Search code examples
amazon-web-servicesmoduleterraformversionterraform-provider-aws

How to make terraform's version immutable with atlantis?


I use Atlantis to run Terraform's task.

In a terraform file, I'm setting AWS provider as this version:

terraform {
  required_version = "0.13.5"

  required_providers {
    aws = "3.13.0"
  }
}

This is in one of multiple tasks. Other task like

terraform {
  required_version = "0.14.9"

  required_providers {
    aws = "3.35.0"
  }
}

Atlantis' workflow setting as

dir: myproj/dev workspace: default

After some days, the Atlantis server checks for new tasks caused the version issue when run terraform init:

Initializing provider plugins...
- Finding hashicorp/aws versions matching "3.13.0, >= 2.68.*, >= 2.42.*, >= 3.28.*, >= 2.68.*, >= 2.49.*, >= 2.49.*"...
- Finding hashicorp/random versions matching "3.1.0, >= 3.1.*, >= 2.2.*"...
- Using hashicorp/random v3.1.0 from the shared cache directory

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws:
no available releases match the given constraints 3.13.0, >= 2.68.*, >= 2.42.*, >= 3.28.*, >= 2.68.*, >= 2.49.*, >= 2.49.*

Should I always update the new version for aws module manually? Is there any way if don't upgrade 3.13.0 version to the newest?


Solution

  • You should configure the terraform version in atlantis.yaml

    Exemple:

    version: 3
    projects:
      - name: my-project-1
        dir: ./my-project-1
        terraform_version: "0.13.5"
      - name: my-project-2
        dir: ./my-project-2
        terraform_version: "0.14.9"