什么是等效的“ lifecycle_configuration = destress_destroy”对于aws_s3_bucket_lifecycle_configuration?
我正在努力防止在Terraform中删除水桶的删除。水桶容纳我的Terraform远程状态文件。到处都说要使用lifecycle_configuration = destres_destroy
。 Terraform文档说使用新参数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" {
│
╵
lifecycle_configuration = destrape_destroy
in aws_s3_s3_bucket_lifecycle_configuration
等于什么?
I'm trying to prevent a bucket's deletion in terraform. The bucket holds my terraform remote state files. Everywhere says to use lifecycle_configuration=prevent_destroy
. The terraform docs say to use the new parameter aws_s3_bucket_lifecycle_configuration
. I have that setup like so:
# 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"
}
}
I'm getting this error:
╷
│ 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" {
│
╵
What is the equivalent of lifecycle_configuration=prevent_destroy
in aws_s3_bucket_lifecycle_configuration
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在混淆Terraform的
LifeCycle
配置和aws_s3_bucket_lifecycle_configuration
/lifecycle_rule
是S3特征,可控制对象中对象的LifyCycle。两者绝对没有任何关系,并且完全无关。解决方案:坚持/使用
lifecycle {destres_destroy = true}
在您的aws_s3_bucket
上,请勿使用aws_s_s3_bucket_lifecycle_configuration
。https://www.terraform.io/language.io/language/meta-arguments/meta-arguments/lifecycle/lifecycle
https://registry.terraform.io/providers/hashicorp%20%20%20/aws/latest/docs/resources/s3_bucket_lifecycle_configuration
You are confusing the
lifecycle
configuration of terraform and theaws_s3_bucket_lifecycle_configuration
/lifecycle_rule
which is an S3 feature controlling the lifycycle of objects in the bucket. The two have absolutely nothing to do with each other and for entirely unrelated things.Solution: stick with / use
lifecycle { prevent_destroy = true }
on youraws_s3_bucket
, do not useaws_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