Provision multiple envs with the same config


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.

What is the best way to do that using terragrunt?

Thank you for any good ideas :slight_smile:

Hi sadoMadupilami,

Did you have a look at the Keep Your Terraform Code DRY page in the Terragrunt documentation?

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.

Hope this is helpful!

Hi Zack,

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      = ""
    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 = [
    arguments = [

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.