From 5896a3b44b650875b9bad08d5b0c7d8d8fe2ba4c Mon Sep 17 00:00:00 2001 From: Michael Li Date: Thu, 5 Dec 2024 09:51:53 -0500 Subject: [PATCH] chore(e2e): Add object expiration policy to s3 bucket (#5298) * chore(e2e): Add expiration date to aws bucket objects * chore(e2e): Add user tag to bucket --- enos/modules/aws_bucket/main.tf | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/enos/modules/aws_bucket/main.tf b/enos/modules/aws_bucket/main.tf index 20c7b1c39..955782066 100644 --- a/enos/modules/aws_bucket/main.tf +++ b/enos/modules/aws_bucket/main.tf @@ -3,10 +3,29 @@ resource "random_pet" "default" {} +data "aws_caller_identity" "current" {} + resource "aws_s3_bucket" "default" { bucket_prefix = "enos-${random_pet.default.id}-" force_destroy = true - tags = local.common_tags + tags = merge( + local.common_tags, + { + User = "${split(":", data.aws_caller_identity.current.user_id)[1]}" + }, + ) +} + +resource "aws_s3_bucket_lifecycle_configuration" "example" { + bucket = aws_s3_bucket.default.id + + rule { + id = "file_retention" + expiration { + days = 30 + } + status = "Enabled" + } } data "aws_iam_policy_document" "default" {