Skip to content

Commit

Permalink
fix bucket names
Browse files Browse the repository at this point in the history
  • Loading branch information
mariammartins committed Oct 9, 2024
1 parent 0bc707b commit bdb467d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions 1-org/modules/cai-monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ locals {
"run.googleapis.com",
"eventarc.googleapis.com"
]
cai_source_name = var.random_suffix ? "CAI Monitoring - ${random_id.suffix.hex}" : "CAI Monitoring"
cai_source_name = var.random_suffix ? "CAI Monitoring - ${random_id.suffix.hex}" : "CAI Monitoring"
cai_monitoring_bucket_suffix = "${random_id.suffix.hex}-sources-${data.google_project.project.number}-${var.location}"
}

data "google_project" "project" {
Expand Down Expand Up @@ -74,7 +75,7 @@ module "cloudfunction_source_bucket" {
version = "~> 6.0"

project_id = var.project_id
name = "bkt-cai-monitoring-${random_id.suffix.hex}-sources-${data.google_project.project.number}-${var.location}"
name = "bkt-cai-monitoring-${md5(local.cai_monitoring_bucket_suffix)}"
location = var.location
storage_class = "REGIONAL"
force_destroy = true
Expand Down
9 changes: 7 additions & 2 deletions 4-projects/modules/base_env/example_storage_cmek.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
* limitations under the License.
*/

locals {
cmek_bucket_prefix = "${var.gcs_bucket_prefix}-cmek-encrypted"
cmek_bucket_suffix = "${module.base_shared_vpc_project.project_id}-${lower(var.location_gcs)}-${random_string.bucket_name.result}"
}

data "google_storage_project_service_account" "gcs_account" {
project = module.base_shared_vpc_project.project_id
}
Expand Down Expand Up @@ -44,11 +49,11 @@ resource "random_string" "bucket_name" {

module "gcs_buckets" {
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
version = "~> 6.0"
version = "~> 6.0.0"

project_id = module.base_shared_vpc_project.project_id
location = var.location_gcs
name = "${var.gcs_bucket_prefix}-${module.base_shared_vpc_project.project_id}-${lower(var.location_gcs)}-cmek-encrypted-${random_string.bucket_name.result}"
name = "${local.cmek_bucket_prefix}-${md5(local.cmek_bucket_suffix)}"
bucket_policy_only = true
custom_placement_config = var.gcs_custom_placement_config

Expand Down

0 comments on commit bdb467d

Please sign in to comment.