From 15963ebbb988d139fc0b9a6b99a7c0bc18fbe921 Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Wed, 8 May 2024 15:57:05 -0700 Subject: [PATCH] [feat] create s3 module --- infra/s3/main.tf | 2 ++ statestore/main.tf | 11 ++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/infra/s3/main.tf b/infra/s3/main.tf index be0d8bc..21cbc0b 100644 --- a/infra/s3/main.tf +++ b/infra/s3/main.tf @@ -1,4 +1,6 @@ module "s3-bucket" { source = "terraform-aws-modules/s3-bucket/aws" version = "4.1.2" + + bucket = var.bucket_name } diff --git a/statestore/main.tf b/statestore/main.tf index 1560335..738b02f 100644 --- a/statestore/main.tf +++ b/statestore/main.tf @@ -3,15 +3,8 @@ locals { dynamodb_table_name = "${var.project}-${var.env}-tflock-${var.region}" } -resource "random_string" "bucket_suffix" { - length = 8 - special = false - upper = false - numeric = true -} - resource "aws_s3_bucket" "bucket" { - bucket = format("%s-%s", local.bucket_name, random_string.bucket_suffix.result) + bucket = local.bucket_name lifecycle { prevent_destroy = true @@ -26,7 +19,7 @@ resource "aws_s3_bucket_versioning" "versioning" { } resource "aws_dynamodb_table" "table" { - name = format("%s-%s", local.dynamodb_table_name, random_string.bucket_suffix.result) + name = local.dynamodb_table_name hash_key = "LockID" read_capacity = 20 write_capacity = 20