Oracle Cloud Infrastructure Documentation

3. Create and Configure a Copy of oci-curl

You can use a bash script provided by Oracle (commonly referred to as oci-curl) to invoke a function. The oci-curl script creates a signed request, based on credentials you provide in the body of the script. For more information about oci-curl, see Request Signatures - Bash.

To use oci-curl to invoke a function, you must provide the credentials of an Oracle Cloud Infrastructure user that has been granted access to resources in the same tenancy and belonging to the same compartment as the function (see Create Policies to Control Access to Network and Function-Related Resources).

Typically you'll want to invoke a function as the functions developer that's configured for your development environment. The instructions below assume that is the case.

The instructions in this topic assume you have already completed the steps in 2. Create a Profile in the Oracle Cloud Infrastructure CLI Configuration File.

To create and configure a copy of oci-curl:

  1. Log in to your development environment as a functions developer.

  2. Create a copy of the oci-curl script file in your development environment and add your credentials to the file as follows:

    1. In a browser navigate to https://docs.cloud.oracle.com/iaas/Content/Resources/Assets/signing_sample_bash.txt to see the oci-curl code as raw text.

    2. Select all the text and copy it.

    3. In a text editor, open a new file in a convenient location. For example, in a terminal window, you might create a new subdirectory in your home directory and open a new file in that directory by entering:

      $ cd ~
      
      $ mkdir oci-curl
      
      $ vim ~/oci-curl/oci-curl.sh

      The name and location of the new file is up to you, but the following instructions assume ~/oci-curl/oci-curl.sh.

    4. Paste the oci-curl script code that you copied earlier into the new file.

    5. Save the file but leave it open so you can add your credentials.
  3. Replace the sample credentials in the oci-curl.sh file with those of the user account that you want to invoke functions, as follows:
    1. Locate the following lines in the oci-curl.sh file that contain sample credential values:

      # TODO: update these values to your own
      local tenancyId="ocid1.tenancy.oc1..aaaaaaaab______dsq";
      local authUserId="ocid1.user.oc1..aaaaaaaas______o3r";
      local keyFingerprint="20:3b:97:13:55:1c:5b:0d:d3:37:d8:50:4e:c5:3a:34";
      local privateKeyPath="/Users/someuser/.oci/oci_api_key.pem";

      Tip

      Typically you'll want to invoke a function as the functions developer that's configured for your development environment. If that's the case, open the ~/.oci/config file so you can easily copy values from there to replace the sample values in the oci-curl.sh file.

    2. Change the value of the tenancyId parameter in the oci-curl.sh file by replacing the sample value in quotes with the OCID of the tenancy in which the function has been deployed. For example:

      local tenancyID="ocid1.tenancy.oc1..aaaaaaaap______keq";
    3. Change the value of the authUserID parameter in the oci-curl.sh file by replacing the sample value in quotes with the OCID of the user account that you want to run the function. The user account must have access to resources in the same tenancy and belonging to the same compartment as the function. For example:

      local authUserId="ocid1.user.oc1..aaaaaaaas______7ap";
    4. Change the value of the keyFingerprint parameter in the oci-curl.sh file by replacing the sample value in quotes with the fingerprint of the user's public key uploaded to Oracle Cloud Infrastructure. For example:

      local keyFingerprint="d1:b2:32:53:d3:5f:cf:68:2d:6f:8b:5f:77:8f:07:";
    5. Change the value of the privateKeyPath parameter in the oci-curl.sh file by replacing the sample value in quotes with the full path to the private key file that is paired with the public key for which you provided the fingerprint. For example:

      local privateKeyPath="/Users/johndoe/.oci/john_api_key_private.pem";
  4. Save and close the oci-curl.sh file.

Note

When you've deployed functions to Oracle Functions and you want to use oci-curl to invoke them, you will first have to run the source command to set up the current shell environment for oci-curl. See Invoking Functions.

When you have completed the steps in this topic, go on to 4. Install Docker for Use with Oracle Functions.