Terraform is forcing replacement EBS resource

My terraform code and the infrastructure deployed in AWS match. However, when performing terraform plan to apply other changes, terraform is flagging an existing EBS Volume to be replaced, and because of that, its EC2 instance.

# module.database.aws_ebs_volume.master_db_data_prod[0] must be replaced
-/+ resource "aws_ebs_volume" "master_db_data_prod" {
      ~ arn                  = "arn:aws:ec2:ap-southeast-2:XXXXXX:volume/vol-035df09a05f15d173" -> (known after apply)
      ~ availability_zone    = "ap-southeast-2c" -> (known after apply) # forces replacement
      ~ id                   = "vol-035df09a05f15d173" -> (known after apply)
      ~ iops                 = 3000 -> (known after apply)
      - multi_attach_enabled = false -> null
      + snapshot_id          = (known after apply)
        tags                 = {
            "Environment" = "prod"
            "Name"        = "pgsql-master-prod-data-volume"
            "Terraform"   = "True"
        }
      ~ throughput           = 125 -> (known after apply)
        # (5 unchanged attributes hidden)
    }

I have already run terraform refresh, but it didn’t help.

Do you guys have any suggestions, please?

Edit:

Terraform resource code:

resource "aws_ebs_volume" "master_db_data_prod" {
  count             = (terraform.workspace == "prod") ? 1 : 0
  availability_zone = aws_instance.masterdb[count.index].availability_zone
  size              = 1024
  type              = "gp3"
  encrypted         = true
  kms_key_id        = aws_kms_key.database_ebs_volumes.arn

  tags = {
    Name        = "pgsql-master-${terraform.workspace}-data-volume"
    Environment = local.workspace["environment"]
    Terraform   = "True"
  }
}

resource "aws_volume_attachment" "ebs_att_data" {
  count       = (terraform.workspace == "prod") ? 1 : 0
  device_name = "/dev/sdg"
  volume_id   = aws_ebs_volume.master_db_data_prod[count.index].id
  instance_id = aws_instance.masterdb[count.index].id
}

Hmm… I came across this post. This workaround solved this problem for me:

lifecycle {
    ignore_changes = [ availability_zone ]
  }

The instance will never change its AZ, so it works for me.