问题描述
在这个文件 https://github.com/wentao-daommo/aws-local/blob/master/local.tf 中,我正在使用 localstack 设置一个 aws_s3_bucket。我第一次运行 terraform apply
时,它成功地为我创建了一个存储桶。
但是,如果我在不更改 tf 文件的情况下再次运行 terraform apply
或 terraform plan
,它会开始应用我没有放入 tf 文件中的新更改,类似这样>
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.
如果我继续改变,会发生什么
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:
我对这种行为感到非常困惑。我假设在同一个 tf 文件上运行 terraform plan/apply
不应触发任何更改。我错过了什么吗?
解决方法
基于评论。
该问题是由使用0.10.5
的非常旧的版本 (localstack
) 引起的。当前版本为 0.12.5
。
升级 localstack
到正确的版本解决了问题。