diff --git a/README.md b/README.md index 3524eb1..c3f9c42 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,10 @@ tofu init -upgrade | Name | Description | Type | Default | Required | |--------------------------|-----------------------------------------------------------------------------------------|----------------|---------|----------| | project | Name of the project. | `string` | n/a | yes | +| bucket_suffix | Adds a random suffix to the bucket name. | `bool` | `false` | no | | cloudwatch_log_retention | Number of days to retain logs in CloudWatch. | `number` | `30` | no | | environment | Environment for the project. | `string` | `"dev"` | no | -| key_recovery_period | Number of days to recover the KMS key after deletion. | `number` | `30` | yes | +| key_recovery_period | Number of days to recover the KMS key after deletion. | `number` | `30` | no | | [log_groups] | List of CloudWatch log groups to create. | `list(string)` | `[]` | no | | log_groups_to_datadog | Send CloudWatch logs to Datadog. The Datadog forwarder must have already been deployed. | `bool` | `true` | no | | tags | Optional tags to be applied to all resources. | `list` | `[]` | no | diff --git a/main.tf b/main.tf index 6bc7c1d..31a9ca2 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,8 @@ # loop of logging. #trivy:ignore:avd-aws-0089 resource "aws_s3_bucket" "logs" { - bucket = "${local.prefix}-logs" + bucket = var.bucket_suffix ? null : "${local.prefix}-logs" + bucket_prefix = var.bucket_suffix ? "${local.prefix}-logs" : null lifecycle { prevent_destroy = true diff --git a/variables.tf b/variables.tf index 5b5f69c..e8955c4 100644 --- a/variables.tf +++ b/variables.tf @@ -1,3 +1,9 @@ +variable "bucket_suffix" { + type = bool + description = "Adds a random suffix to the bucket name." + default = false +} + variable "cloudwatch_log_retention" { type = number description = "Number of days to retain logs in CloudWatch."