Skip to content

Commit

Permalink
fix: use bootstrap.outputs.common_config as default in 4-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
nbugden committed Apr 3, 2024
1 parent 0d23fe2 commit 35a47ed
Show file tree
Hide file tree
Showing 26 changed files with 192 additions and 67 deletions.
2 changes: 2 additions & 0 deletions 0-bootstrap/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ output "common_config" {
billing_account = var.billing_account,
default_region = var.default_region,
default_region_2 = var.default_region_2,
default_region_gcs = var.default_region_gcs,
default_region_kms = var.default_region_kms,
project_prefix = var.project_prefix,
folder_prefix = var.folder_prefix
parent_id = local.parent
Expand Down
5 changes: 4 additions & 1 deletion 0-bootstrap/terraform.example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ groups = {
# }
}

default_region = "us-central1"
default_region = "us-central1"
default_region_2 = "us-west1"
default_region_gcs = "US"
default_region_kms = "us"

# Optional - for an organization with existing projects or for development/validation.
# Uncomment this variable to place all the example foundation resources under
Expand Down
12 changes: 12 additions & 0 deletions 0-bootstrap/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ variable "default_region_2" {
default = "us-west1"
}

variable "default_region_gcs" {
description = "Case-Sensitive default region to create gcs resources where applicable."
type = string
default = "US"
}

variable "default_region_kms" {
description = "Secondary default region to create kms resources where applicable."
type = string
default = "us"
}

variable "parent_folder" {
description = "Optional - for an organization with existing projects or for development/validation. It will place all the example foundation resources under the provided folder instead of the root organization. The value is the numeric folder ID. The folder must already exist."
type = string
Expand Down
18 changes: 12 additions & 6 deletions 4-projects/business_unit_1/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
module "env" {
source = "../../modules/base_env"

env = "development"
business_code = "bu1"
business_unit = "business_unit_1"
remote_state_bucket = var.remote_state_bucket
location_kms = var.location_kms
location_gcs = var.location_gcs
env = "development"
business_code = "bu1"
business_unit = "business_unit_1"
remote_state_bucket = var.remote_state_bucket
location_kms = coalesce(var.location_kms, local.default_region_kms)
location_gcs = coalesce(var.location_gcs, local.default_region_gcs)
gcs_custom_placement_config = {
data_locations = [
local.default_region,
local.default_region_2,
]
}
tfc_org_name = var.tfc_org_name
peering_module_depends_on = var.peering_module_depends_on
peering_iap_fw_rules_enabled = true
Expand Down
5 changes: 4 additions & 1 deletion 4-projects/business_unit_1/development/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs
default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms
}

data "terraform_remote_state" "bootstrap" {
Expand Down
12 changes: 10 additions & 2 deletions 4-projects/business_unit_1/development/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ variable "remote_state_bucket" {
variable "location_kms" {
description = "Case-Sensitive Location for KMS Keyring (Should be same region as the GCS Bucket)"
type = string
default = "us"
default = null
}

variable "location_gcs" {
description = "Case-Sensitive Location for GCS Bucket (Should be same region as the KMS Keyring)"
type = string
default = "US"
default = null
}

variable "gcs_custom_placement_config" {
description = "Configuration of the bucket's custom location in a dual-region bucket setup. If the bucket is designated a single or multi-region, the variable are null."
type = object({
data_locations = list(string)
})
default = null
}

variable "peering_module_depends_on" {
Expand Down
18 changes: 12 additions & 6 deletions 4-projects/business_unit_1/non-production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
module "env" {
source = "../../modules/base_env"

env = "non-production"
business_code = "bu1"
business_unit = "business_unit_1"
remote_state_bucket = var.remote_state_bucket
location_kms = var.location_kms
location_gcs = var.location_gcs
env = "non-production"
business_code = "bu1"
business_unit = "business_unit_1"
remote_state_bucket = var.remote_state_bucket
location_kms = coalesce(var.location_kms, local.default_region_kms)
location_gcs = coalesce(var.location_gcs, local.default_region_gcs)
gcs_custom_placement_config = {
data_locations = [
local.default_region,
local.default_region_2,
]
}
tfc_org_name = var.tfc_org_name
peering_module_depends_on = var.peering_module_depends_on
peering_iap_fw_rules_enabled = true
Expand Down
5 changes: 4 additions & 1 deletion 4-projects/business_unit_1/non-production/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs
default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms
}

data "terraform_remote_state" "bootstrap" {
Expand Down
12 changes: 10 additions & 2 deletions 4-projects/business_unit_1/non-production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ variable "remote_state_bucket" {
variable "location_kms" {
description = "Case-Sensitive Location for KMS Keyring (Should be same region as the GCS Bucket)"
type = string
default = "us"
default = null
}

variable "location_gcs" {
description = "Case-Sensitive Location for GCS Bucket (Should be same region as the KMS Keyring)"
type = string
default = "US"
default = null
}

variable "gcs_custom_placement_config" {
description = "Configuration of the bucket's custom location in a dual-region bucket setup. If the bucket is designated a single or multi-region, the variable are null."
type = object({
data_locations = list(string)
})
default = null
}

variable "peering_module_depends_on" {
Expand Down
18 changes: 12 additions & 6 deletions 4-projects/business_unit_1/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
module "env" {
source = "../../modules/base_env"

env = "production"
business_code = "bu1"
business_unit = "business_unit_1"
remote_state_bucket = var.remote_state_bucket
location_kms = var.location_kms
location_gcs = var.location_gcs
env = "production"
business_code = "bu1"
business_unit = "business_unit_1"
remote_state_bucket = var.remote_state_bucket
location_kms = coalesce(var.location_kms, local.default_region_kms)
location_gcs = coalesce(var.location_gcs, local.default_region_gcs)
gcs_custom_placement_config = {
data_locations = [
local.default_region,
local.default_region_2,
]
}
tfc_org_name = var.tfc_org_name
peering_module_depends_on = var.peering_module_depends_on
peering_iap_fw_rules_enabled = true
Expand Down
5 changes: 4 additions & 1 deletion 4-projects/business_unit_1/production/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs
default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms
}

data "terraform_remote_state" "bootstrap" {
Expand Down
12 changes: 10 additions & 2 deletions 4-projects/business_unit_1/production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ variable "remote_state_bucket" {
variable "location_kms" {
description = "Case-Sensitive Location for KMS Keyring (Should be same region as the GCS Bucket)"
type = string
default = "us"
default = null
}

variable "location_gcs" {
description = "Case-Sensitive Location for GCS Bucket (Should be same region as the KMS Keyring)"
type = string
default = "US"
default = null
}

variable "gcs_custom_placement_config" {
description = "Configuration of the bucket's custom location in a dual-region bucket setup. If the bucket is designated a single or multi-region, the variable are null."
type = object({
data_locations = list(string)
})
default = null
}

variable "peering_module_depends_on" {
Expand Down
18 changes: 12 additions & 6 deletions 4-projects/business_unit_2/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
module "env" {
source = "../../modules/base_env"

env = "development"
business_code = "bu2"
business_unit = "business_unit_2"
remote_state_bucket = var.remote_state_bucket
location_kms = var.location_kms
location_gcs = var.location_gcs
env = "development"
business_code = "bu2"
business_unit = "business_unit_2"
remote_state_bucket = var.remote_state_bucket
location_kms = coalesce(var.location_kms, local.default_region_kms)
location_gcs = coalesce(var.location_gcs, local.default_region_gcs)
gcs_custom_placement_config = {
data_locations = [
local.default_region,
local.default_region_2,
]
}
tfc_org_name = var.tfc_org_name
peering_module_depends_on = var.peering_module_depends_on
peering_iap_fw_rules_enabled = true
Expand Down
5 changes: 4 additions & 1 deletion 4-projects/business_unit_2/development/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs
default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms
}

data "terraform_remote_state" "bootstrap" {
Expand Down
12 changes: 10 additions & 2 deletions 4-projects/business_unit_2/development/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ variable "remote_state_bucket" {
variable "location_kms" {
description = "Case-Sensitive Location for KMS Keyring (Should be same region as the GCS Bucket)"
type = string
default = "us"
default = null
}

variable "location_gcs" {
description = "Case-Sensitive Location for GCS Bucket (Should be same region as the KMS Keyring)"
type = string
default = "US"
default = null
}

variable "gcs_custom_placement_config" {
description = "Configuration of the bucket's custom location in a dual-region bucket setup. If the bucket is designated a single or multi-region, the variable are null."
type = object({
data_locations = list(string)
})
default = null
}

variable "peering_module_depends_on" {
Expand Down
18 changes: 12 additions & 6 deletions 4-projects/business_unit_2/non-production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
module "env" {
source = "../../modules/base_env"

env = "non-production"
business_code = "bu2"
business_unit = "business_unit_2"
remote_state_bucket = var.remote_state_bucket
location_kms = var.location_kms
location_gcs = var.location_gcs
env = "non-production"
business_code = "bu2"
business_unit = "business_unit_2"
remote_state_bucket = var.remote_state_bucket
location_kms = coalesce(var.location_kms, local.default_region_kms)
location_gcs = coalesce(var.location_gcs, local.default_region_gcs)
gcs_custom_placement_config = {
data_locations = [
local.default_region,
local.default_region_2,
]
}
tfc_org_name = var.tfc_org_name
peering_module_depends_on = var.peering_module_depends_on
peering_iap_fw_rules_enabled = true
Expand Down
5 changes: 4 additions & 1 deletion 4-projects/business_unit_2/non-production/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs
default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms
}

data "terraform_remote_state" "bootstrap" {
Expand Down
12 changes: 10 additions & 2 deletions 4-projects/business_unit_2/non-production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ variable "remote_state_bucket" {
variable "location_kms" {
description = "Case-Sensitive Location for KMS Keyring (Should be same region as the GCS Bucket)"
type = string
default = "us"
default = null
}

variable "location_gcs" {
description = "Case-Sensitive Location for GCS Bucket (Should be same region as the KMS Keyring)"
type = string
default = "US"
default = null
}

variable "gcs_custom_placement_config" {
description = "Configuration of the bucket's custom location in a dual-region bucket setup. If the bucket is designated a single or multi-region, the variable are null."
type = object({
data_locations = list(string)
})
default = null
}

variable "peering_module_depends_on" {
Expand Down
18 changes: 12 additions & 6 deletions 4-projects/business_unit_2/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@
module "env" {
source = "../../modules/base_env"

env = "production"
business_code = "bu2"
business_unit = "business_unit_2"
remote_state_bucket = var.remote_state_bucket
location_kms = var.location_kms
location_gcs = var.location_gcs
env = "production"
business_code = "bu2"
business_unit = "business_unit_2"
remote_state_bucket = var.remote_state_bucket
location_kms = coalesce(var.location_kms, local.default_region_kms)
location_gcs = coalesce(var.location_gcs, local.default_region_gcs)
gcs_custom_placement_config = {
data_locations = [
local.default_region,
local.default_region_2,
]
}
tfc_org_name = var.tfc_org_name
peering_module_depends_on = var.peering_module_depends_on
peering_iap_fw_rules_enabled = true
Expand Down
5 changes: 4 additions & 1 deletion 4-projects/business_unit_2/production/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs
default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms
}

data "terraform_remote_state" "bootstrap" {
Expand Down
Loading

0 comments on commit 35a47ed

Please sign in to comment.