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 remote state has to be run twice #9330

Closed
myoung34 opened this issue Oct 11, 2016 · 3 comments
Closed

terraform remote state has to be run twice #9330

myoung34 opened this issue Oct 11, 2016 · 3 comments

Comments

@myoung34
Copy link
Contributor

myoung34 commented Oct 11, 2016

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

0.7.5

Affected Resource(s)

  1. terraform_remote_state

Technically affects all resources

Terraform Configuration Files

  terraform remote config \
    -backend=s3 \
    -backend-config="bucket=${BUCKET}" \
    -backend-config="key=${LOCATION}/terraform.tfstate" \
    -backend-config="region=us-east-1"

Debug Output

https://gist.github.com/myoung34/c2343ed930e25899718c5c14cea7290b

Expected Behavior

Should have succeeded in initializing remote states

Actual Behavior

Failed and bombed out on first initialize. Fixed by running bash init.sh || bash init.sh
Succeeds on second run every time

Steps to Reproduce

  1. Use something like Jenkins EC2 plugin which runs outside of 'userdata'
  2. Run terraform remote config -backend=s3 near immediate start of instance

Important Factoids

Running from Jenkins EC2 slave instance using IAM role. Will fail the first time ever run. All subsequent uses of terraform remote config will succeed.

References

#5839 - see @sjpalf 's comment

@ekulz
Copy link

ekulz commented Nov 17, 2016

This is also happening to me. Remote state would pull down fine but on apply it kept giving 403 errors. My steps were (using a python wrapper):

terraform.py remote
terraform.py get
terraform.py plan
terraform.py apply

Once I added another remote step in between plan and apply it worked perfect? On version 0.7.7

Nevermind, all looks ok now. Think it was a glitch when copying my state file to a server side encryption required S3 bucket. Ever since adding that second remote step and performing a proper apply, I have been able to remove the second remote step and everything runs fine.

@apparentlymart
Copy link
Contributor

Hi @myoung34 and @lhickin! Sorry for the issues here and sorry we let this issue languish.

The remote system was completely redesigned for 0.9, so the workflow this issue is discussing is no longer present. Given how much the relevant parts of Terraform have changed since 0.7.5 I'm going to close this. If anyone is seeing similar issues in 0.9 or above I suggest opening a fresh issue so that we can triage and address it separately. Thanks for opening this issue!

@ghost
Copy link

ghost commented Apr 14, 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 14, 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

4 participants