From 96088a5a47bec8cbd1cb7de33f4cc8689a25270c Mon Sep 17 00:00:00 2001 From: Christophe Tafani-Dereeper Date: Tue, 23 Jan 2024 17:33:51 +0100 Subject: [PATCH] Ensure that S3 bucket names are globally unique for aws.persistence.lambda-layer-extension (#465) --- .../aws/persistence/lambda-layer-extension/main.tf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/v2/internal/attacktechniques/aws/persistence/lambda-layer-extension/main.tf b/v2/internal/attacktechniques/aws/persistence/lambda-layer-extension/main.tf index bd9af5f8..16ba9dab 100644 --- a/v2/internal/attacktechniques/aws/persistence/lambda-layer-extension/main.tf +++ b/v2/internal/attacktechniques/aws/persistence/lambda-layer-extension/main.tf @@ -67,10 +67,18 @@ resource "aws_iam_role_policy_attachment" "lambda_logs_attach" { policy_arn = aws_iam_policy.lambda_logs.arn } + +resource "random_string" "suffix" { + length = 6 + min_lower = 6 + special = false +} + resource "aws_s3_bucket" "bucket" { - bucket = "${local.resource_prefix}-bucket" + bucket = "${local.resource_prefix}-${random_string.suffix.result}" force_destroy = true } + resource "aws_s3_bucket_object" "code" { bucket = aws_s3_bucket.bucket.id key = "simpleLambda.zip"