Terraform plan wants to recreate all of my infrastructure

This was posted on github but closed for being a question.
I think it might also be a bug, but can’t say for sure now.

Terraform Version

Terraform v1.4.6
on linux_amd64

Terraform Configuration Files


terraform {
  required_providers {
    random = {
      source  = "hashicorp/random"
      version = "3.5.1"
    }
    aws = {
      source  = "hashicorp/aws"
      version = "4.24"
    }
  }
  required_version = "~> 1.0"
}

provider "aws" {
  region = "us-west-1"
}

resource "aws_ebs_volume" "dev_db" {
  availability_zone = aws_instance.dev["1"].availability_zone
  type              = "gp3"
  throughput        = 250
  iops              = 8000
  size              = 1100
  # Create a snapshot before deleting this volume
  final_snapshot = true
  multi_attach_enabled = false
  encrypted = false

  tags = {
    Name           = "dev1_data"
    DreEnvironment = "dev"
    Backup         = true
  }
}

Debug Output

  # aws_ebs_volume.dev_db must be replaced
-/+ resource "aws_ebs_volume" "dev_db" {
      ~ arn                  = "REDACTED" -> (known after apply)
      ~ availability_zone    = "us-west-1b" # forces replacement -> (known after apply) # forces replacement
      + final_snapshot       = true
      ~ id                   = "REDACTED" -> (known after apply)
      + kms_key_id           = (known after apply)
      + snapshot_id          = (known after apply)
        tags                 = {
            "Backup"         = "true"
            "DreEnvironment" = "dev"
            "Name"           = "dev1_data"
        }
        # (7 unchanged attributes hidden)

      - timeouts {}
    }

....
Plan: 33 to add, 17 to change, 33 to destroy.

Expected Behavior

I would expect the plan to not require any changes.

Actual Behavior

I did not change the state.
I ran terraform plan today successfully using terraform 1.4.2.
I upgraded terraform to 1.4.6.
I upgraded aws plugin from 4.24 → latest - 4.67 .
I only upgraded random plugin as well.

I ran terraform plan - and it asks me to destroy and create all my infrastructure.
Why?

Steps to Reproduce

terraform init
terraform plan

Additional Context

I’m using local state and the only one using terraform.
I was preparing to use remote state.

Now I don’t know. This failure is unexpected and not sure how to fix it.
It’s very concerning.

References

No response

Running plan with -refresh-only does not mention any changes.

terraform plan -refresh-only

No changes. Your infrastructure still matches the configuration.

Terraform has checked that the real remote objects still match the result of your most recent changes, and found no differences.

So I tracked this down to the ami id of the server changing (I used an AMI datasource with a filter, the AMI id was dynamic).