Upgrading terraform 0.11.15 when state is stored in S3, can I test upgrade locally somehow?

I am on terraform 0.11.15 and working to upgrade to 1.x now.
My state is stored in a S3 bucket.

Currently I deploy doing the following:

Clear stale modules & remote state, then re-initialize

rm -rf .terraform terraform.tfstate*

terraform init \
    -backend-config="bucket=${S3_BUCKET_KEY}" \
    -backend-config="key=terraform/state"

terraform plan \
    -var="image_tag=\"${GIT_COMMIT}\"" \
    -var-file="${S3_BUCKET_KEY}.tfvars" \
    -out="${S3_BUCKET_KEY}.tfplan"

terraform apply "${S3_BUCKET_KEY}.tfplan"

My question is, can I perform my terraform state upgrade by pulling in the current 0.11.15 state from S3, update it locally and then save it to a different S3 bucket?

If so, what steps should I take to do that?
Does running apply push the updated state file to S3 automatically?

You can either copy the file locally using the aws cli, or you can use the state pull command. Once you have the state stored locally, update the config to use the local state and then you can make whatever changes you need without affecting the original state.

1 Like