Giter VIP home page Giter VIP logo

list-compartments-sample-repo's Introduction

Function that returns the list of compartments in a user's tenancy

This function uses Resource Principals to securely authorize a function to make API calls to OCI services using the OCI Python SDK. It returns a list of all compartments within the tenancy.

The function calls the following OCI Python SDK classes:

As you make your way through this tutorial, look out for this icon user input icon. Whenever you see it, it's time for you to perform an action.

Prerequisites

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

List Applications

Assuming you have successfully completed the prerequisites, you should see your application in the list of applications.

fn ls apps

Create or Update your Dynamic Group

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 or Update Policies

This function does not require any particular IAM policy.

Review and customize the function

Review the following files in the current folder:

  • requirements.txt which specifies all the dependencies for your function
  • func.yaml which contains metadata about your function and declares properties
  • func.py which is your actual Python function

The name of your function oci-list-compartments-python is specified in func.yaml.

Deploy the function

In Cloud Shell, run the fn deploy command to build the function and its dependencies as a Docker image, push the image to the specified Docker registry, and deploy the function to Oracle Functions in the application created earlier:

user input icon

fn -v deploy --app <app-name>

e.g.

fn -v deploy --app myapp

Test

user input icon

fn invoke <app-name> <function-name>

e.g.

fn invoke myapp oci-list-compartments-python

You should see all the compartments in your tenancy listed in the terminal.

Monitoring Functions

Learn how to configure basic observability for your function using metrics, alarms and email alerts:

list-compartments-sample-repo's People

Contributors

lmafonso avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.