Skip to content

Commit

Permalink
fix: use bootstrap.outputs.common_config as default in 5-app-infra
Browse files Browse the repository at this point in the history
  • Loading branch information
nbugden committed Apr 3, 2024
1 parent 35a47ed commit 3833e0b
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 5-app-infra/business_unit_1/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module "base_shared_gce_instance" {
environment = local.environment
business_unit = local.business_unit
project_suffix = "sample-base"
region = var.instance_region
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}

Expand All @@ -35,6 +35,6 @@ module "peering_gce_instance" {
environment = local.environment
business_unit = local.business_unit
project_suffix = "sample-peering"
region = var.instance_region
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}
28 changes: 28 additions & 0 deletions 5-app-infra/business_unit_1/development/remote.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
}

data "terraform_remote_state" "bootstrap" {
backend = "gcs"

config = {
bucket = var.remote_state_bucket
prefix = "terraform/bootstrap/state"
}
}
1 change: 1 addition & 0 deletions 5-app-infra/business_unit_1/development/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
variable "instance_region" {
description = "The region where compute instance will be created. A subnetwork must exists in the instance region."
type = string
default = null
}

variable "remote_state_bucket" {
Expand Down
4 changes: 2 additions & 2 deletions 5-app-infra/business_unit_1/non-production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module "base_shared_gce_instance" {
environment = local.environment
business_unit = local.business_unit
project_suffix = "sample-base"
region = var.instance_region
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}

Expand All @@ -35,6 +35,6 @@ module "peering_gce_instance" {
environment = local.environment
business_unit = local.business_unit
project_suffix = "sample-peering"
region = var.instance_region
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}
28 changes: 28 additions & 0 deletions 5-app-infra/business_unit_1/non-production/remote.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
}

data "terraform_remote_state" "bootstrap" {
backend = "gcs"

config = {
bucket = var.remote_state_bucket
prefix = "terraform/bootstrap/state"
}
}
1 change: 1 addition & 0 deletions 5-app-infra/business_unit_1/non-production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
variable "instance_region" {
description = "The region where compute instance will be created. A subnetwork must exists in the instance region."
type = string
default = null
}

variable "remote_state_bucket" {
Expand Down
4 changes: 2 additions & 2 deletions 5-app-infra/business_unit_1/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module "base_shared_gce_instance" {
environment = local.environment
business_unit = local.business_unit
project_suffix = "sample-base"
region = var.instance_region
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}

Expand All @@ -35,6 +35,6 @@ module "peering_gce_instance" {
environment = local.environment
business_unit = local.business_unit
project_suffix = "sample-peering"
region = var.instance_region
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}
28 changes: 28 additions & 0 deletions 5-app-infra/business_unit_1/production/remote.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

locals {
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
}

data "terraform_remote_state" "bootstrap" {
backend = "gcs"

config = {
bucket = var.remote_state_bucket
prefix = "terraform/bootstrap/state"
}
}
1 change: 1 addition & 0 deletions 5-app-infra/business_unit_1/production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
variable "instance_region" {
description = "The region where compute instance will be created. A subnetwork must exists in the instance region."
type = string
default = null
}

variable "remote_state_bucket" {
Expand Down
2 changes: 1 addition & 1 deletion 5-app-infra/common.auto.example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

instance_region = "us-central1" // should be one of the regions used to create network on step 3-networks
# instance_region = "us-central1" // should be one of the regions used to create network on step 3-networks

remote_state_bucket = "REMOTE_STATE_BUCKET"

0 comments on commit 3833e0b

Please sign in to comment.