`log-export-logbucket` doesn't use prefix
Closed this issue · 1 comments
jedimasterjonny commented
Describe the bug
log-export-logbucket
in stage 0 of FAST doesn't use the prefix, and therefore tries to generate buckets with non-unique names causing the apply to fail.
Environment
Terraform v1.7.5
on linux_amd6
fa58c225
To Reproduce
Try to run stage 0 of FAST, checked out from the v30.0.0
tag
Expected behavior
A successful apply
Result
│ Error: Error creating Bucket: googleapi: Error 409: Bucket audit-logs already exists
│
│ with module.log-export-logbucket["audit-logs"].google_logging_project_bucket_config.bucket[0],
│ on .terraform/modules/log-export-logbucket/modules/logging-bucket/main.tf line 17, in resource "google_logging_project_bucket_config" "bucket":
│ 17: resource "google_logging_project_bucket_config" "bucket" {
│
╵
╷
│ Error: Error creating Bucket: googleapi: Error 409: Bucket vpc-sc already exists
│
│ with module.log-export-logbucket["vpc-sc"].google_logging_project_bucket_config.bucket[0],
│ on .terraform/modules/log-export-logbucket/modules/logging-bucket/main.tf line 17, in resource "google_logging_project_bucket_config" "bucket":
│ 17: resource "google_logging_project_bucket_config" "bucket" {
│
╵
╷
│ Error: Error creating Bucket: googleapi: Error 409: Bucket workspace-audit-logs already exists
│
│ with module.log-export-logbucket["workspace-audit-logs"].google_logging_project_bucket_config.bucket[0],
│ on .terraform/modules/log-export-logbucket/modules/logging-bucket/main.tf line 17, in resource "google_logging_project_bucket_config" "bucket":
│ 17: resource "google_logging_project_bucket_config" "bucket" {
│
Additional context
Fix:
diff --git a/fast/stages/0-bootstrap/log-export.tf b/fast/stages/0-bootstrap/log-export.tf
index ed87c24c..f743baa5 100644
--- a/fast/stages/0-bootstrap/log-export.tf
+++ b/fast/stages/0-bootstrap/log-export.tf
@@ -89,7 +89,7 @@ module "log-export-logbucket" {
for_each = toset([for k, v in var.log_sinks : k if v.type == "logging"])
parent_type = "project"
parent = module.log-export-project.project_id
- id = each.key
+ id = "${local.prefix}-${each.key}"
location = local.locations.logging
log_analytics = { enable = true }
ludoo commented
Yes, bucket names are not globally unique so we prefer keeping them as they are. Just manually delete the existing bucket, or change the name of the sink in the stage variables.