Skip to content

Commit bdb467d

Browse files
committed
fix bucket names
1 parent 0bc707b commit bdb467d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

1-org/modules/cai-monitoring/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ locals {
2626
"run.googleapis.com",
2727
"eventarc.googleapis.com"
2828
]
29-
cai_source_name = var.random_suffix ? "CAI Monitoring - ${random_id.suffix.hex}" : "CAI Monitoring"
29+
cai_source_name = var.random_suffix ? "CAI Monitoring - ${random_id.suffix.hex}" : "CAI Monitoring"
30+
cai_monitoring_bucket_suffix = "${random_id.suffix.hex}-sources-${data.google_project.project.number}-${var.location}"
3031
}
3132

3233
data "google_project" "project" {
@@ -74,7 +75,7 @@ module "cloudfunction_source_bucket" {
7475
version = "~> 6.0"
7576

7677
project_id = var.project_id
77-
name = "bkt-cai-monitoring-${random_id.suffix.hex}-sources-${data.google_project.project.number}-${var.location}"
78+
name = "bkt-cai-monitoring-${md5(local.cai_monitoring_bucket_suffix)}"
7879
location = var.location
7980
storage_class = "REGIONAL"
8081
force_destroy = true

4-projects/modules/base_env/example_storage_cmek.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
locals {
18+
cmek_bucket_prefix = "${var.gcs_bucket_prefix}-cmek-encrypted"
19+
cmek_bucket_suffix = "${module.base_shared_vpc_project.project_id}-${lower(var.location_gcs)}-${random_string.bucket_name.result}"
20+
}
21+
1722
data "google_storage_project_service_account" "gcs_account" {
1823
project = module.base_shared_vpc_project.project_id
1924
}
@@ -44,11 +49,11 @@ resource "random_string" "bucket_name" {
4449

4550
module "gcs_buckets" {
4651
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
47-
version = "~> 6.0"
52+
version = "~> 6.0.0"
4853

4954
project_id = module.base_shared_vpc_project.project_id
5055
location = var.location_gcs
51-
name = "${var.gcs_bucket_prefix}-${module.base_shared_vpc_project.project_id}-${lower(var.location_gcs)}-cmek-encrypted-${random_string.bucket_name.result}"
56+
name = "${local.cmek_bucket_prefix}-${md5(local.cmek_bucket_suffix)}"
5257
bucket_policy_only = true
5358
custom_placement_config = var.gcs_custom_placement_config
5459

0 commit comments

Comments
 (0)