作者:mobiledu2502905213 | 来源:互联网 | 2023-10-11 18:19
Hi there,
Terraform Version
all
Affected Resource(s)
Please list the resources as a list, for example:
- aws_s3_bucket, s3 is a sample, this feature should be applied to most resources.
- meta-parameters: lifecycle
Terraform lifecycle has three attributes: create_before_destroy, prevent_destroy, ignore_changes, but doesn't support attribute
which AWS CFN supported.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
Terraform Configuration Files
1 2 3 4 5 6 7
| hcl
resource "aws_s3_bucket" {
...
lifecycle {
retain = true|false
}
} |
Expected Behavior
Need
option works as in AWS Cloudformation. Related document is at http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
To keep a resource when its stack is deleted, specify
for that resource.
1
| You can use retain for any resource |
. For example, you can retain a nested stack, S3 bucket, or EC2 instance so that you can continue to use or modify those resources after you delete their stacks.
Actual Behavior
No this option
该提问来源于开源项目:hashicorp/terraform-provider-aws
This would be useful for our deployment process. It mostly uses terraform, but it also uploads our Javascript bundles to S3 with immutable filenames, which are eventually cleaned up by S3 lifecycle policies. We tried using terraform for this, but it deletes previous versions which are gone from the local filesystem, so we're currently using aws-cli instead.