Codify assets to Terraform

Codify assets and create reusable code. This code uses resource descriptions instead of resource IDs so that the code can be used in other subnets.

Procedure

  1. Select Inventory.

  2. Select the asset(s) and Codify > Terraform.

The code describes the configuration of the dependencies rather than referencing the specific ID. The following codification options are available:

TypeDescription

Explicit Values

Creates code for one or multiple assets using the resource IDs of dependencies.

Data Sources

Creates code that describes the configuration of the dependencies rather than referencing the explicit resource IDs.

Codify Unmanaged Dependencies

Creates code that codifies all unmanaged dependencies with explicit resource IDs.

Codify All Dependencies

Creates code for the asset and all of its dependencies, including codified dependencies. For unmanaged dependencies, the configuration of the data source is used rather than the explicit resource ID. Use this code to create multiple instances of the same environment. This code can also be used to create a module.

Module Call

Creates code for the asset and all of its dependencies in the private or public module that you specify. Create a separate module call for each asset. The module is used to create additional instances of the asset. The module is stored in the repository that holds your Terraform files. (If your public module is not included in Terraform AWS or GCP modules, contact us, and we will create it for you).

Create Module

Creates a reusable module for any type of asset and its dependencies. The module can be created either from a private module in your Git or from a public module in the Terraform Registry. After creating the module, you can store it in your Git and import the assets. You can deploy this module in any region or account.

Preview represents an experimental version of the codification feature.

Generating Import Blocks

Import existing resources into Terraform and bring them under its management.

Import blocks are only available in Terraform v.1.50 or later.

Procedure

  1. To generate the block for your Terraform code, switch the Import Blocks toggle.

  2. To preview the import plan and generate configuration for your resources, run the terraform plan command.

  3. Copy the code, and add the block to your Terraform configuration file.

Generating Provider Blocks

To create the Terraform provider configuration, generate a provider block.

Procedure

  1. Switch the Provider Block toggle.

  2. Copy the code, and add the block to your Terraform configuration file.

Using the Terraform import command

Terraform imports your existing infrastructure resources and brings them under its management. Each remote object must be imported to only one Terraform resource address.

Procedure

  1. To import the resource into your state file, select >_ Import Commands, and copy or export the code.

  2. Open the Terraform console, and paste the Terraform code into your Terraform file.

  3. Run the command in your Terraform file.

Codify Revision

Roll back any asset to a previous revision.

Procedure

  1. Select Inventory.

  2. To view your assets with a revision history, select Mutations.

  3. Select the asset and Mutations.

  4. To codify the previous revision of the asset, select Codify Revision.

Creating a pull request

Add your Terraform resources to your integrated version control system (VCS). Resources can be added to an existing file in your VCS by selecting a target branch and file path.

Procedure

  1. Select Pull request.

  2. Select a VCS Integration.

  3. Select a Repository.

    • Optional: Select the Target Branch.

    • Optional: Add a File Path. Select Browse Repository and locate the destination file.

  4. Select Create.

Last updated