Skip to content

Commit

Permalink
Ability to set custom name for CUR bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Clemente authored and rclemente-mrge committed Oct 1, 2024
1 parent e976cb5 commit ca0e26d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions terraform-modules/cur-setup-source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion terraform-modules/cur-setup-source/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions terraform-modules/cur-setup-source/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit ca0e26d

Please sign in to comment.