From 2263aa01a384d2bcc1c81ba4542b38efdfb676f3 Mon Sep 17 00:00:00 2001 From: David Sibley Date: Tue, 28 Jan 2025 12:53:50 +0000 Subject: [PATCH] updated docs now that state files are stored natively in S3 rather than through DynamoDB --- source/runbooks/terraform.html.md.erb | 10 ++++------ .../running-terraform-plan-locally.html.md.erb | 16 +--------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/source/runbooks/terraform.html.md.erb b/source/runbooks/terraform.html.md.erb index baf7511de..4a7fd2303 100644 --- a/source/runbooks/terraform.html.md.erb +++ b/source/runbooks/terraform.html.md.erb @@ -54,25 +54,23 @@ $ terraform workspace select core-logging-production $ terraform plan ``` -You will likely get an error if you haven't changed your workspace from `default`. +You will get errors if you haven't changed your workspace from `default`. ### Permissions required for `terraform/environments/` directory in [`modernisation-platform-environments`](https://github.com/ministryofjustice/modernisation-platform-environments) repo You can run `terraform plan` and `terraform apply` in customer directories using credentials for AdministratorAccess SSO role for the terraform workspace you're running against. For example, if you're want to run code in the `terraform/environments/nomis` directory in the `nomis-development` workspace, you will need to retrieve the [AWS SSO credentials](../user-guide/getting-aws-credentials.html) for the `nomis-development` account and paste them into your environment prior to running terraform commands. -After pasting the credentials, use the following steps to run terraform in the `nomis` directory against `nomis-development` account: +After pasting the credentials, use the following steps to run terraform in the `example` directory against `example-development` account: ```bash $ cd terraform/environments/nomis -$ terraform init -backend-config=assume_role={role_arn=\"arn:aws:iam:::role/modernisation-account-terraform-state-member-access\"} +$ terraform init $ terraform workspace list -$ terraform workspace select nomis-development +$ terraform workspace select example-development $ terraform plan $ terraform apply ``` -NOTE, you are required to replace `` with the actual account number of the `modernisation-platform` account in order to run the `terraform init` command. - >If you encounter `Access Denied` error, try running `rm -rf .terraform` and rerun `terraform init` ### Permissions required for each directory in `terraform/` in [`modernisation-platform`](https://github.com/ministryofjustice/modernisation-platform) repo diff --git a/source/user-guide/running-terraform-plan-locally.html.md.erb b/source/user-guide/running-terraform-plan-locally.html.md.erb index d058dbb24..a6367252b 100644 --- a/source/user-guide/running-terraform-plan-locally.html.md.erb +++ b/source/user-guide/running-terraform-plan-locally.html.md.erb @@ -29,24 +29,10 @@ Get your AWS SSO credentials as detailed [here](./getting-aws-credentials.html), Follow the instructions [here](https://learn.hashicorp.com/tutorials/terraform/install-cli) to install the latest version of Terraform according to your platform. -## Retrieve the Modernisation Platform account ID - -You will need the Modernisation Platform account ID to assume the correct role when running `terraform init`. -You can retrieve the Modernisation Platform account ID from the SSM Parameter store via the web console, or via CLI. -This will allow you to assume the correct `role_arn`. - -``` -aws ssm get-parameters --region eu-west-2 \ ---names "modernisation_platform_account_id" --with-decryption --query "Parameters[*].{Value:Value}" --output text -``` - ## Run Terraform plan 1. Navigate to your application infrastructure code - `cd modernisation-platform-environments/terraform/environments/my-application` -2. Run a Terraform init that assumes the backend role in the **Modernisation Platform** account - `terraform init -backend-config=assume_role={role_arn=\"arn:aws:iam::000000000000:role/modernisation-account-terraform-state-member-access\"}` - -> Remember to replace the `000000000000` placeholder with the Modernisation Platform account ID. - +2. Run `terraform init` 3. View the workspaces (you have different workspaces for your different environment accounts) - `terraform workspace list` 4. Select the required workspace - `terraform workspace select my-application-development` 5. Run a Terraform plan - `terraform plan`