什么是等效的“ lifecycle_configuration = destress_destroy”对于aws_s3_bucket_lifecycle_configuration?

发布于 2025-02-14 01:24:52 字数 1120 浏览 0 评论 0原文

我正在努力防止在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

涫野音 2025-02-21 01:24:52

您正在混淆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 the aws_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 your aws_s3_bucket, do not use 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文