Skip to content

Commit 32afc3e

Browse files
update dual-shared
1 parent 027fa28 commit 32afc3e

File tree

17 files changed

+129
-52
lines changed

17 files changed

+129
-52
lines changed

3-networks-dual-svpc/README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,15 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
195195

196196
```bash
197197
git add .
198-
git commit -m 'Initialize networks repo'
198+
git commit -m 'Initialize networks repo - plan'
199+
```
200+
201+
1. You must manually plan and apply the `production` environment since the `development`, `nonproduction` and `plan` environments depend on it.
202+
203+
```bash
204+
git checkout -b production
199205
```
200206

201-
1. You must manually plan and apply the `shared` environment (only once) since the `development`, `nonproduction` and `production` environments depend on it.
202207
1. To use the `validate` option of the `tf-wrapper.sh` script, please follow the [instructions](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) to install the terraform-tools component.
203208
1. Use `terraform output` to get the Cloud Build project ID and the networks step Terraform Service Account from 0-bootstrap output. An environment variable `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` will be set using the Terraform Service Account to enable impersonation.
204209

@@ -210,6 +215,36 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
210215
echo ${GOOGLE_IMPERSONATE_SERVICE_ACCOUNT}
211216
```
212217

218+
1. Run `init` and `plan` and review output for environment production.
219+
220+
```bash
221+
./tf-wrapper.sh init production
222+
./tf-wrapper.sh plan production
223+
```
224+
225+
1. Run `validate` and check for violations.
226+
227+
```bash
228+
./tf-wrapper.sh validate production $(pwd)/../gcp-policies ${CLOUD_BUILD_PROJECT_ID}
229+
```
230+
231+
1. Run `apply` production.
232+
233+
```bash
234+
./tf-wrapper.sh apply production
235+
```
236+
237+
1. Push your production branch since development and nonproduction depends it. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
238+
pushing to this branch triggers both _terraform plan_ and _terraform apply_. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
239+
240+
*Note:** The Production envrionment must be the first branch to be pushed as it includes the DNS Hub communication that will be used by other environments.
241+
242+
```bash
243+
git push --set-upstream origin production
244+
```
245+
246+
1. You must manually plan and apply the `shared` environment (only once) since the `development`, `nonproduction` and `production` environments depend on it.
247+
213248
1. Run `init` and `plan` and review output for environment shared.
214249

215250
```bash
@@ -237,17 +272,7 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
237272
git push --set-upstream origin plan
238273
```
239274

240-
1. Merge changes to production. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
241-
pushing to this branch triggers both _terraform plan_ and _terraform apply_. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
242-
243-
*Note:** The Production envrionment must be the next branch to be merged as it includes the DNS Hub communication that will be used by other environments.
244-
245-
```bash
246-
git checkout -b production
247-
git push origin production
248-
```
249-
250-
1. After production has been applied, apply development.
275+
1. After plan has been applied, apply development.
251276
1. Merge changes to development. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
252277
pushing to this branch triggers both _terraform plan_ and _terraform apply_. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID
253278

3-networks-dual-svpc/envs/production/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The purpose of this step is to set up base and restricted shared VPCs with defau
2424
| perimeter\_additional\_members | The list of additional members to be added to the enforced perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:[email protected]` or `serviceAccount:[email protected]`. | `list(string)` | `[]` | no |
2525
| perimeter\_additional\_members\_dry\_run | The list of additional members to be added to the dry-run perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:[email protected]` or `serviceAccount:[email protected]`. | `list(string)` | `[]` | no |
2626
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
27+
| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones. | `list(map(any))` | `[]` | no |
2728
| tfc\_org\_name | Name of the TFC organization | `string` | `""` | no |
2829

2930
## Outputs

3-networks-dual-svpc/envs/production/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ module "base_env" {
9595
restricted_private_service_connect_ip = "10.17.0.7"
9696
remote_state_bucket = var.remote_state_bucket
9797
tfc_org_name = var.tfc_org_name
98+
target_name_server_addresses = var.target_name_server_addresses
9899
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../production.auto.tfvars

3-networks-dual-svpc/envs/production/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
variable "target_name_server_addresses" {
18+
description = "List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones."
19+
type = list(map(any))
20+
default = []
21+
}
22+
1723
variable "remote_state_bucket" {
1824
description = "Backend bucket to load Terraform Remote State Data from previous steps."
1925
type = string

3-networks-dual-svpc/envs/shared/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
## Outputs
2222

23-
No outputs.
23+
| Name | Description |
24+
|------|-------------|
25+
| base\_host\_project\_id | The base host project ID |
26+
| restricted\_host\_project\_id | The restricted host project ID |
2427

2528
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

3-networks-dual-svpc/envs/shared/outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17+
18+
output "restricted_host_project_id" {
19+
value = local.restricted_net_hub_project_id
20+
description = "The restricted host project ID"
21+
}
22+
23+
output "base_host_project_id" {
24+
value = local.base_net_hub_project_id
25+
description = "The base host project ID"
26+
}
27+

3-networks-dual-svpc/envs/shared/remote.tf

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
*/
1616

1717
locals {
18-
env = "common"
19-
environment_code = "c"
20-
dns_bgp_asn_number = var.bgp_asn_dns
21-
default_region1 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
22-
default_region2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
23-
folder_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.folder_prefix
24-
parent_id = data.terraform_remote_state.bootstrap.outputs.common_config.parent_id
25-
bootstrap_folder_name = data.terraform_remote_state.bootstrap.outputs.common_config.bootstrap_folder_name
26-
common_folder_name = data.terraform_remote_state.org.outputs.common_folder_name
27-
network_folder_name = data.terraform_remote_state.org.outputs.network_folder_name
28-
development_folder_name = data.terraform_remote_state.env_development.outputs.env_folder
29-
nonproduction_folder_name = data.terraform_remote_state.env_nonproduction.outputs.env_folder
30-
production_folder_name = data.terraform_remote_state.env_production.outputs.env_folder
18+
env = "common"
19+
environment_code = "c"
20+
dns_bgp_asn_number = var.bgp_asn_dns
21+
default_region1 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
22+
default_region2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
23+
folder_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.folder_prefix
24+
parent_id = data.terraform_remote_state.bootstrap.outputs.common_config.parent_id
25+
bootstrap_folder_name = data.terraform_remote_state.bootstrap.outputs.common_config.bootstrap_folder_name
26+
common_folder_name = data.terraform_remote_state.org.outputs.common_folder_name
27+
network_folder_name = data.terraform_remote_state.org.outputs.network_folder_name
28+
development_folder_name = data.terraform_remote_state.env_development.outputs.env_folder
29+
nonproduction_folder_name = data.terraform_remote_state.env_nonproduction.outputs.env_folder
30+
production_folder_name = data.terraform_remote_state.env_production.outputs.env_folder
31+
base_net_hub_project_id = data.terraform_remote_state.org.outputs.base_net_hub_project_id //
32+
restricted_net_hub_project_id = data.terraform_remote_state.org.outputs.restricted_net_hub_project_id //
3133
}
3234

3335
data "terraform_remote_state" "bootstrap" {

3-networks-dual-svpc/modules/base_env/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
|------|-------------|
4242
| access\_level\_name | Access context manager access level name for the enforced perimeter |
4343
| access\_level\_name\_dry\_run | Access context manager access level name for the dry-run perimeter |
44+
| base\_dns\_project\_id | The base DNS project ID |
4445
| base\_host\_project\_id | The base host project ID |
4546
| base\_network\_name | The name of the VPC being created |
4647
| base\_network\_self\_link | The URI of the VPC being created |
@@ -49,6 +50,7 @@
4950
| base\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
5051
| base\_subnets\_self\_links | The self-links of subnets being created |
5152
| enforce\_vpcsc | Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases. |
53+
| restricted\_dns\_project\_id | The restricted DNS project ID |
5254
| restricted\_host\_project\_id | The restricted host project ID |
5355
| restricted\_network\_name | The name of the VPC being created |
5456
| restricted\_network\_self\_link | The URI of the VPC being created |

3-networks-dual-svpc/modules/base_env/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ module "restricted_shared_vpc" {
171171

172172
project_id = local.restricted_project_id
173173
project_number = local.restricted_project_number
174-
production_project_id = local.production_restricted_project_id
174+
restricted_dns_project_id = local.restricted_dns_project_id
175175
environment_code = var.environment_code
176176
access_context_manager_policy_id = var.access_context_manager_policy_id
177177
restricted_services = local.restricted_services
@@ -265,7 +265,7 @@ module "base_shared_vpc" {
265265
source = "../base_shared_vpc"
266266

267267
project_id = local.base_project_id
268-
production_project_id = local.production_base_project_id
268+
base_dns_project_id = local.base_dns_project_id
269269
environment_code = var.environment_code
270270
private_service_cidr = var.base_private_service_cidr
271271
private_service_connect_ip = var.base_private_service_connect_ip

0 commit comments

Comments
 (0)