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

-force flag on terraform remote push does not work #5663

Closed
dansteen opened this Issue Mar 16, 2016 · 11 comments

Comments

Projects
None yet
9 participants
@dansteen
Copy link

dansteen commented Mar 16, 2016

Hey,

I have an issue where I am attempting to push my local state over the remote state using the command:

# terraform remote push -force                                          

results in the error

Failed to read state: Unknown refresh result: Local and remote state conflict, manual resolution required

Shouldn't the "-force" overwrite the remote anyway, or am I not understanding something?

I am on v0.6.13

Thanks!

@dansteen

This comment has been minimized.

Copy link

dansteen commented Mar 16, 2016

One additional note is that I first did a

terraform remote config -backend=S3 -backend-config="bucket=xxxxxx" -backend-config="key=terraform.tfstate" -backend-config="region=us-east-1" -pull=false

(notice the "-pull=false" on the end. This was an attempt to fix up an issue)

@phinze phinze added bug core labels Mar 16, 2016

@phinze

This comment has been minimized.

Copy link
Member

phinze commented Mar 16, 2016

Thanks for the report, @dansteen it does indeed look like the -force flag is not working as intended here!

The workaround in the meantime is to manually bump the serial number in your local state cache (.terraform/terraform.tfstate) to exceed the number held remotely. Then terraform remote push should succeed.

@dansteen

This comment has been minimized.

Copy link

dansteen commented Mar 16, 2016

thanks!

@brikis98

This comment has been minimized.

Copy link
Contributor

brikis98 commented Apr 29, 2016

Hitting a frustrating issue with the -force flag as well. I have some state in an S3 bucket that is old. Like @dansteen, I did a terraform remote config with a -pull=false. I then tried a terraform push -force to overwrite the old state. However, instead, the old state gets merged into my current state, which messes things up. I'll try the serial number fix to see if that helps.

@brikis98

This comment has been minimized.

Copy link
Contributor

brikis98 commented Apr 29, 2016

Update: looks like bumping the version number in the .terraform/terraform.tfstate file did the trick. Thanks for the workaround.

@ti-mo

This comment has been minimized.

Copy link

ti-mo commented May 17, 2016

@phinze Also ran into this, thanks for the workaround.

@iroller

This comment has been minimized.

Copy link
Contributor

iroller commented Sep 20, 2016

It's terraform 0.7.3 and the issue is still there.

@sheeley

This comment has been minimized.

Copy link

sheeley commented Sep 22, 2016

For anyone else that happens upon this, it's serial that needs to be bumped, not version

@eherot

This comment has been minimized.

Copy link

eherot commented Mar 2, 2017

I haven't tried it out myself but this appears to have been significantly reworked in master. I wouldn't be surprised if it's been fixed by some of those changes.

@artburkart

This comment has been minimized.

Copy link

artburkart commented Mar 31, 2017

If bumping the serial number is how one confirms this bug still exists, then I can confirm it is still there as of 0.8.8.

@apparentlymart

This comment has been minimized.

Copy link
Contributor

apparentlymart commented Apr 5, 2017

Hi all! Sorry for this issue and sorry for letting it sit here for so long.

In Terraform 0.9 we significantly redesigned the remote state system, eliminating the local cache of state and along with it the terraform remote push command. Therefore the code that was causing this bug no longer exists: Terraform just immediately writes state to the backend, skipping the local/remote syncing that used to happen.

Therefore I'm going to close this issue. If anyone still has issues with remote state, I recommend to open a fresh new issue for it since the relevant parts of Terraform have changed a lot since v0.6.3 (and v0.8.8, for that matter) so any new issues are likely to have a different root-cause and need fresh investigation. Thanks everyone for the discussion here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment