atlantis: policy checks and terraform version inconsistent behavior

We currently set which version of terraform to use inside of the terraform block per project like so:

terraform {
  required_version = "0.13.5"
}

When implementing policy checks we got some unreadable errors that we eventually figured out is because the default version of terraform is 0.12.12.

We didn’t want to go through a docker deployment so I set the terraform_version in atlantis.yaml for my project/workspaces. I first tested it to v0.15.1 since I saw that is the latest. However, no plans ran because the required version was 0.13.5 and therefore no policy checks ran as it needs the plan file.

So my take on it is this. When the project has nothing set terraform 0.12.12 plans but knows to upgrade to 0.13.5 for the plan. The terraform show however is just reading a plan file.

Is there any way to read the terraform block or perhaps the plan file has the version that made the plan?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Actually nwm, I was able to reproduce the issue. I will mark it as a bug.

To repro:

  1. Setup atlantis for development following instructions.
  2. Set the default terraform version to anything >0.13 and enable policy checking.
  3. Create a new project in you target repository with main.tf containing -
terraform {
  required_version = "0.13.5"
}
  1. Create a PR and see policy checking fail.

I just want to add that I am encountering the same error even though the Terraform version used for the plan and show is the same. I have also tried updating the default TF version on atlantis.

running terraform show: running "/root/.atlantis/bin/terraform0.13.5 show -no-color -json /root/.atlantis/repos/foo/foo-infrastructure/1493/default/terraform/aws/s3/opa-test-bucket/default.tfplan" in "/root/.atlantis/repos/foo/foo-infrastructure/1493/default/terraform/aws/s3/opa-test-bucket": exit status 1

@uLan08 I needed to hop on the container and manually run terraform show as the atlantis user in order to see the actual error message. If your versions are the same and you got no errors during the plan phase it would seem like a different issue.