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

provide script or instruction for utilizing s3 versioned bucket for rolling back state #2

Open
stavxyz opened this issue Jul 7, 2018 · 0 comments

Comments

@stavxyz
Copy link
Owner

stavxyz commented Jul 7, 2018

Since this module ensures that terraform users provision a versioned bucket for state, it should also provide instructions for why that is useful and how to roll back in case of disasters.

wip

  1. List state bucket versions:
aws s3api list-object-versions --bucket terraform-state-bucket | jq '.Versions|sort_by(.LastModified)'
  1. Get the version you want ( revert.tfstate is used as the <outfile> arg )

TODO: How can a user determine which version they want? Previewing state by pulling an object version and pointing terraform show at it? That's the only way I can think of. Sounds like this is going to turn into a weird side project/tool.

aws s3api get-object --bucket terraform-state-bucket --version-id ZZZZZZ ... revert.tfstate
  1. Check out the content type (probably application/json ) and metadata (if any)
aws s3api head-object --version-id ZZZZZZ --bucket terraform-state-bucket --key terraform.tfstate
  1. Copy previous object version
aws s3 cp revert.tfstate s3://terraform-state-bucket/revert.tfstate
  1. Set as current version:
aws s3 cp s3://terraform-state-bucket/revert.tfstate s3://terraform-state-bucket/terraform.tfstate
@stavxyz stavxyz changed the title provide script or instruction for leveraging s3 versioned bucket for rolling back state provide script or instruction for utilizing s3 versioned bucket for rolling back state Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant