I would want to provision multiple envs which are the same apart from the name of the resources to not collide with each other. In terraform I use workspaces to achive that, this seems not to be supported by terragrunt. The envs are dynamically created by developers if they need one.
Handling the use case you’re describing is a core feature of Terragrunt. In your case each new environment would be a directory and you can use Terragrunt methods such as get_terragrunt_dir(), etc to achieve your desired differentiation by resource naming amongst otherwise identical environments.
I was aware of that but did not want to copy folders. I found a solution for me that works in the same folder, I am not sure if it’s a good solution but it works.
in the parent terragrunt.hcl:
remote_state {
backend = "gcs"
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
config = {
bucket = get_env("TERRAFORM_STATE_BUCKET")
prefix = "terraform/${basename(get_parent_terragrunt_dir())}/instances/${get_env("ENV")}/${path_relative_to_include()}/"
}
}
terraform {
// this is done to allow changing the bucket state path without any init commands
extra_arguments "init_args" {
commands = [
"init"
]
arguments = [
"-reconfigure",
]
}
}
This leads to different environments everytime I change the ENV variable. Every user can now export his env name and it works fine for me. I also use the ENV variable to name resources.