I’m looking for a way to tell terragrunt that is ran from terragrunt-workspace/aws to use a specific AWS_PROFILE for each account but so far I came up empty.
So your region attribute in the remote_state needs to refer to a var:
region = var.region
Then you need to set that var in your “terragrunt-workspace/aws//terragrunt.hcl”.
I would do that either by:
Clean but more files: create a “region.hcl” config file inside each region folder with the following locals:
locals{
region = "eu-west-1"
}
Then inside your “root” terragrunt.hcl (terragrunt-workspace/aws//terragrunt.hcl) you load and use that var:
locals{
region_vars = read_terragrunt_config("region.hcl")
region = local.region_vars.locals.region
}
Extract it from the path (not tested):
locals{
// Extracting “eu-west-X” from the path by cutting on ‘/’
path_array = path_relative_to_include().split(‘/’)
region = element(path_array, length(path_array)-1)
}
What Luigi_Bakker said is the right approach here. You basically need to load in the data you need by taking advantage of the folder structure. The one thing I will add is that you can use find_in_parent_folder to load the data file in the parent config.