Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added option to assign a suffix to the bucket name. #7

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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