atlantis: Specified terraform version (using required_version) not used when required_providers is specified

I have a project that I just upgraded to terraform 0.13, and that on it’s own worked fine. I then attempted to use the new syntax for specifying a provider version, and that seems to cause atlantis to be unable to parse the required_version specified in the terraform. For example, with this configuration plans are successful:

terraform {
  required_version = "0.13.0"

  backend "s3" {
    region         = "us-west-2"
    bucket         = "<redacted>"
    key            = "<redacted>"
    dynamodb_table = "<redacted>"
  }
}

But with this configuration:

terraform {
  required_version = "0.13.0"

  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "~> 3"
    }
  }

  backend "s3" {
    region         = "us-west-2"
    bucket         = "<redacted>"
    key            = "<redacted>"
    dynamodb_table = "<redacted>"
  }
}

The plan fails with


Warning: Provider source not supported in Terraform v0.12

  on main.tf line 5, in terraform:
   5:     aws = {
   6:       source = "hashicorp/aws"
   7:       version = "~> 3"
   8:     }

A source was declared for provider aws. Terraform v0.12 does not support the
provider source attribute. It will be ignored.


Error: Unsupported Terraform Core version

This configuration does not support Terraform version 0.12.27. To proceed,
either choose another supported Terraform version or update the root module's
version constraint. Version constraints are normally set for good reason, so
updating the constraint may lead to other errors or unexpected behavior.

It seems specifying the provider info breaks required_version = "0.13.0".

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I wanted to report that this still doesnt work in the latest helm chart.

terraform {
  required_version = "0.13.5"
  backend "s3" {
    bucket         = "terraform-tfstate-us-east-1"
    encrypt        = "true"
    key            = "ops/restricted" # Change as needed
    dynamodb_table = "terraform_locks_us-east-1"
    region         = "us-east-1"
  }
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.19.0"
      region  = "us-east-1"
    }
  }
}

Results in

Error: Unsupported Terraform Core version

  on providers.tf line 2, in terraform:
   2:   required_version = "0.13.5"

This configuration does not support Terraform version 0.13.3. To proceed,
either choose another supported Terraform version or update this version
constraint. Version constraints are normally set for good reason, so updating
the constraint may lead to other errors or unexpected behavior.

We are specifying defaultTFVersion: 0.13.3 chart, and then attempting to upgrade section by section to 0.13.5, then we would bump up the default version.

Looked at the source code and answered my own question. It does not, for reasons that are unclear to me. Filed #1217.

@llamahunter if you have a moment can you please make note of where in the source you found the constraint to make it easier for someone to pick up?

PRs welcome! Can someone dig into this?

I’m seeing this error message in the logs:

2020/08/17 03:42:43+0000 [EROR] project_command_builder.go:450 [censored]#79: Trying to detect required version: Unsuitable value type: Unsuitable value: string required