Skip to content

Commit

Permalink
use create_bucket flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dacbd committed Dec 14, 2024
1 parent 232bc7a commit 84d0ed5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
18 changes: 11 additions & 7 deletions examples/byo-vpc-eks-sql-redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -61,7 +61,6 @@ locals {
}

module "file_storage" {
count = var.create_bucket ? 1 : 0
source = "../../modules/file_storage"

create_queue = !local.use_internal_queue
Expand All @@ -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 {
Expand Down Expand Up @@ -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 = {
Expand Down
19 changes: 12 additions & 7 deletions examples/byo-vpc-sql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -102,7 +102,6 @@ locals {
}

module "file_storage" {
count = var.create_bucket ? 1 : 0
source = "../../modules/file_storage"

create_queue = !local.use_internal_queue
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
18 changes: 12 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" {
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 84d0ed5

Please sign in to comment.