diff --git a/terraform-modules/cur-setup-source/README.md b/terraform-modules/cur-setup-source/README.md index e29f8e20..1da665e7 100644 --- a/terraform-modules/cur-setup-source/README.md +++ b/terraform-modules/cur-setup-source/README.md @@ -104,6 +104,14 @@ Type: `string` The following input variables are optional (have default values): +### cur\_bucket\_name + +Description: S3 Bucket name for CUR + +Type: `string` + +Default: `null` + ### cur\_name\_suffix Description: Suffix used to name the CUR report diff --git a/terraform-modules/cur-setup-source/main.tf b/terraform-modules/cur-setup-source/main.tf index 0a6880d5..c6421a45 100644 --- a/terraform-modules/cur-setup-source/main.tf +++ b/terraform-modules/cur-setup-source/main.tf @@ -2,12 +2,16 @@ data "aws_caller_identity" "this" {} data "aws_partition" "this" {} data "aws_region" "this" {} +locals { + cur_bucket_name = var.cur_bucket_name != null ? var.cur_bucket_name : "${var.resource_prefix}-${data.aws_caller_identity.this.account_id}-local" +} + ### # CUR S3 Bucket ### resource "aws_s3_bucket" "this" { # checkov:skip=CKV2_AWS_62:Due to dependencies, S3 event notifications must be configured external to the module - bucket = "${var.resource_prefix}-${data.aws_caller_identity.this.account_id}-local" + bucket = local.cur_bucket_name force_destroy = true tags = var.tags diff --git a/terraform-modules/cur-setup-source/variables.tf b/terraform-modules/cur-setup-source/variables.tf index 6aa530b2..b305bc31 100644 --- a/terraform-modules/cur-setup-source/variables.tf +++ b/terraform-modules/cur-setup-source/variables.tf @@ -1,3 +1,9 @@ +variable "cur_bucket_name" { + type = string + description = "S3 Bucket name for CUR(optional)" + default = null +} + variable "destination_bucket_arn" { type = string description = "Destination Bucket ARN"