forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add service attachment roncile connections (GoogleCloudPlatform#8164)
- Loading branch information
1 parent
da577c0
commit c355525
Showing
2 changed files
with
95 additions
and
0 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
70 changes: 70 additions & 0 deletions
70
mmv1/templates/terraform/examples/service_attachment_reconcile_connections.tf.erb
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,70 @@ | ||
resource "google_compute_service_attachment" "<%= ctx[:primary_resource_id] %>" { | ||
name = "<%= ctx[:vars]['service_attachment_name'] %>" | ||
region = "us-west2" | ||
description = "A service attachment configured with Terraform" | ||
|
||
domain_names = ["gcp.tfacc.hashicorptest.com."] | ||
enable_proxy_protocol = true | ||
connection_preference = "ACCEPT_MANUAL" | ||
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id] | ||
target_service = google_compute_forwarding_rule.psc_ilb_target_service.id | ||
|
||
consumer_reject_lists = ["673497134629", "482878270665"] | ||
|
||
consumer_accept_lists { | ||
project_id_or_num = "658859330310" | ||
connection_limit = 4 | ||
} | ||
|
||
reconcile_connections = false | ||
} | ||
|
||
resource "google_compute_forwarding_rule" "psc_ilb_target_service" { | ||
name = "<%= ctx[:vars]['producer_forwarding_rule_name'] %>" | ||
region = "us-west2" | ||
|
||
load_balancing_scheme = "INTERNAL" | ||
backend_service = google_compute_region_backend_service.producer_service_backend.id | ||
all_ports = true | ||
network = google_compute_network.psc_ilb_network.name | ||
subnetwork = google_compute_subnetwork.psc_ilb_producer_subnetwork.name | ||
} | ||
|
||
resource "google_compute_region_backend_service" "producer_service_backend" { | ||
name = "<%= ctx[:vars]['producer_service_name'] %>" | ||
region = "us-west2" | ||
|
||
health_checks = [google_compute_health_check.producer_service_health_check.id] | ||
} | ||
|
||
resource "google_compute_health_check" "producer_service_health_check" { | ||
name = "<%= ctx[:vars]['producer_health_check_name'] %>" | ||
|
||
check_interval_sec = 1 | ||
timeout_sec = 1 | ||
tcp_health_check { | ||
port = "80" | ||
} | ||
} | ||
|
||
resource "google_compute_network" "psc_ilb_network" { | ||
name = "<%= ctx[:vars]['network_name'] %>" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" { | ||
name = "<%= ctx[:vars]['producer_subnetwork_name'] %>" | ||
region = "us-west2" | ||
|
||
network = google_compute_network.psc_ilb_network.id | ||
ip_cidr_range = "10.0.0.0/16" | ||
} | ||
|
||
resource "google_compute_subnetwork" "psc_ilb_nat" { | ||
name = "<%= ctx[:vars]['nat_subnetwork_name'] %>" | ||
region = "us-west2" | ||
|
||
network = google_compute_network.psc_ilb_network.id | ||
purpose = "PRIVATE_SERVICE_CONNECT" | ||
ip_cidr_range = "10.1.0.0/16" | ||
} |