This is an example to show how to send SMS from OCI using Notification Service, Function and Syniverse. Syniverse offers support for an SMS service on a global scale that allows enterprise customers to send intelligent and customizable messages with a cloud-based solution.
Another option is to combine Logging and Service Connector Hub to emit a notification with the log content every time that a specific log is generated, such as every time a log has a 500 error.
More
As you make your way through this tutorial, look out for this icon . Whenever you see it, it's time for you to perform an action.
Before you deploy this sample function, make sure you have run steps A, B and C of the Oracle Functions Quick Start Guide for Cloud Shell
- A - Set up your tenancy
- B - Create application
- C - Set up your Cloud Shell dev environment
Assuming you have successfully completed the prerequisites, you should see your application in the list of applications.
fn ls apps
-
Go to the Syniverse Developer Community and create an account.
-
Sign in to your Syniverse account, go to the Applications menu, and click Create New.
-
Enter the following:
- Application Name: oci
- Description: Real-time SMS with OCI Alert or OCI logs
- Account: Choose your initial account
-
After creating the application, click the application name and expand Auth Keys to see the API details. We use this info on the Oracle Function and Vaults.
First, you need to create a Bucket.
-
From the menu in the upper-left corner, select Core Infrastructure, and then select Object Storage.
-
Select the compartment syniverse_compartment that you created.
-
Click Create Bucket and create a Bucket with syniverse_phone_target_list name
Create and upload a file with the phone number. The Function has an object store dependency because it reads the file with recipient phones to send the SMS.
-
Create a local file called numbers.txt and add the phone number that you want to use for your case. The file should be comma delimited with no spaces.
-
From the Object Storage details screen click Upload Objects and select the numbers.txt file to upload
-
From the menu in the upper-left corner, select Security, and then select Vault.
-
Select syniverse_compartment that you created.
-
Click Create Vault and create a vault with syniverse-api-credentials name.
-
Choose your Vault, click Create Key and create a key with syniverse-key name, leaving the other fields (protection mode, key shape algorithm, key shape length) as default.
-
Click on the Secrets link under Resources in the left navigation pane
-
Click Create Secret and use the following example:
- Name: syniverse-token
- Encryption Key: Select the syniverse-key that you created earlier
- Secret Type Template: Base64
- Secret Contents: here you should add the Access token from Syniverse
-
Click on the secret syniverse-token, copy the secret OCID and replace the value in the func.yaml file of your sample function:
In order to use other OCI Services, your function must be part of a dynamic group. For information on how to create a dynamic group, refer to the documentation.
When specifying the Matching Rules, we suggest matching all functions in a compartment with:
ALL {resource.type = 'fnfunc', resource.compartment.id = 'ocid1.compartment.oc1..aaaaaxxxxx'}
Create a new policy that allows the dynamic group to read objects and secret-bundles in the functions-related compartment.
Your policy should look something like this:
Allow dynamic-group <dynamic-group-name> to read objects in compartment <compartment-name>
Allow dynamic-group <dynamic-group-name> to read secret-bundles in compartment <compartment-name>
e.g.
Allow dynamic-group demo-func-dyn-group to read objects in compartment demo-func-compartment
Allow dynamic-group demo-func-dyn-group to read secret-bundles in compartment demo-func-compartment
For more information on how to create policies, go here.
Refer to the readme for each function:
Refer to the readme for each function:
Refer to the readme for each function: