From 434e6ca6bc35db5f390b3fdad362ea1c5fed672f Mon Sep 17 00:00:00 2001 From: Ryan Clemente Date: Tue, 1 Oct 2024 17:48:17 +0800 Subject: [PATCH] Ability to set custom name for CUR bucket --- terraform-modules/cur-setup-source/README.md | 9 +++++++++ terraform-modules/cur-setup-source/main.tf | 4 ++++ terraform-modules/cur-setup-source/variables.tf | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/terraform-modules/cur-setup-source/README.md b/terraform-modules/cur-setup-source/README.md index e29f8e20..78e63803 100644 --- a/terraform-modules/cur-setup-source/README.md +++ b/terraform-modules/cur-setup-source/README.md @@ -104,6 +104,15 @@ 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..d1b1d6ec 100644 --- a/terraform-modules/cur-setup-source/main.tf +++ b/terraform-modules/cur-setup-source/main.tf @@ -2,6 +2,10 @@ 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 ### 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"