Get right to it, here is the code
Python CDK code for creating an S3 bucket with a lifecycle rule which uses a tag filter.
bucket = s3.Bucket(self, "myBucket",
lifecycle_rules = [
s3.LifecycleRule(
id="example-rule-made-with-python-cdk",
expiration=core.Duration.days(1),
tag_filters={
'Key': 'delete_in_1_day',
'Value': 'true'
}
)
]
)
Relevant CDK docs:
- https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_s3/Bucket.html
- https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_s3/LifecycleRule.html#aws_cdk.aws_s3.LifecycleRule
Note: AWS Lifecycle rules do not get more precise than 24 hours[docs].
More CDK or AWS Serverless Questions?
Feel free to leave a comment here or hit us up on LinkedIn.
Want to learn more about how SignetSeal can help make your chats more secure? Read more about us on our website SignetSeal.com
Top comments (0)