Skip to content

Commit 72f4e9c

Browse files
author
Heider Oliveira
committed
feat: add unique suffix to S3 bucket names
Introduced a `random_string` resource to generate an 8-character suffix for S3 bucket names, ensuring uniqueness and avoiding naming conflicts.
1 parent 947b389 commit 72f4e9c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

infra/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
resource "aws_s3_bucket" "bucket" {
2-
bucket = var.bucket_name
2+
bucket = "${var.bucket_name}-${random_string.bucket_suffix.result}"
3+
}
4+
5+
resource "random_string" "bucket_suffix" {
6+
length = 8
7+
special = false
8+
upper = false
39
}

0 commit comments

Comments
 (0)