1919 *****************************************/
2020
2121module "main" {
22- source = " terraform-google-modules/network/google"
23- version = " ~> 2.0"
24- project_id = var. project_id
25- network_name = var. network_name
26- shared_vpc_host = " true"
22+ source = " terraform-google-modules/network/google"
23+ version = " ~> 2.0"
24+ project_id = var. project_id
25+ network_name = var. network_name
26+ shared_vpc_host = " true"
27+ delete_default_internet_gateway_routes = " true"
2728
2829 subnets = var. subnets
2930 secondary_ranges = var. secondary_ranges
3031
3132 routes = [
3233 {
33- name = " gcp-windows-activation"
34- description = " Route through IGW to allow Windows kms activation."
34+ name = " egress-internet"
35+ description = " Tag based route through IGW to access internet"
36+ destination_range = " 0.0.0.0/0"
37+ tags = " egress-internet"
38+ next_hop_internet = " true"
39+ },
40+ {
41+ name = " private-google-access"
42+ description = " Route through IGW to allow private google api access."
43+ destination_range = " 199.36.153.8/30"
44+ next_hop_internet = " true"
45+ },
46+ {
47+ name = " windows-activation"
48+ description = " Route through IGW to allow Windows KMS activation for GCP."
3549 destination_range = " 35.190.247.13/32"
3650 next_hop_internet = " true"
3751 },
3852 ]
3953}
4054
41- /* *****************************************
42- Default DNS Policy
43- *****************************************/
44-
45- resource "google_dns_policy" "default_policy" {
46- provider = google- beta
47- project = var. project_id
48- name = " default-policy"
49- enable_inbound_forwarding = true
50- enable_logging = true
51- networks {
52- network_url = module. main . network_self_link
53- }
54- }
55-
56-
5755/* **************************************************************
5856 Configure Service Networking for Cloud SQL & future services.
5957 **************************************************************/
@@ -93,7 +91,7 @@ resource "google_compute_router" "default_router" {
9391}
9492
9593resource "google_compute_address" "nat_external_addresses" {
96- count = 2
94+ count = var . nat_num_addresses
9795 project = var. project_id
9896 name = " nat-external-address-${ count . index } "
9997 region = var. default_region
@@ -113,59 +111,3 @@ resource "google_compute_router_nat" "default_nat" {
113111 enable = true
114112 }
115113}
116-
117- /* *****************************************
118- Default firewall rules
119- *****************************************/
120-
121-
122- // Allow SSH when using the allow-ssh tag for Linux workloads.
123- resource "google_compute_firewall" "allow_ssh" {
124- name = " allow-ssh"
125- network = module. main . network_name
126- project = var. project_id
127-
128- // Cloud IAP's TCP forwarding netblock
129- source_ranges = concat (data. google_netblock_ip_ranges . iap_forwarders . cidr_blocks_ipv4 )
130-
131- allow {
132- protocol = " tcp"
133- ports = [" 22" ]
134- }
135-
136- target_tags = [" allow-ssh" ]
137- }
138-
139- // Allow RDP when using the allow-rdp tag for Windows workloads.
140- resource "google_compute_firewall" "allow_rdp" {
141- name = " allow-rdp"
142- network = module. main . network_name
143- project = var. project_id
144-
145- // Cloud IAP's TCP forwarding netblock
146- source_ranges = concat (data. google_netblock_ip_ranges . iap_forwarders . cidr_blocks_ipv4 )
147-
148- allow {
149- protocol = " tcp"
150- ports = [" 3389" ]
151- }
152-
153- target_tags = [" allow-rdp" ]
154- }
155-
156- // Allow traffic for Internal & Global load balancing health check and load balancing IP ranges.
157- resource "google_compute_firewall" "allow_lb" {
158- name = " lb-healthcheck"
159- network = module. main . network_name
160- project = var. project_id
161-
162- source_ranges = concat (data. google_netblock_ip_ranges . health_checkers . cidr_blocks_ipv4 , data. google_netblock_ip_ranges . legacy_health_checkers . cidr_blocks_ipv4 )
163-
164- // Allow common app ports by default.
165- allow {
166- protocol = " tcp"
167- ports = [" 80" , " 8080" , " 443" ]
168- }
169-
170- target_tags = [" allow-lb" ]
171- }
0 commit comments