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
- Navigate to your application infrastructure code -
cd modernisation-platform-environments/terraform/environments/my-application
- Run
terraform init
- View the workspaces (you have different workspaces for your different environment accounts) -
terraform workspace list
- Select the required workspace -
terraform workspace select my-application-development
- 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.