Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote backend config from multiple backend.conf files #263

Closed
sevagh opened this issue Aug 7, 2017 · 5 comments
Closed

Remote backend config from multiple backend.conf files #263

sevagh opened this issue Aug 7, 2017 · 5 comments
Labels

Comments

@sevagh
Copy link

sevagh commented Aug 7, 2017

Hello,

I have a bunch of Terraform configs structured something like this:

├── backend.conf (shared)
├── cluster-1
│   ├── backend.conf
│   ├── terraform.tfvars
└── cluster-2
    ├── backend.conf
    ├── terraform.tfvars

I initialize each of these with terraform init --backend-config=./backend.conf --backend-config=../backend.conf. The root backend.conf contains the meat of it (s3 bucket name, DynamoDB lock table name), and the sub-files have different key values to distinguish the stacks.

Is there any way this translates to Terragrunt?

I.e.:

terragrunt = {
  remote_state {
    backend = "s3"
    config { "${get_tfvars_dir()}/../backend.conf" }
    config { "backend.conf" }
  }
}

(this doesn't work, just a contrived example)

I also tried:

extra_arguments "custom_vars" {
      commands = [
        "init",
      ]

      arguments = [
        "-backend-config=${get_tfvars_dir()}/../backend.conf",
        "-backend-config=backend.conf"
      ]
    }

This didn't help me either.

Any suggestions?

Thanks

@sevagh sevagh changed the title Remote config from multiple backend.conf files Remote backend config from multiple backend.conf files Aug 7, 2017
@sevagh
Copy link
Author

sevagh commented Aug 7, 2017

I'm reading through this now which seems relevant: #26

@brikis98
Copy link
Member

brikis98 commented Aug 7, 2017

The support for passing files to -backend-config is fairly new to Terraform and not yet supported by Terragrunt. In fact, there are a bunch of changes that came out with Terraform 0.10.0 that we are trying to figure out how to support in Terragrunt. See #261 for the discussion.

@sevagh
Copy link
Author

sevagh commented Aug 10, 2017

Thanks for the update. Meanwhile is there a reason this doesn't work?

extra_arguments "custom_vars" {
      commands = [
        "init",
      ]

      arguments = [
        "-backend-config=${get_tfvars_dir()}/../backend.conf",
        "-backend-config=backend.conf"
      ]
    }

If extra_arguments were applied to terraform init (and I'm not sure why it's not being applied - is init a special case? is it a bug?) it's still a compelling reason for our organization to use Terragrunt and avoid typing terraform init -backend-config=../backend.conf -backend-config=../../backend.conf each time.

@brikis98
Copy link
Member

Since Terragrunt calls init for you, it doesn't currently let you call it yourself. Changing this behavior is what we're discussing in #261.

@sevagh
Copy link
Author

sevagh commented Oct 25, 2017

I think I can close this now. Feel free to re-open if it's still relevant.

@sevagh sevagh closed this as completed Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants