Skip to content

Commit

Permalink
feat: Added option to assign a suffix to the bucket name.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesiarmes committed Oct 28, 2024
1 parent 269a41c commit 02ba07f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -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."
Expand Down

0 comments on commit 02ba07f

Please sign in to comment.