From 84d0ed530161427c4b4ec26cda354702d5bcf9df Mon Sep 17 00:00:00 2001 From: Daniel Barnes Date: Sat, 14 Dec 2024 13:07:31 +0900 Subject: [PATCH] use create_bucket flag --- examples/byo-vpc-eks-sql-redis/main.tf | 18 +++++++++++------- examples/byo-vpc-sql/main.tf | 19 ++++++++++++------- main.tf | 18 ++++++++++++------ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/examples/byo-vpc-eks-sql-redis/main.tf b/examples/byo-vpc-eks-sql-redis/main.tf index f2be8eee..ca4a1b83 100644 --- a/examples/byo-vpc-eks-sql-redis/main.tf +++ b/examples/byo-vpc-eks-sql-redis/main.tf @@ -13,7 +13,7 @@ provider "aws" { } data "aws_s3_bucket" "file_storage" { depends_on = [module.file_storage] - bucket = local.bucket_name + bucket = var.bucket_name } data "aws_sqs_queue" "file_storage" { @@ -61,7 +61,6 @@ locals { } module "file_storage" { - count = var.create_bucket ? 1 : 0 source = "../../modules/file_storage" create_queue = !local.use_internal_queue @@ -72,8 +71,7 @@ module "file_storage" { } locals { - bucket_name = local.use_external_bucket ? var.bucket_name : module.file_storage.0.bucket_name - bucket_queue_name = local.use_internal_queue ? null : module.file_storage.0.bucket_queue_name + bucket_queue_name = local.use_internal_queue ? null : module.file_storage.bucket_queue_name } locals { @@ -176,11 +174,17 @@ module "wandb" { extraEnv = var.other_wandb_env - bucket = { + bucket = var.create_bucket ? null : { provider = "s3" - name = local.bucket_name + name = var.bucket_name region = data.aws_s3_bucket.file_storage.region - kmsKey = local.use_external_bucket ? var.bucket_kms_key_arn : local.kms_key_arn + kmsKey = var.bucket_kms_key_arn + } + defaultBucket = { + provider = "s3" + name = module.file_storage.bucket_name + region = module.file_storage.bucket_region + kmsKey = module.kms.key.arn } mysql = { diff --git a/examples/byo-vpc-sql/main.tf b/examples/byo-vpc-sql/main.tf index 6e0dbb05..35cdaa06 100644 --- a/examples/byo-vpc-sql/main.tf +++ b/examples/byo-vpc-sql/main.tf @@ -13,7 +13,7 @@ provider "aws" { } data "aws_s3_bucket" "file_storage" { depends_on = [module.file_storage] - bucket = local.bucket_name + bucket = var.bucket_name } data "aws_sqs_queue" "file_storage" { @@ -102,7 +102,6 @@ locals { } module "file_storage" { - count = var.create_bucket ? 1 : 0 source = "../../modules/file_storage" create_queue = !local.use_internal_queue @@ -113,7 +112,6 @@ module "file_storage" { } locals { - bucket_name = local.use_external_bucket ? var.bucket_name : module.file_storage.0.bucket_name bucket_queue_name = local.use_internal_queue ? null : module.file_storage.0.bucket_queue_name } @@ -167,7 +165,7 @@ module "app_eks" { map_users = var.kubernetes_map_users bucket_kms_key_arns = local.use_external_bucket ? var.bucket_kms_key_arn : local.kms_key_arn - bucket_arn = data.aws_s3_bucket.file_storage.arn + bucket_arn = var.create_bucket ? module.file_storage.bucket_arn : data.aws_s3_bucket.file_storage.arn bucket_sqs_queue_arn = local.use_internal_queue ? null : data.aws_sqs_queue.file_storage.0.arn network_id = local.network_id @@ -281,11 +279,18 @@ module "wandb" { extraEnv = var.other_wandb_env - bucket = { + bucket = var.create_bucket ? null : { provider = "s3" - name = local.bucket_name + name = var.bucket_name region = data.aws_s3_bucket.file_storage.region - kmsKey = local.use_external_bucket ? var.bucket_kms_key_arn : local.kms_key_arn + kmsKey = var.bucket_kms_key_arn + } + + defaultBucket = { + provider = "s3" + name = module.file_storage.bucket_name + region = module.file_storage.bucket_region + kmsKey = module.kms.key.arn } mysql = { diff --git a/main.tf b/main.tf index 1b74a5a3..44f2df9a 100644 --- a/main.tf +++ b/main.tf @@ -29,7 +29,7 @@ locals { } module "file_storage" { - count = var.create_bucket ? 1 : 0 + #count = var.create_bucket ? 1 : 0 source = "./modules/file_storage" namespace = var.namespace create_queue = !local.use_internal_queue @@ -39,8 +39,8 @@ module "file_storage" { } locals { - bucket_name = local.use_external_bucket ? var.bucket_name : module.file_storage[0].bucket_name - bucket_queue_name = local.use_internal_queue ? null : module.file_storage[0].bucket_queue_name + bucket_name = local.use_external_bucket ? var.bucket_name : module.file_storage.bucket_name + bucket_queue_name = local.use_internal_queue ? null : module.file_storage.bucket_queue_name } module "networking" { @@ -271,12 +271,18 @@ module "wandb" { cloudProvider = "aws" extraEnv = var.other_wandb_env - defaultBucket = { + bucket = var.create_bucket ? null : { provider = "s3" - name = local.bucket_name + name = var.bucket_name path = var.bucket_path region = data.aws_s3_bucket.file_storage.region - kmsKey = local.s3_kms_key_arn + kmsKey = var.bucket_kms_key_arn + } + defaultBucket = { + provider = "s3" + name = module.file_storage.bucket_name + region = module.file_storage.bucket_region + kmsKey = module.kms.key.arn } mysql = {