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

S3 Backend Initialisation Error #12971

Closed
npepinpe opened this issue Mar 22, 2017 · 5 comments
Closed

S3 Backend Initialisation Error #12971

npepinpe opened this issue Mar 22, 2017 · 5 comments

Comments

@npepinpe
Copy link

npepinpe commented Mar 22, 2017

Admittedly this is probably very low priority issue, as it only happens if you rerun initialisation in a folder where the backend was already initialised. Not a blocker by any means, but it was definitely unexpected.

NOTE: Obviously the bucket name is not the one I use, and I changed a few paths and so on, but this should be reproducible.

Terraform Version

0.9.1

Affected Resource(s)

S3 backend locking during initialisation.

Terraform Configuration Files

config.tfvars:

region = "eu-west-1"
encrypt = "true"
lock_table = "terraform_locks"
bucket = "terraform-statefiles.sandbox"

main.tf:

terraform {
  required_version = ">= 0.9.0"
  backend "s3" {}
}

Debug Output

Gist

Expected Behavior

It should not have noted any changes to the backend, if I run the command twice in a row with the same configuration. Furthermore, when trying to copy over states with the same names, it should not run into locking issues.

Actual Behavior

On every init run, changes in the backend are detected, even there are no actual configuration changes. Furthermore, when trying to copy over pre-existing state that has the same exact key, it fails to acquire the lock. When replying "no" to copying over pre-existing state, it works just fine.

Steps to Reproduce

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

  1. terraform init -backend-config='key=global.tfstate' -backend-config=config.tfvars
@makered
Copy link

makered commented Mar 22, 2017

Same problem for me with v0.9.1. I dynamically construct the S3 key and since interpolation is not available for backend config, I am passing the key in -backend-config.

However, as mentioned, this option forces a backend change and interactive prompts break our automation.

@jbardin
Copy link
Member

jbardin commented Mar 23, 2017

Hi,

Thanks for reporting the issue. A problem merging "terraform" configuration blocks was recently fixed by #12942 , and will be included in the next release.

I verified the above reproduction case works in master.

@jbardin jbardin closed this as completed Mar 23, 2017
@makered
Copy link

makered commented Mar 29, 2017

Looks like the issue still exists in v0.9.2 for me.

When I run terraform init against a previously applied/saved state:

terraform init -input=false -get=true -backend-config="key=project/env/terraform.tfstate"

I get:

Initializing the backend...
Backend configuration changed!

Terraform has detected that the configuration specified for the backend
has changed. Terraform will now reconfigure for this backend. If you didn't
intend to reconfigure your backend please undo any changes to the "backend"
section in your Terraform configuration.


Do you want to copy the state from "s3"?
  Would you like to copy the state from your prior backend "s3" to the
  newly configured "s3" backend? If you're reconfiguring the same backend,
  answering "yes" or "no" shouldn't make a difference. Please answer exactly
  "yes" or "no".

  Enter a value:

@jas-on
Copy link

jas-on commented May 16, 2017

Deleting .terraform/terraform.tfstate before doing terraform init fixed the issue for me.

@ghost
Copy link

ghost commented Jul 25, 2019

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 Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants