Terraform State Related Functionalities
Utilize the ‘Terraform Cloud’ tool in the Opsera Tool Registry to integrate Terraform Cloud in Opsera Pipelines. In the ‘Organizations’ tab create, delete and edit organizations in Terraform Cloud. Once an organization is created, navigate to the ‘Workspaces’ to add a Terraform Cloud Workspace. The Terraform Cloud Workspace added in this tab will be referenced in the pipeline setup in the scenario that a user wants to save the terraform state file remotely to the configured Terraform Cloud.
Terraform Cloud Configuration in Tool Registry:
Once you have created a new tool using ‘Terraform Cloud’ as tool identifier, provide the proper configuration details in the ‘Connections’ tab:
Terraform Cloud URL - http://app.terraform.io
Terraform Token - Provide your access Token from Terraform.
Is Terraform Enterprise? - Enable toggle if using a Terraform Enterprise URL. If the toggle is enabled, this tool will be fetched in pipeline steps as ‘Terraform Enterprise’.Save your configurations and click the ‘Test Connection’ button to verify the connection is successful.
Navigate to the ‘Organizations’ tab.
Click the ' + New Terraform Cloud Organization' button to add a new Organization.
Â
Provide a name for your Terraform Cloud Organization and click the ‘Create’ button. You can now access this organization in Terraform Remote State in a pipeline.
Navigate to the ‘Workspaces’ tab to add a new Terraform Cloud Workspace. From the ‘Organization Name’ dropdown, select the organization to add a Terraform Cloud Workspace to.
Click the ‘+ New Terraform Cloud Workspace’ button. Select an Organization Name from the dropdown, provide a Workspace Name and click the ‘Create’ button.
Â
Misc Observed pipeline changes:
Verify these are new changes:
Terraform Version - select version or ‘latest’ to use most recent
Terraform Execution Script - Select Opsera Script or Custom Script from the dropdown.
Terraform Commands - Provide terraform commands: execute, update, delete
Â
Terraform Remote State in Pipeline
Terraform Remote State can be utilized in the Terraform pipeline step support to saving the terraform state file in a remote location. This will allow you to indicate via toggle if you would like to save the terraform state file to a remote location and specify the location where the terraform state file will be saved.
To support saving the terraform state file in a remote location, enable the ‘Maintain Remote State’ toggle, then proceed to select the location where Terraform State will be saved.
Once the ‘Maintain Remote State’ toggle is enabled, the following fields will become available for selection.
State File Management:
Automatic
Manual - Managed by Opsera
Backend State - Select AWS S3, Azure, Terraform Cloud, Terraform Enterprise or Local Filesystem from the dropdown list. Depending on selection, the following selections will be made available from dropdown menus:
AWS S3
S3 Bucket Name - Select a bucket name pulled from AWS.
Bucket Region - Select the region of the selected bucket from the dropdown.
Azure
Azure Tool - Select a configured Azure Tool from the Tool Registry.
Azure Credential - Select the configured Azure Application Credentials from the Azure Tool’s ‘Applications’ tab .
Storage Account Name - Select the Storage Account Name, fetched from the configured Azure app.
Resource Group - Select a Resource Group fetched from the Azure portal.
Storage Container - Select a Storage Container fetched from the Azure portal.
Terraform Cloud
Terraform Cloud Tool - Select a configured Terraform Cloud tool from the Tool Registry.
Organization Name - Select the Organization from the selected Terraform Cloud Tool, added in ‘Organization’ tab of the Terraform Cloud tool.
Workspace Name - Select the Workspace Name added in the ‘Workspaces’ tab of the Terraform Cloud tool.
Terraform Enterprise - In order for the Terraform Cloud tool to be fetched as Terraform Enterprise, navigate to the ‘Connection' tab of tool in Tool Registry and enable the ‘Is Terraform Enterprise?’ toggle.
Terraform Cloud Tool - Select a configured Terraform Cloud tool from the Tool Registry with enabled Terraform Enterprise toggle and corresponding Terraform Enterprise URL.
Organization Name - Select the Organization from the selected Terraform Cloud Tool, added in ‘Organization’ tab of the Terraform Cloud tool.
Workspace Name - Select the Workspace Name added in the ‘Workspaces’ tab of the Terraform Cloud tool.
Â