Creating a Stack from Git

Create a stack in Resource Manager from a Terraform configuration stored in Git. Select a configuration source provider that specifies the Git information needed to access the configurations.

Ensure that your Terraform configuration is valid. See Terraform Configurations for Resource Manager and Authoring Configurations.

For information about configuration source providers, see Managing Configuration Source Providers.

Using the Console

  1. Open the navigation menu and click Developer Services. Under Resource Manager, click Stacks.
  2. Choose a compartment that you have permission to work in (on the left side of the page).
  3. Click Create stack.
  4. In the Create stack page, under Choose the origin of the Terraform configuration, select Source code control system.
  5. Select the configuration source provider location for your Terraform configuration:
    1. Select a Configuration source provider.
      If you need to create one, see To create a configuration source provider.
    2. Select a Repository.
      Example: https://gitlab.com/example
    3. Select a Branch.
      The list returned is limited to 100 branches.
    4. (Optional) Specify a Working directory for running Terraform.

      This field is visible when you select a branch with directories.

      Example (one level): Directory

      Example (two levels): Directory/Subdirectory

      If not specified, the root directory is used.

    The dialog box is populated with information contained in the Terraform configuration.
  6. In the Stack information panel, fill in the fields.
    FieldDescription
    Use custom providers Select this option to use custom providers, and then select the bucket that contains the custom providers.
    Name Stack name. You can accept the default name provided. Avoid entering confidential information.
    Description Stack description (optional).
    Create in compartment Compartment where you want to create the stack. A compartment from the list scope is set by default.
    Terraform version Version that you want for the Terraform configuration.
    Tags Optionally apply tags to the stack.
  7. Click Next.
    The Configure variables panel lists variables from the Terraform configuration.
  8. Review the variables and change as needed.
    Important

    Don't add your private key or other confidential information to configuration variables.
  9. Click Next.
  10. In the Review panel, verify your stack configuration.
  11. To automatically provision resources when the stack is created, select Run apply.
    Note

    Run apply is selected by default for stacks created from the Deploy to Oracle Cloud button or from Marketplace.
  12. Click Create to create your stack.

The stack is created and its Stack details page opens.

If you selected Run apply, then Resource Manager runs the apply action on the new stack.

Using the CLI

Use the oci resource-manager stack create-from-git-provider command and required parameters to create a stack from Git.

oci resource-manager stack create-from-git-provider [OPTIONS]

For a complete list of flags and variable options for CLI commands, see the Command Line Reference for Resource Manager.

Example Request
oci resource-manager stack create-from-git-provider --compartment-id ocid1.tenancy.oc1..uniqueid --config-source-configuration-source-provider-id ocid.ormconfigsourceprovider.oc1..uniqueid --config-source-repository-url https://github.com/user/repo.git --config-source-branch-name mybranch --display-name "My Stack from Git" --description "My Test" --variables file://variables.json --working-directory ""

Using the API

Use the CreateStack operation to create a stack from Git.

Example request
POST /20180917/stacks
Host: resourcemanager.us-phoenix-1.oraclecloud.com
<authorization and other headers>
{
  "compartmentId": "ocid1.compartment.oc1..<unique_ID>",
  "displayName": "My GitHub Configuration",
  "configSource": {
    "configSourceType": "GIT_CONFIG_SOURCE",
    "configurationSourceProviderId": "ocid1.ormconfigsourceprovider.oc1..<unique_ID>",
    "repositoryUrl": "https://github.com/user/repo.git",
    "branchName": "MyBranch",
    "workingDirectory": "<file_path_to_directory>",
  }
}