Oracle Functions is a serverless, highly scalable, fully managed Functions-as-a-Service platform built on Oracle Cloud Infrastructure and powered by the open-source Fn Project engine. Developers can use Oracle Functions 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 shows how you can use a serverless function to in response to cloud events.
The architecture diagram shows the data flow. When files are uploaded to a specific bucket in Oracle Cloud Infrastructure Object Storage, the Events service is triggered. The emitted event invokes a function, which extracts metadata from the uploaded files and loads the data into a different bucket in Oracle Cloud Infrastructure Object Storage.
For details of the architecture, see Deploy an event-triggered serverless application
-
Permission to
manage
the following types of resources in your Oracle Cloud Infrastructure tenancy:vcns
,internet-gateways
,route-tables
,security-lists
,serviceconnectors
,buckets
,subnets
, andfunctions
. -
Quota to create the following resources: 1 VCN, 1 subnets, 1 Internet Gateway, 1 route rules, 1 function, 1 service connector, 2 buckets.
If you don't have the required permissions and quota, contact your tenancy administrator. See Policy Reference, Service Limits, Compartment Quotas.
-
If you aren't already signed in, when prompted, enter the tenancy and user credentials.
-
Review and accept the terms and conditions.
-
Select the region where you want to deploy the stack.
-
Follow the on-screen prompts and instructions to create the stack.
-
After creating the stack, click Terraform Actions, and select Plan.
-
Wait for the job to be completed, and 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.
-
If no further changes are necessary, return to the Stack Details page, click Terraform Actions, and select Apply.
Now, you'll want a local copy of this repo. You can make that with the commands:
git clone https://github.com/oracle-devrel/terraform-oci-arch-fn-app.git
cd terraform-oci-arch-fn-app
ls
First off, you'll need to do some pre-deploy setup for Docker and Fn Project inside your machine:
sudo su -
yum update
yum install yum-utils
yum-config-manager --enable *addons
yum install docker-engine
groupadd docker
service docker restart
usermod -a -G docker opc
chmod 666 /var/run/docker.sock
exit
curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
exit
-
Complete the prerequisites described here.
-
Create a
terraform.tfvars
file, and specify the following variables:
# Authentication
tenancy_ocid = "<tenancy_ocid>"
user_ocid = "<user_ocid>"
fingerprint = "<finger_print>"
private_key_path = "<pem_private_key_path>"
# Region
region = "<oci_region>"
# Compartment
compartment_ocid = "<compartment_ocid>"
# OCIR
ocir_user_name = "<ocir_user_name>"
ocir_user_password = "<ocir_user_password>"
Run the following commands:
terraform init
terraform plan
terraform apply
You can test the stack by uploading files into the first bucket. If event emission will be successful, the function should be executed, metadata is extracted from the uploaded files and the function output is stored to the second bucket, function-output-bucket.
Within the automated deployment, a random id tag is appended to the bucket names. This is visible in the Terraform output (sample below).
Outputs:
buckets_created = "bucket-44ac, function-output-bucket-44ac"
When you no longer need the deployment, you can run this command to destroy the resources:
terraform destroy
You can utilize this repository as remote module, providing the necessary inputs:
module "oci-arch-fn-app" {
source = "github.com/oracle-devrel/terraform-oci-arch-fn-app"
tenancy_ocid = "<tenancy_ocid>"
user_ocid = "<user_ocid>"
fingerprint = "<user_ocid>"
region = "<oci_region>"
private_key_path = "<private_key_path>"
compartment_ocid = "<compartment_ocid>"
ocir_user_name = "<ocir_user_name>"
ocir_user_password = "<ocir_user_password>"
}
It is possible to deploy this architecture using an existing VCN and public subnet. Please refer to the examples folder.
This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.
Initially, this project was created and distributed in GitHub Oracle QuickStart space. For that reason, we would like to thank all the involved contributors enlisted below:
- Kartik Hedge (https://github.com/KartikShrikantHegde)
- Lukasz Feldman (https://github.com/lfeldman)
- Ben Lackey (https://github.com/benofben)
Copyright (c) 2021 Oracle and/or its affiliates.
Licensed under the Universal Permissive License (UPL), Version 1.0.
See LICENSE for more details.