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

terraform init -backend-config does not work with with variables #12875

Closed
skarum opened this issue Mar 20, 2017 · 6 comments
Closed

terraform init -backend-config does not work with with variables #12875

skarum opened this issue Mar 20, 2017 · 6 comments

Comments

@skarum
Copy link

skarum commented Mar 20, 2017

Terraform Version

Terraform v0.9.0

Affected Resource(s)

Not a problem with a resource, but with terraform itself.

  • terraform init

Terraform Configuration Files

terraform {
  backend "s3" {
    bucket = "my-s3-state-bucket"
  }
}

Debug Output

terraform init -backend-config 'region=eu-west-1' returns this:

Output:

InitiEarlriozri nlgo atdhien gb abcakceknedn.d. .co
nfig: Error loading extra configuration file for backend: open region='eu-west-1': The system cannot find the file specified.

https://gist.github.com/skarum/42e024fa05262fadd6c857c58c129c3d

Expected Behavior

Terraform should use the variable specified in the ìnit`command and use region = 'eu-west-1' for the backend.

Actual Behavior

Terraform tries to load the variable as it was a file.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create backend in ´backend.tf´

    terraform {
      backend "s3" {
        bucket = "my-bucket"
        key = "my-key"
      }
    }
  2. terraform init -backend-config 'region=eu-west-1'

Important Factoids

If I create a file with the variable and points -backend-config at it, it works as expected:

File content:

region="eu-west-1"

terraform init -backend-config './path/to/file'

@chrisrlong
Copy link

I think i have a similar issue:

When using the .tf file:

terraform {
  backend "s3" {
    bucket = "foo-bar-terraform"
    key    = "foo/bar.tfstate"
    region = "eu-west-1"
    profile = "foo"
  }
}

This finishes as expected and a plan states:
"No changes. Infrastructure is up-to-date." Which is correct.

If I try and run via CLI:

terraform init -backend-config "bucket=foo-bar-terraform" -backend-config "key=foo/bar.tfstate" -backend-config "profile=foo" -backend-config "region=eu-west-1"

Everything reports success except the plan reports:
"Plan: 7 to add, 0 to change, 0 to destroy."
Which is wrong.... I do think the state file is processed.

@mitchellh
Copy link
Contributor

Hey @skarum, support for K/V values was added in 0.9.1!

@jangrewe
Copy link

@mitchellh This is a bit of a pickle now: We can't update to 0.9.1 because of #12892 , and we can't use 0.9.0 because of this issue right here. Any chance for a quick fix for #12892 ?

@grubernaut
Copy link
Contributor

@jangrewe we're working internally on #12892, and should have a solution coming soon. Thanks.

@jangrewe
Copy link

Thanks @grubernaut, that info keeps me from rolling everything back ;-)

@ghost
Copy link

ghost commented Apr 15, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants