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 the Terraform configuration is valid. See Terraform Configurations for Resource Manager and Authoring Configurations.

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

    1. Open the navigation menu and click Developer Services. Under Resource Manager, click Stacks.
    2. On the Stacks page, select a compartment.
    3. Click Create stack.
    4. On the Create stack page, under Choose the origin of the Terraform configuration, select Source code control system.
    5. Under Stack configuration, for Source code management type, select GitHub or GitLab.
    6. Select the Git configuration source provider that you want.
      If you need to create a configuration source provider, click Create configuration source provider and enter values. For information about the fields, see Creating a GitHub Configuration Source Provider or Creating a GitLab Configuration Source Provider.
    7. Select the Git repository and branch. The list of branches is limited to 100.
    8. (Optional) To use a directory other than the root directory for running Terraform, specify the working directory. This field is visible when the selected branch has directories. Examples:
      • One level: Directory
      • Two levels: Directory/Subdirectory
    9. (Optional) To use custom providers, select Use custom providers and then select the bucket that contains the custom provider.
    10. (Optional) Edit the default stack name and enter a stack description. Avoid entering confidential information.
    11. Select the compartment where you want to create the stack.
    12. For Terraform version, select the version used by the Terraform configuration.
    13. (Optional) Click Show advanced options and assign tags to the stack.
      • Tag namespace: To add a defined tag, select an existing namespace. To add a free-from tag, leave the value blank.
      • Tag key: To add a defined tag, select an existing tag key. To add a free-form tag, type the key name that you want.
      • Tag value: Type the tag value that you want.
      • Add tag: Click to add another tag.
    14. Click Next.
    15. In the Configure variables panel, review the variables listed from the Terraform configuration and change as needed.
      Important

      Don't add your private key or other confidential information to configuration variables.
    16. Click Next.
    17. In the Review panel, verify the stack configuration.
    18. (Optional) To automatically provision resources on creation of the stack, select Run apply.
    19. Click Create.

    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.

  • 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 parameters and values 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 ""
  • Use the CreateStack operation to create a stack from Git.

    For an example of the configSource part of the request, see CreateGitConfigSourceDetails.

    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>",
      }
    }