Managing Private Templates

This topic describes how to create, edit, and delete private templates for reuse of Terraform configurations.

Required IAM Policy

To manage private templates, you must be given the required type of access in a policy  written by an administrator, whether you're using the Console or the REST API with an SDK, CLI, or other tool. If you try to perform an action and get a message that you don’t have permission or are unauthorized, confirm with your administrator the type of access you've been granted and which compartment  you should work in.

Important

Policies for managing Oracle Cloud Infrastructure resources are also required for Resource Manager operations that access resources. For example, running an apply job on a stack that includes Compute instances and subnets requires policies that grant you permissions for those resource types, in the compartments where you want to provision the resources. To see examples of policies for managing Oracle Cloud Infrastructure resources, see Common Policies.

If you're new to policies, see Getting Started with Policies and Common Policies.

Administrators: For common policies that give groups access to Resource Manager resources, see Manage Private Templates (Securing Resource Manager).

Using the Console

To create a private template
  1. Open the navigation menu and click Developer Services. Under Resource Manager, click Private Templates.

  2. Choose a compartment that you have permission to work in (on the left side of the page). The page updates to display only the resources in that compartment. If you're not sure which compartment to use, contact an administrator.

  3. Click Create private template.
  4. On the Create private template panel, do the following.
    • Configuration: Select either Folder or .Zip file, then either drag and drop your configuration onto the dialog's control or click Browse and navigate to the folder or file location.
    • If needed, edit the default Name provided for your private template. Avoid entering confidential information.
    • Type a Description.
    • (Optional) In Details, type a detailed description of your private template. This text is displayed in the Console page listing templates when the template is expanded.
  5. Optionally do one or more of the following:
    • To add an icon, click Show advanced options and then either drag and drop your icon file onto the dialog's Template icon control or click Browse and navigate to the file location.

      Template icon file requirements: PNG format, 50 KB maximum, 110 x 110 pixels.

      The icon is displayed in the Console page listing templates when the template is expanded.

    • To choose a different compartment for storing your new private template, click Show advanced options and then select the compartment you want from Compartment.
    • To tag the template, click Show advanced options and add your tag.
  6. Click Create.

    Congratulations, your private template is now created. You can now share the private template with anyone in your tenancy who has sufficient permissions.

    For instructions to create a stack from your private template, see Creating a Stack from a Template.

To create a stack from a private template

This section provides instructions for starting the stack creation process from the detail page for a private template. You can alternatively select a private template when creating a stack.

  1. Open the navigation menu and click Developer Services. Under Resource Manager, click Private Templates.

  2. Choose a compartment that you have permission to work in (on the left side of the page). The page updates to display only the resources in that compartment. If you're not sure which compartment to use, contact an administrator.

  3. Click the name of the private template you want.
  4. On the detail page for the selected private template, click Create stack.

    The Create Stack page appears, populated with information contained in the Terraform configuration for the selected template.

  5. Select the Working directory for running Terraform.

    This option is available when multiple directories exist in the template's Terraform configuration.

  6. Enter a Name for the new stack (or accept the default name provided). Avoid entering confidential information.
  7. Optionally enter a Description.
  8. From the Create in compartment drop-down, select the compartment where you want to create the stack.

    A compartment from the list scope is set by default.

  9. Optionally apply tags to the stack.

    If you have permissions to create a resource, then you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you are not sure whether to apply tags, skip this option (you can apply tags later) or ask your administrator.

  10. Click Next.

    The Configure variables panel displays variables from the Terraform configuration.

  11. Review the variables and make changes as necessary.

    Important

    Do not add your private key or other confidential information to configuration variables.
  12. Click Next.
  13. In the Review panel, verify your stack configuration.
  14. To automatically provision resources when the stack is created, select Run apply.

  15. Click Create to create your stack.

    The stack detail page for the new stack appears.

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

    If Run apply was not selected, then you can manually run an apply job on the stack.

To view private templates
  1. Open the navigation menu and click Developer Services. Under Resource Manager, click Private Templates.

  2. Choose a compartment that you have permission to work in (on the left side of the page). The page updates to display only the resources in that compartment. If you're not sure which compartment to use, contact an administrator.

To edit a private template
  1. Open the navigation menu and click Developer Services. Under Resource Manager, click Private Templates.

  2. Choose a compartment that you have permission to work in (on the left side of the page). The page updates to display only the resources in that compartment. If you're not sure which compartment to use, contact an administrator.

  3. Click the name of the private template you want.
  4. On the detail page for the selected private template, click Edit.
  5. In the Edit template panel, update the properties you want.
  6. Click Save.
To delete a private template
  1. Open the navigation menu and click Developer Services. Under Resource Manager, click Private Templates.

  2. Choose a compartment that you have permission to work in (on the left side of the page). The page updates to display only the resources in that compartment. If you're not sure which compartment to use, contact an administrator.

  3. Click the Actions menu, select Delete private template, and confirm the operation when prompted.

    Note

    You cannot undo this operation.

    You can also delete a private template from its detail page. Click the name of the template to display the Template information page and then click Delete.

Using the CLI

This section provides basic sample CLI commands for managing private templates. For information about using the CLI, see Command Line Interface (CLI). For a complete list of flags and options available for CLI commands, see CLI Help.

To create a private template from an uploaded file

This section describes how to create a private template from an uploaded configuration file (.zip).

Open a command prompt and run oci resource-manager template create to create a private template: 

oci resource-manager template create --compartment-id <compartment_OCID> --display-name "<friendly_name_for_template>" --description "<description>" --long-description "<long-description>" --logo-file <icon_file_name> --from-json <config_file_name>

For example: 

oci resource-manager stack create --compartment-id ocid1.tenancy.oc1..uniqueid --display-name "My Template" --description "My Default VCN" --long-description "Use this template to provision the default VCN." --logo-file file://mylogo.png --from-json file://myconfig.json
To create a stack from a private template

This section describes how to create a stack from a private template.

Open a command prompt and run oci resource-manager stack create-from-template to create a stack from a private template: 

oci resource-manager stack create-from-template --compartment-id <compartment_OCID> --template-id "<template_OCID>"