Wentao Zheng
Wentao Zheng

Reputation: 25

Executing `terraform apply` on the same aws_s3_bucket resource twice have different results

In this file https://github.com/wentao-daommo/aws-local/blob/master/local.tf I'm setting up a aws_s3_bucket with localstack. The first time I run terraform apply it successfully created a bucket for me.

However, if I go run terraform apply or terraform plan again without change the tf file, it started to apply new changes that I didn't put in my tf file, with something like this

Terraform will perform the following actions:

  # aws_s3_bucket.b will be updated in-place
  ~ resource "aws_s3_bucket" "b" {
        id                          = "local-bucket"
        tags                        = {}
        # (8 unchanged attributes hidden)

      - object_lock_configuration {
        }

      - replication_configuration {
        }

      - server_side_encryption_configuration {
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

If I proceed with change, what will happen is

aws_s3_bucket.b: Refreshing state... [id=local-bucket]
aws_s3_bucket.b: Modifying... [id=local-bucket]

Error: error removing S3 bucket server side encryption: NoSuchBucket: The specified bucket does not exist
    status code: 404, request id: , host id: 

I'm very confused about this behavior. I'm assuming running terraform plan/apply on the same tf file shouldn't trigger any changes. Am I missing anything?

Upvotes: 1

Views: 1872

Answers (1)

Marcin
Marcin

Reputation: 238299

Based on the comments.

The issue was caused by using very old version (0.10.5) of localstack. The current version is 0.12.5.

Upgrading localstack to the correct version resolved the issue.

Upvotes: 1

Related Questions