Skip to content

Commit

Permalink
Allow setting the full name of the S3 bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
Chili-Man committed Feb 6, 2024
1 parent bdf9b04 commit 5944fa7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ locals {

source_bucket_arn = var.create_s3_bucket ? aws_s3_bucket.mwaa[0].arn : var.source_bucket_arn

source_bucket_prefix = var.source_bucket_name == null ? format("%s-%s-", "mwaa", data.aws_caller_identity.current.account_id) : (var.use_source_bucket_name_as_prefix ? var.source_bucket_name : null)

source_bucket_name = local.source_bucket_prefix != null ? null : var.var.source_bucket_name

default_airflow_configuration_options = {
"logging.logging_level" = "INFO"
}
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ resource "aws_iam_role_policy_attachment" "mwaa" {
resource "aws_s3_bucket" "mwaa" {
count = var.create_s3_bucket ? 1 : 0

bucket_prefix = var.source_bucket_name != null ? var.source_bucket_name : format("%s-%s-", "mwaa", data.aws_caller_identity.current.account_id)
tags = var.tags
name = local.source_bucket_name
bucket_prefix = local.source_bucket_prefix

tags = var.tags
}

#tfsec:ignore:aws-s3-encryption-customer-key
Expand Down
12 changes: 11 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,22 @@ variable "create_s3_bucket" {

variable "source_bucket_name" {
description = <<-EOD
New bucket will be created with the given name for MWAA when create_s3_bucket=true
New bucket will be created with the given name for MWAA when create_s3_bucket=true.
If set to null, then the default bucket name prefix will be set, irrespective of the value of `var.use_source_bucket_name_as_prefix`
EOD
type = string
default = null
}

variable "use_source_bucket_name_as_prefix" {
description = <<-EOD
Whether or not to use the `var.source_bucket_name` as the S3 bucket name prefix
EOD
type = bool
default = true
}


variable "source_bucket_arn" {
description = "(Required) The Amazon Resource Name (ARN) of your Amazon S3 storage bucket. For example, arn:aws:s3:::airflow-mybucketname"
type = string
Expand Down

0 comments on commit 5944fa7

Please sign in to comment.