terraform-aws-tfstate-backend icon indicating copy to clipboard operation
terraform-aws-tfstate-backend copied to clipboard

Upgrading from <0.33.1 to >=0.33.1 requires state move for bucket

Open ScottMillard opened this issue 3 years ago • 1 comments

Describe the Bug

When upgrading from before version 0.33.1 to any version after 0.33.1: count was added to the default bucket so a plan sees that the bucket does not exist and wants to remove it from state.

No where in the release notes or README does it mention needing to do a state move. Once you move the state to add an index a plan will show no changes needed: terraform state mv module.tfstate-backend.aws_s3_bucket.default module.tfstate-backend.aws_s3_bucket.default[0]

Expected Behavior

A note in the 0.33.1 release about needing to perform the state move.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Init a terraform project with terraform-aws-tfstate-backend version 0.33.0
  2. Run terraform apply
  3. Change the terraform-aws-tfstate-backend to version 0.33.1
  4. Run terraform plan
  5. See error

Screenshots

N/A

Environment (please complete the following information):

Terraform v1.0.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.56.0

Additional Context

Add any other context about the problem here.

ScottMillard avatar Feb 02 '22 22:02 ScottMillard

I thought newer versions of terraform correct for count logic added or subtracted from components as long as the count is either 1 or 0. Perhaps it is for a terraform version greater than 1.0.5?

nitrocode avatar Jun 23 '22 21:06 nitrocode

Closing as fixed in Terraform v1.1. See note in Terraform documentation:

When you add count to an existing resource that didn't use it, Terraform automatically proposes to move the original object to instance zero, unless you write an moved block explicitly mentioning that resource.

Nuru avatar Apr 23 '23 20:04 Nuru