0

I am looking to pass in the provider_version into terragrunt.hcl as a variable to make upgrading / setting the version easier. However this is my current code:

terraform {
  backend "s3" {}
  required_version = "~> 0.12"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "${var.aws_provider_version}"
    }
  }
}

I am getting an error

61: version = "${var.aws_provider_version}" Variables may not be used here.

Is there a known workaround or is this not possible?

user7692855
  • 1,582
  • 5
  • 19
  • 39

1 Answers1

2

Terraform doesn't support variables in blocks that are inputs to terraform itself, like provider blocks or lifecycle attributes.

You may be able to use code generation to set up a small providers.tf file before running terraform if you need to update your provider version at build time.

Dan Monego
  • 9,637
  • 6
  • 37
  • 72