From 9430dbec825a3135deba3ce5968cabebff09c0a1 Mon Sep 17 00:00:00 2001 From: cailyoung Date: Mon, 24 Nov 2025 15:20:35 +1100 Subject: [PATCH 1/2] fix up this page --- .../environment_variables.png | Bin .../environment_variables.png.json | 1 + .../preparing-your-terraform-environment/index.md | 14 ++++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) rename {src/pages/docs => public/docs/img}/deployments/terraform/preparing-your-terraform-environment/environment_variables.png (100%) create mode 100644 public/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png.json diff --git a/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/environment_variables.png b/public/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png similarity index 100% rename from src/pages/docs/deployments/terraform/preparing-your-terraform-environment/environment_variables.png rename to public/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png diff --git a/public/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png.json b/public/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png.json new file mode 100644 index 0000000000..99a9dbfa86 --- /dev/null +++ b/public/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png.json @@ -0,0 +1 @@ +{"width":2050,"height":836,"updated":"2025-11-24T04:14:41.658Z"} \ No newline at end of file diff --git a/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md b/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md index b43dab7540..9a4804125a 100644 --- a/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md +++ b/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md @@ -1,7 +1,7 @@ --- layout: src/layouts/Default.astro pubDate: 2023-01-01 -modDate: 2023-10-04 +modDate: 2025-11-24 title: Preparing your Terraform environment description: Configuring remote state, backends, and cloud accounts using Terraform with Octopus navOrder: 10 @@ -23,10 +23,10 @@ By default, Terraform stores state files [locally](https://developer.hashicorp.c ### Basic Example -```ruby +```hcl terraform { cloud { - organization = "my-org" + organization = "my-org" workspaces { project = "Default Project" name = "base_layer" @@ -38,7 +38,7 @@ terraform { A common setup will be use a combination of Octopus environment variables, Octopus Project Variables, and hardcoded values. The below example shows the `organization` is inherited from an ENV variable in Octopus, the HCP Terraform project is derived from a combination of Octopus project name and environment name, and the workspace name is hardcoded. -```ruby +```hcl # organization is inherited from ENV variable TF_CLOUD_ORGANIZATION terraform { cloud { @@ -61,7 +61,9 @@ _note: if you set all 3 environment variables, a empty cloud block **must** exis You can add environment Variables to your Octopus project like this: -![setting environment variables in octopus project](environment_variables.png) +:::figure +![setting environment variables in octopus project](/docs/img/deployments/terraform/preparing-your-terraform-environment/environment_variables.png) +::: ## Managed cloud accounts @@ -75,7 +77,7 @@ You can optionally prepare the environment that Terraform runs in using the deta You can query Terraform Enterprise for values from a remote state file using a data source referencing the `tfe_outputs` backend. A token is required and should be set as an ENV variable (`TFE_TOKEN`) -```ruby +```hcl data "tfe_outputs" "previous_step_outputs" { organization = var.organization workspace = var.workspace From 9b66b4cdee674713380ed8cdaf915346f04e1d4e Mon Sep 17 00:00:00 2001 From: cailyoung Date: Tue, 25 Nov 2025 09:44:43 +1100 Subject: [PATCH 2/2] tweak example --- .../preparing-your-terraform-environment/index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md b/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md index 9a4804125a..05f6520a20 100644 --- a/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md +++ b/src/pages/docs/deployments/terraform/preparing-your-terraform-environment/index.md @@ -36,15 +36,16 @@ terraform { ``` ### Common Example -A common setup will be use a combination of Octopus environment variables, Octopus Project Variables, and hardcoded values. The below example shows the `organization` is inherited from an ENV variable in Octopus, the HCP Terraform project is derived from a combination of Octopus project name and environment name, and the workspace name is hardcoded. +A common setup will be use a combination of Octopus environment variables, Octopus Project Variables, and hardcoded values. The below example shows the `organization` is inherited from an ENV variable in Octopus, the HCP Terraform project is derived from the Octopus project name, and the workspace name is derived from the project, environment, and a unique string. ```hcl # organization is inherited from ENV variable TF_CLOUD_ORGANIZATION terraform { cloud { workspaces { - project = "#{Octopus.Project.Name}-#{Octopus.Environment.Name}" - name = "base_layer" + project = "#{Octopus.Project.Name}" + # Workspace names must be unique across an entire HCP Terraform organization + name = "#{Octopus.Project.Name}-base-layer-#{Octopus.Environment.Name}" } } }