Creating a Stack from a Zip File

Create a stack in Resource Manager from a local Terraform configuration stored in a zip file.

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

    1. On the Stacks list page, select Create stack. If you need help finding the list page or the stack, see Listing Stacks.
    2. On the Create stack page, under Choose the origin of the Terraform configuration, select My configuration.
    3. Select .Zip file and add the revised Terraform configuration.
      You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
      The page is populated with information contained in the Terraform configuration.
    4. (Optional) To use custom providers, select Use custom providers and then select the bucket that contains the custom provider.
    5. (Optional) Edit the default stack name and enter a stack description. Avoid entering confidential information.
    6. Select the compartment where you want to create the stack.
    7. For Terraform version, select the version used by the Terraform configuration.
    8. (Optional) Select 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.
    9. Select Next.
    10. 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.
    11. Select Next.
    12. In the Review panel, verify the stack configuration.
    13. (Optional) To automatically provision resources on creation of the stack, select Run apply.
    14. Select 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.

  • Note

    On Windows, be sure the zip file and variables.json files are in the same directory from which you're running the CLI. The CLI currently has a limitation on Windows that prevents correct handling of the files if either one is in a subdirectory.

    Use the oci resource-manager stack create command and required parameters to create a stack from a local zip file.

    oci resource-manager stack create [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 --compartment-id ocid1.tenancy.oc1..uniqueid --config-source vcn.zip --variables file://variables.json --display-name "My Example Stack" --description "My Tutorial to Create a VCN" --working-directory ""
    Example Response
    {
      "data": {
        config-source": 
        {
          "working-directory": null,
          "config-source-type": "ZIP_UPLOAD"
        },
        "defined-tags": {},
        "description": "My Tutorial to Create a VCN",
        "display-name": "My Example Stack",
        "freeform-tags": {},
        "id": "ocid1.ormstack.oc1..uniqueid",
        "lifecycle-state": "ACTIVE",
        "time-created": "2019-04-03T18:26:56.299000+00:00",
        "variables": 
        {
          "compartment_ocid": "ocid1.compartment.oc1..uniqueid", 
          "region": "us-phoenix-1"
        }
      }
    }
  • Use the CreateStack operation to create a stack from a local zip file.

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

    Example request
    POST /20180917/stacks
    Host: resourcemanager.us-phoenix-1.oraclecloud.com
    <authorization and other headers>
    {
      "compartmentId": "ocid1.compartment.oc1..<unique_ID>",
      "terraformVersion": "0.12.x",
      "displayName": "My Zip Configuration",
      "configSource": {
        "configSourceType": "ZIP_UPLOAD",
        "zipFileBase64Encoded": "<zip_file_content_encoded_in_base64_format>",
        "workingDirectory": "<file_path_to_directory>"
      },
    }