Open yordis opened 1 year ago
I'm not sure this is entirely the same as my use case, but if it is, I solved is using override files. Each of my providers looks something like this:
generate "aws_provider" {
path = "_aws_provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
provider "aws" {
...
}
EOF
}
generate "aws_provider_required_providers" {
path = "_aws_provider_override.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.32"
}
}
}
EOF
}
Meanwhile, my backend.hcl looks like this, and it's this that defines terraform required_version:
generate "backend" {
path = "_backend.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
terraform {
required_version = ">= 1.2.9"
backend "s3" {
bucket = "my-tf-bucket"
key = "${lower(trimprefix(path_relative_to_include(), "../"))}.tfstate"
region = "eu-west-1"
dynamodb_table = "my-state-lock"
}
}
EOF
}
@simonholt I am not sure if that were the same use case. You would need more than one terraform.required_providers
block code to be generated.
Being said, I may be wrong!
@denis256 do you know which files I could visit to dig into how to add this feature?
I have the following file system structure
I need to be able to configure the
terraform
block at multiple levels. Ideally, setting upterraform.required_version
is always the same for all of them; but the difficulty comes with setting upterraform.required_providers
because it depends on the project.Maybe have something similar to
remote_state
but for theterraform
block.Example:
Merging all those configs would be an ideal, or a similar experience.