我正在尝试使用Terraform使用复制配置s3存储桶。我收到以下错误。
Error: insufficient items for attribute "destination"; must have at least 1
on main.tf line 114, in resource "aws_s3_bucket" "ps-db-backups":
114: lifecycle_rule {
我不明白此错误消息。首先在replication
部分中定义了destination
。其次,错误消息中提到lifecycle_rule
,它没有
destination
属性。存储桶定义如下。
resource "aws_s3_bucket" "ps-db-backups" {
bucket = "ps-db-backups-b3bd1643-8cbf-4927-a64a-f0cf9b58dfab"
acl = "private"
region = "eu-west-1"
versioning {
enabled = true
}
lifecycle_rule {
id = "transition"
enabled = true
transition {
days = 30
storage_class = "STANDARD_IA"
}
expiration {
days = 180
}
}
replication_configuration {
role = "${aws_iam_role.ps-db-backups-replication.arn}"
rules {
id = "ps-db-backups-replication"
status = "Enabled"
destination {
bucket = "${aws_s3_bucket.ps-db-backups-replica.arn}"
storage_class = "STANDARD_IA"
}
}
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
答案 0 :(得分:0)
仔细检查地形docs。
您需要像这样为destination
创建一个单独的Terraform资源:
resource "aws_s3_bucket" "destination" {
bucket = "tf-test-bucket-destination-12345"
region = "eu-west-1"
versioning {
enabled = true
}
}
然后在您的replication_configuration
中将其引用为
destination {
bucket = "${aws_s3_bucket.destination.arn}"
storage_class = "STANDARD"
}
我希望这会有所帮助。尝试让我知道。
答案 1 :(得分:0)
这似乎是Terraform 0.12中的错误。 看到这个问题https://github.com/terraform-providers/terraform-provider-aws/issues/9048
答案 2 :(得分:0)
作为旁注,如果您还需要启用对S3复制的监视,则将无法执行此操作。 Terraform尚未实现。
但是为此打开了一个PR,请以竖起大拇指投票,https://github.com/terraform-providers/terraform-provider-aws/pull/11337