-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0836853
commit b5b41e5
Showing
49 changed files
with
900 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
examples/security-policy-edge/README.md → ...ackend-security-policy-complete/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Copyright 2024 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. | ||
*/ | ||
|
||
# # ############## Healthcheck | ||
|
||
resource "google_compute_http_health_check" "default" { | ||
provider = google-beta | ||
project = var.project_id | ||
|
||
name = "glb-ca-health-check" | ||
check_interval_sec = 5 | ||
timeout_sec = 3 | ||
} | ||
|
||
resource "google_compute_backend_service" "backend_service" { | ||
provider = google-beta | ||
|
||
project = var.project_id | ||
|
||
name = "glb-ca-web-backend-svc-a" | ||
port_name = "http" | ||
protocol = "HTTP" | ||
timeout_sec = 10 | ||
|
||
backend { | ||
group = google_compute_instance_group.ca_vm_1_ig.self_link | ||
max_utilization = 0.5 | ||
} | ||
|
||
health_checks = [google_compute_http_health_check.default.id] | ||
load_balancing_scheme = "EXTERNAL" | ||
|
||
## Attach Cloud Armor policy to the backend service | ||
security_policy = module.cloud_armor.policy.self_link | ||
} | ||
|
||
resource "google_compute_url_map" "default" { | ||
provider = google-beta | ||
|
||
project = var.project_id | ||
name = "glb-ca-https" | ||
description = "global ca url map" | ||
|
||
default_service = google_compute_backend_service.backend_service.id | ||
} | ||
|
||
resource "google_compute_target_http_proxy" "http_glb_proxy" { | ||
name = "glb-ca-http-proxy" | ||
url_map = google_compute_url_map.default.id | ||
project = var.project_id | ||
} | ||
|
||
resource "google_compute_global_address" "glb_external_address" { | ||
name = "glb-ca-http-global-ip" | ||
project = var.project_id | ||
} | ||
|
||
|
||
resource "google_compute_global_forwarding_rule" "glb_forwarding_rule" { | ||
name = "glb-ca-http-global-fr" | ||
target = google_compute_target_http_proxy.http_glb_proxy.self_link | ||
ip_address = google_compute_global_address.glb_external_address.address | ||
port_range = "80" | ||
project = var.project_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
examples/global-backend-security-policy-complete/network.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/** | ||
* Copyright 2024 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 { | ||
network_name = "test-global-ca" | ||
rfc1918_cidr_ranges = ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", ] | ||
} | ||
|
||
/****************************************** | ||
Ranges for default firewall rules. | ||
*****************************************/ | ||
|
||
data "google_netblock_ip_ranges" "legacy_health_checkers" { | ||
range_type = "legacy-health-checkers" | ||
} | ||
|
||
data "google_netblock_ip_ranges" "health_checkers" { | ||
range_type = "health-checkers" | ||
} | ||
|
||
data "google_netblock_ip_ranges" "iap_forwarders" { | ||
range_type = "iap-forwarders" | ||
} | ||
|
||
|
||
module "test_vpc" { | ||
source = "terraform-google-modules/network/google" | ||
version = "~> 9.0" | ||
project_id = var.project_id | ||
network_name = local.network_name | ||
|
||
subnets = [ | ||
{ | ||
subnet_name = "subnet-100" | ||
subnet_ip = "10.10.100.0/24" | ||
subnet_region = local.primary_region | ||
}, | ||
{ | ||
subnet_name = "subnet-200" | ||
subnet_ip = "10.10.200.0/24" | ||
subnet_region = local.secondary_region | ||
}, | ||
] | ||
} | ||
|
||
module "net_firewall" { | ||
source = "terraform-google-modules/network/google//modules/fabric-net-firewall" | ||
version = "~> 9.0" | ||
project_id = module.test_vpc.project_id | ||
network = module.test_vpc.network_name | ||
ssh_source_ranges = [] | ||
http_source_ranges = [] | ||
https_source_ranges = [] | ||
internal_ranges_enabled = true | ||
internal_ranges = local.rfc1918_cidr_ranges | ||
internal_allow = [ | ||
{ | ||
protocol = "all" | ||
}, | ||
] | ||
custom_rules = { | ||
ca-allow-ssh-from-iap = { | ||
description = "Allow SSH access from IAP tunnel" | ||
direction = "INGRESS" | ||
action = "allow" | ||
ranges = data.google_netblock_ip_ranges.iap_forwarders.cidr_blocks_ipv4 | ||
sources = [] | ||
targets = [] | ||
use_service_accounts = false | ||
rules = [ | ||
{ | ||
protocol = "tcp" | ||
ports = [22] | ||
}, | ||
] | ||
extra_attributes = {} | ||
} | ||
ca-allow-rdp-from-iap = { | ||
description = "Allow RDP access from IAP tunnel" | ||
direction = "INGRESS" | ||
action = "allow" | ||
ranges = data.google_netblock_ip_ranges.iap_forwarders.cidr_blocks_ipv4 | ||
sources = [] | ||
targets = [] | ||
use_service_accounts = false | ||
rules = [ | ||
{ | ||
protocol = "tcp" | ||
ports = [3389] | ||
}, | ||
{ | ||
protocol = "udp" | ||
ports = [3389] | ||
}, | ||
] | ||
extra_attributes = {} | ||
} | ||
ca-allow-lb-healthcheck = { | ||
description = "Allow Load balancer health check to all backends" | ||
direction = "INGRESS" | ||
action = "allow" | ||
ranges = concat(data.google_netblock_ip_ranges.health_checkers.cidr_blocks_ipv4, data.google_netblock_ip_ranges.legacy_health_checkers.cidr_blocks_ipv4) | ||
sources = [] | ||
targets = [] | ||
use_service_accounts = false | ||
rules = [ | ||
{ | ||
protocol = "tcp" | ||
ports = [] | ||
}, | ||
] | ||
extra_attributes = {} | ||
} | ||
} | ||
} | ||
|
||
module "cloud_router" { | ||
source = "terraform-google-modules/cloud-router/google" | ||
version = "~> 6.0" | ||
|
||
name = "test-ca-${local.primary_region}-cr" | ||
project = module.test_vpc.project_id | ||
region = local.primary_region | ||
network = module.test_vpc.network_self_link | ||
nats = [{ | ||
name = "test-ca-${local.primary_region}-nat" | ||
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES" | ||
min_ports_per_vm = 4096 | ||
log_config = { | ||
"filter" = "ERRORS_ONLY" | ||
} | ||
}, | ||
] | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.