I have 2 different environment that i am trying to configure statefile for(Prod and Dev)I want terragrunt to create s3 bucket for state file for me with different bucket names(one for prod and dev).I have terragrunt.hcl in the root of my repository and child terragrunt.hcl in each of prod and dev.I would like to be able to configure terragrunt to use different bucket names for each environment but i am having some trouble getting that done.the code i have right now i believe will do that but i would like to know if anyone has simple way to have terragrunt create different bucket name in 2 different environments.I have copied sample of my code here to if anyone can see and suggest an easier way to get it done.
this is my root terragrunt
locals {
team = “dev”
environment = “test-gitaction”
aws_region = “us-east-1”
overrides_path = “${get_terragrunt_dir()}/overrides.yaml”
overrides = yamldecode(fileexists(local.overrides_path) ? file(local.overrides_path) : “{}”)
overridden = fileexists(local.overrides_path) ? merge(local.overrides.base_s3) : {}
}
remote_state {
backend = “s3”
generate = {
path = “backend.tf”
if_exists = “overwrite”
}
config = {
bucket = fileexists(local.overrides_path) ? lower(format("%s-tfstate", join("-", values(local.overridden)))) : join("-", [ lower(local.team),lower(local.environment),lower(local.aws_region), “tfstate”, ])
key = “${path_relative_to_include()}/terraform.tfstate”
region = “us-east-1”
encrypt = true
dynamodb_table = “gitactionlock-table”
}
}
each of my child terragrunt consist of this:
include {
path = find_in_parent_folders()
}
and my Override.yaml consist of:
base_s3:
team = “prod”
environment = “prod-githubaction143”
aws_region = “us-east-1”
please any suggestion of easier way to achieve the same thing