Deploy an Event-Triggered Serverless Application

Oracle Functions is a serverless, highly scalable, fully managed platform built on Oracle Cloud Infrastructure and powered by the Fn Project open source engine. Developers can use it to write and deploy code that delivers business value without worrying about provisioning or managing the underlying infrastructure. Oracle Functions is container-native with functions packaged as Docker container images.


This reference architecture invokes Oracle Functions with the Oracle Cloud Infrastructure Events service, which responds automatically to changes made to Oracle Cloud Infrastructure Object Storage. Uploading a sample image to Object Storage triggers the Events service, which in turn invokes Oracle Functions. The Fn Project supports most programming languages. This architecture uses Java in the function to extract the metadata from the uploaded image and store it in Oracle Cloud Infrastructure Object Storage.

The following diagram illustrates this reference architecture.

Description of serverless-oci.png follows
Description of the illustration serverless-oci.png

The Oracle Functions architecture has the following components:

  • Region

    An Oracle Cloud Infrastructure region is a localized geographic area that contains one or more data centers, called availability domains. Regions are independent of other regions, and vast distances can separate them (across countries or even continents).

  • Availability domains

    Availability domains are standalone, independent data centers within a region. The physical resources in each availability domain are isolated from the resources in the other availability domains, which provides fault tolerance. Availability domains don’t share infrastructure such as power or cooling, or the internal availability domain network. So, a failure at one availability domain is unlikely to affect the other availability domains in the region.

  • Virtual cloud network (VCN) and subnets

    A VCN is a customizable, software-defined network that you set up in an Oracle Cloud Infrastructure region. Like traditional data center networks, VCNs give you complete control over your network environment. A VCN can have multiple non-overlapping CIDR blocks that you can change after you create the VCN. You can segment a VCN into subnets, which can be scoped to a region or to an availability domain. Each subnet consists of a contiguous range of addresses that don't overlap with the other subnets in the VCN. You can change the size of a subnet after creation. A subnet can be public or private.

    The function in this reference architecture is deployed in a public regional subnet.

  • Oracle Functions

    Oracle Functions lets you deploy your code, call it directly, or trigger it in response to events. Oracle Functions is triggered when the Events service invokes it, processes the image, and stores the metadata back to Object Storage. Oracle Functions uses Docker containers hosted on Oracle Cloud Infrastructure Registry.

  • Events

    Oracle Cloud Infrastructure services emit events, which are structured messages that indicate changes in resources. Events include create, read, update, or delete (CRUD) operations, resource lifecycle state changes, and system events that impact a resource. An event can be emitted when a backup finishes or fails, or when a file in an Object Storage bucket is added, updated, or deleted.

  • Object Storage

    Oracle Cloud Infrastructure Object Storage is an internet-scale, high-performance storage platform that offers reliable and cost-efficient data durability. Object Storage can store an unlimited amount of unstructured data of any content type, including analytic data and rich content, like images and videos. Two distinct storage tiers address the need for frequently accessed "hot" storage (Standard) and less frequently accessed "cold" storage (Archive). Standard Object Storage is for data that you need to access quickly, immediately, and frequently. Archive Storage is for data that you need to seldom or rarely access, but that must be retained and preserved for long periods of time.


Your requirements might differ from the architecture described here. Use the following recommendations as a starting point.

  • VCN

    When you create a VCN, determine the number of CIDR blocks required and the size of each block based on the number of resources that you plan to attach to subnets in the VCN. Use CIDR blocks that are within the standard private IP address space.

    After you create a VCN, you can change, add, and remove its CIDR blocks.

    This architecture uses a public VCN to deploy the function. The function is hosted on a public regional subnet in the VCN. You can also use a private VCN. In that case, you must use a NAT gateway to have access to the internet.

  • Oracle Functions

    In this architecture, Java programming was used to develop the functions. Because the Fn Project supports multiple programming languages, you can use the language of your choice to develop the functions and deploy them.

  • Object Storage

    This architecture uses Standard Object Storage to upload an image and store it, so that the Events service can pick it up when the object is created. Object Storage stores the metadata about the object after Functions processes.

  • Events

    In this architecture, the Oracle Cloud Infrastructure Events service is configured to listen to changes in Object Storage creation. The service is invoked after the object is uploaded to Object Storage and calls the function for processing.


  • Availability

    The Events service is not available in regions within the Government Cloud realm.

  • Manageability

    This architecture uses a sample Java application to write the functions. However, you can use the programming language of your choice.

  • Security

    Use policies to restrict who can access the Oracle Cloud Infrastructure resources that your company has and how.

    For Object Storage, encryption is enabled by default and can’t be turned off.

    All access to functions deployed in Oracle Functions is controlled through Oracle Cloud Infrastructure Identity and Access Management (IAM). IAM allows both function management and function invocation privileges to be assigned to specific users and user groups.

  • Cost

    You pay for only the resources used while a function is running.


The Terraform code for this reference architecture is available in GitHub. You can pull the code into Oracle Cloud Infrastructure Resource Manager with a single click, create the stack, and deploy it. Alternatively, you can download the code from GitHub to your computer, customize the code, and deploy the architecture by using the Terraform command line interface (CLI).

  • Deploy by using Oracle Cloud Infrastructure Resource Manager:
    1. Click Deploy to Oracle Cloud

      If you aren't already signed in, enter the tenancy and user credentials.

    2. Review and accept the terms and conditions.
    3. Select the region where you want to deploy the stack.
    4. Follow the on-screen prompts and instructions to create the stack.
    5. After creating the stack, click Terraform Actions, and select Plan.
    6. Wait for the job to complete, then review the plan.

      To make any changes, return to the Stack Details page, click Edit Stack, and make the required changes. Then, run the Plan action again.

    7. If no further changes are necessary, return to the Stack Details page, click Terraform Actions, and select Apply.
  • Deploy using the Terraform code in GitHub:
    1. Go to GitHub.
    2. Clone or download the repository to your local computer.
    3. Follow the instructions in the README document.

Change Log

This log lists only the significant changes: