Skip to main content

Running Terraform Plan Locally

Whilst it is possible to see the results of a Terraform plan when you create a pull request, it is also possible to run a Terraform plan locally. Some engineers prefer this as it provides a quicker feedback loop to identify any issues with your infrastructure code.

Enter your AWS SSO credentials

Get your AWS SSO credentials as detailed here, choose option 1 and paste the credentials into the terminal window you are working from.

Please note that the credentials will expire after a period of 1 hour.

Install Terraform

Follow the instructions here to install the latest version of Terraform according to your platform.

Run Terraform plan

  1. Navigate to your application infrastructure code - cd modernisation-platform-environments/terraform/environments/my-application
  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

Running a plan locally has read only permissions, you will not be able to run an apply, destroy or import. The example syntax for assuming a backend role is appropriate for Terraform 1.6.0 onwards.

This page was last reviewed on 13 December 2024. It needs to be reviewed again on 13 June 2025 by the page owner #modernisation-platform .
This page was set to be reviewed before 13 June 2025 by the page owner #modernisation-platform. This might mean the content is out of date.