Skip to content

fix: allow setting GCS and KMS default location separately #354

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ locals {
is_organization = var.parent_folder == "" ? true : false
parent_id = var.parent_folder == "" ? var.org_id : split("/", var.parent_folder)[1]
seed_org_depends_on = try(google_folder_iam_member.tmp_project_creator[0].etag, "") != "" ? var.org_id : google_organization_iam_member.tmp_project_creator[0].org_id
kms_location = var.kms_default_location == null ? var.default_region : var.kms_default_location
gcs_location = var.gcs_default_location == null ? var.default_region : var.gcs_default_location
}

resource "random_id" "suffix" {
Expand Down Expand Up @@ -116,7 +118,7 @@ module "kms" {
version = "~> 3.2"

project_id = module.seed_project.project_id
location = var.default_region
location = local.kms_location
keyring = "${var.project_prefix}-keyring"
keys = ["${var.project_prefix}-key"]
key_rotation_period = var.key_rotation_period
Expand All @@ -135,7 +137,7 @@ module "kms" {
resource "google_storage_bucket" "org_terraform_state" {
project = module.seed_project.project_id
name = local.state_bucket_name
location = var.default_region
location = local.gcs_location
labels = var.storage_bucket_labels
force_destroy = var.force_destroy
uniform_bucket_level_access = true
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ variable "default_region" {
type = string
default = "us-central1"
}
variable "gcs_default_region" {
description = "Default region to create GCS resources where applicable."
type = string
default = "us-central1"
}
variable "kms_default_region" {
description = "Default region to create KMS resources where applicable."
type = string
default = "us-central1"
}

/******************************************
Optional variables
Expand Down