aws_s3_bucket_lifecycle_configuration的等效"lifecycle_configuration=prevent_destroy"是多少?



我正在尝试阻止bucket在terraform中的删除。桶保存着我的地形远程状态文件。到处都说用lifecycle_configuration=prevent_destroy。地形文档说要使用新的参数aws_s3_bucket_lifecycle_configuration。我的设置是这样的:

# Prevent deletion
resource "aws_s3_bucket_lifecycle_configuration" "tf_remote_state_s3_lifecycle_config" {
bucket = aws_s3_bucket.tf_remote_state.id
rule {
id     = "prevent_destroy"
status = "Enabled"
}

}

我得到这个错误:

╷
│ Error: error creating S3 Lifecycle Configuration for bucket (XXXX): InvalidRequest: At least one action needs to be specified in a rule
│       status code: 400, request id: XXXX, host id: XXXX
│ 
│   with aws_s3_bucket_lifecycle_configuration.tf_remote_state_s3_lifecycle_config,
│   on main.tf line 34, in resource "aws_s3_bucket_lifecycle_configuration" "tf_remote_state_s3_lifecycle_config":
│   34: resource "aws_s3_bucket_lifecycle_configuration" "tf_remote_state_s3_lifecycle_config" {
│ 
╵

aws_s3_bucket_lifecycle_configurationlifecycle_configuration=prevent_destroy的等价物是什么?

您混淆了terraform的lifecycle配置和控制bucket中对象生命周期的S3功能aws_s3_bucket_lifecycle_configuration/lifecycle_rule。这两者完全没有关系,也完全没有关系。

解决方案:在aws_s3_bucket上坚持使用lifecycle { prevent_destroy = true },不要使用aws_s3_bucket_lifecycle_configuration

https://www.terraform.io/language/meta-arguments/lifecycle
https://registry.terraform.io/providers/hashicorp%20%20/aws/latest/docs/resources/s3_bucket_lifecycle_configuration

是的,@luk2302是正确的,是的@j7skov也是棘手的。

一边写着已弃用,另一边写着使用"aws_s3_bucket_lifecycle_configuration">

相关内容

  • 没有找到相关文章

最新更新