Skip to content

Commit

Permalink
CORE-260 consistently set bucket name for static website
Browse files Browse the repository at this point in the history
  • Loading branch information
tundeaoni committed May 3, 2024
1 parent 0503a52 commit 1140f53
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions google/static-website/main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
locals {
# We have to use dashes instead of dots in the bucket name, because
# that bucket is not a website
website_domain_name_dashed = replace(var.website_domain_name, ".", "-")
bucket_name = var.bucket_name == "" ? "${local.website_domain_name_dashed}-bucket" : "${var.bucket_name}"
}

resource "google_compute_backend_bucket" "static" {
project = var.project

name = var.bucket_name == "" ? "${local.website_domain_name_dashed}-bucket" : "${var.bucket_name}"
name = local.bucket_name
bucket_name = module.website.name
enable_cdn = var.enable_cdn
}
Expand All @@ -16,7 +15,7 @@ module "website" {
source = "terraform-google-modules/cloud-storage/google"
version = "5.0.0"
project_id = var.project
names = [local.website_domain_name_dashed]
names = [local.bucket_name]
set_admin_roles = true
admins = var.storage_admins
website = {
Expand Down

0 comments on commit 1140f53

Please sign in to comment.