尝试在 AWS 存储桶模块上设置对象锁定(无需对象锁定配置即可正常工作)时出现错误:
无效或未知的密钥:object_lock_configuration
错误消息让我想到了语法错误,但看不到它,所以这里是存储桶定义:
resource "aws_s3_bucket" "new_b" {
bucket = "${lower(var.sia)}-${var.bucket_name}-${lower(var.env)}"
acl = "${var.bucket_acl}"
object_lock_configuration {
object_lock_enabled = "${var.locking}"
}
lifecycle_rule {
id = "default"
prefix = ""
enabled = "${var.default_lifecycle}"
expiration {
days = "${var.default_expiry_days}"
}
}
tags {
Name = "${lower(var.sia)}-${var.bucket_name}-${lower(var.env)}"
Sia = "${upper(var.sia)}"
Env = "${upper(var.env)}"
Author = "${var.author}"
}
}
我正在使用以下系统运行它:Terraform v0.11.13 + provider.aws v1.52.0 + provider.template v1.0.0
答案1
设置存储桶的对象锁定配置需要 Terraform AWS 提供程序的 1.56.0 版本。
参见https://github.com/terraform-providers/terraform-provider-aws/issues/6634#issuecomment-454621706