Skip to content

Commit 2094dcd

Browse files
Added propagatedConnectionLimit and connectedEndpoints output fields to ServiceAttachment (#11625)
1 parent 8316d60 commit 2094dcd

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

mmv1/products/compute/ServiceAttachment.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@ properties:
156156
description: |
157157
The status of the connection from the consumer forwarding rule to
158158
this service attachment.
159+
- !ruby/object:Api::Type::String
160+
name: 'consumerNetwork'
161+
output: true
162+
description: |
163+
The url of the consumer network.
164+
- !ruby/object:Api::Type::String
165+
name: 'pscConnectionId'
166+
output: true
167+
description: |
168+
The PSC connection id of the connected endpoint.
169+
- !ruby/object:Api::Type::Integer
170+
name: 'propagatedConnectionCount'
171+
min_version: 'beta'
172+
output: true
173+
description: |
174+
The number of consumer Network Connectivity Center spokes that the connected Private Service Connect endpoint has propagated to.
159175
- !ruby/object:Api::Type::String
160176
name: targetService
161177
required: true
@@ -237,3 +253,15 @@ properties:
237253
238254
If false, connection policy update will only affect existing PENDING PSC endpoints. Existing ACCEPTED/REJECTED endpoints will remain untouched regardless how the connection policy is modified .
239255
If true, update will affect both PENDING and ACCEPTED/REJECTED PSC endpoints. For example, an ACCEPTED PSC endpoint will be moved to REJECTED if its project is added to the reject list.
256+
- !ruby/object:Api::Type::Integer
257+
name: 'propagatedConnectionLimit'
258+
min_version: 'beta'
259+
default_from_api: true
260+
description: |
261+
The number of consumer spokes that connected Private Service Connect endpoints can be propagated to through Network Connectivity Center.
262+
This limit lets the service producer limit how many propagated Private Service Connect connections can be established to this service attachment from a single consumer.
263+
264+
If the connection preference of the service attachment is ACCEPT_MANUAL, the limit applies to each project or network that is listed in the consumer accept list.
265+
If the connection preference of the service attachment is ACCEPT_AUTOMATIC, the limit applies to each project that contains a connected endpoint.
266+
267+
If unspecified, the default propagated connection limit is 250.

mmv1/third_party/terraform/services/compute/resource_compute_service_attachment_test.go renamed to mmv1/third_party/terraform/services/compute/resource_compute_service_attachment_test.go.erb

+161
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<% autogen_exception -%>
12
package compute_test
23

34
import (
@@ -50,6 +51,54 @@ func TestAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(t *test
5051
})
5152
}
5253

54+
<% unless version == "ga" -%>
55+
func TestAccComputeServiceAttachment_serviceAttachmentConnectedEndpointsOutput(t *testing.T) {
56+
t.Parallel()
57+
58+
context := map[string]interface{}{
59+
"random_suffix": acctest.RandString(t, 10),
60+
}
61+
62+
acctest.VcrTest(t, resource.TestCase{
63+
PreCheck: func() { acctest.AccTestPreCheck(t) },
64+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
65+
CheckDestroy: testAccCheckComputeServiceAttachmentDestroyProducer(t),
66+
Steps: []resource.TestStep{
67+
{
68+
Config: testAccComputeServiceAttachment_serviceAttachmentBasicExampleConnectedEndpointsOutput(context, true),
69+
},
70+
{
71+
ResourceName: "google_compute_service_attachment.psc_ilb_service_attachment",
72+
ImportState: true,
73+
ImportStateVerify: true,
74+
ImportStateVerifyIgnore: []string{"target_service", "region"},
75+
},
76+
{
77+
Config: testAccComputeServiceAttachment_serviceAttachmentBasicExampleConnectedEndpointsOutput(context, false),
78+
Check: resource.ComposeTestCheckFunc(
79+
resource.TestCheckResourceAttrSet(
80+
"google_compute_service_attachment.psc_ilb_service_attachment", "connected_endpoints.0.endpoint"),
81+
resource.TestCheckResourceAttrSet(
82+
"google_compute_service_attachment.psc_ilb_service_attachment", "connected_endpoints.0.status"),
83+
resource.TestCheckResourceAttrSet(
84+
"google_compute_service_attachment.psc_ilb_service_attachment", "connected_endpoints.0.consumer_network"),
85+
resource.TestCheckResourceAttrSet(
86+
"google_compute_service_attachment.psc_ilb_service_attachment", "connected_endpoints.0.psc_connection_id"),
87+
resource.TestCheckResourceAttrSet(
88+
"google_compute_service_attachment.psc_ilb_service_attachment", "connected_endpoints.0.propagated_connection_count"),
89+
),
90+
},
91+
{
92+
ResourceName: "google_compute_service_attachment.psc_ilb_service_attachment",
93+
ImportState: true,
94+
ImportStateVerify: true,
95+
ImportStateVerifyIgnore: []string{"target_service", "region"},
96+
},
97+
},
98+
})
99+
}
100+
<% end -%>
101+
53102
func testAccComputeServiceAttachment_serviceAttachmentBasicExampleFork(context map[string]interface{}) string {
54103
return acctest.Nprintf(`
55104
resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
@@ -232,6 +281,118 @@ resource "google_compute_subnetwork" "psc_ilb_nat" {
232281
`, context)
233282
}
234283

284+
<% unless version == "ga" -%>
285+
func testAccComputeServiceAttachment_serviceAttachmentBasicExampleConnectedEndpointsOutput(context map[string]interface{}, preventDestroy bool) string {
286+
context["lifecycle_block"] = ""
287+
if preventDestroy {
288+
context["lifecycle_block"] = `
289+
lifecycle {
290+
prevent_destroy = true
291+
}`
292+
}
293+
294+
return acctest.Nprintf(`
295+
resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
296+
provider = google-beta
297+
name = "tf-test-my-psc-ilb%{random_suffix}"
298+
region = "us-west2"
299+
description = "A service attachment configured with Terraforms"
300+
301+
enable_proxy_protocol = true
302+
connection_preference = "ACCEPT_MANUAL"
303+
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
304+
target_service = google_compute_forwarding_rule.psc_ilb_target_service.id
305+
306+
consumer_reject_lists = ["673497134629", "482878270665"]
307+
consumer_accept_lists {
308+
project_id_or_num = "658859330310"
309+
connection_limit = 4
310+
}
311+
312+
propagated_connection_limit = 175
313+
reconcile_connections = false
314+
}
315+
316+
resource "google_compute_address" "psc_ilb_consumer_address" {
317+
provider = google-beta
318+
name = "tf-test-psc-ilb-consumer-address%{random_suffix}"
319+
region = "us-west2"
320+
321+
subnetwork = "default"
322+
address_type = "INTERNAL"
323+
}
324+
325+
resource "google_compute_forwarding_rule" "psc_ilb_consumer" {
326+
provider = google-beta
327+
name = "tf-test-psc-ilb-consumer-forwarding-rule%{random_suffix}"
328+
region = "us-west2"
329+
330+
target = google_compute_service_attachment.psc_ilb_service_attachment.id
331+
load_balancing_scheme = "" # need to override EXTERNAL default when target is a service attachment
332+
network = "default"
333+
ip_address = google_compute_address.psc_ilb_consumer_address.id
334+
}
335+
336+
resource "google_compute_forwarding_rule" "psc_ilb_target_service" {
337+
provider = google-beta
338+
name = "tf-test-producer-forwarding-rule%{random_suffix}"
339+
region = "us-west2"
340+
341+
load_balancing_scheme = "INTERNAL"
342+
backend_service = google_compute_region_backend_service.producer_service_backend.id
343+
all_ports = true
344+
allow_global_access = true
345+
network = google_compute_network.psc_ilb_network.name
346+
subnetwork = google_compute_subnetwork.psc_ilb_producer_subnetwork.name
347+
}
348+
349+
resource "google_compute_region_backend_service" "producer_service_backend" {
350+
provider = google-beta
351+
name = "tf-test-producer-service%{random_suffix}"
352+
region = "us-west2"
353+
354+
health_checks = [google_compute_health_check.producer_service_health_check.id]
355+
}
356+
357+
resource "google_compute_health_check" "producer_service_health_check" {
358+
provider = google-beta
359+
name = "tf-test-producer-service-health-check%{random_suffix}"
360+
361+
check_interval_sec = 1
362+
timeout_sec = 1
363+
tcp_health_check {
364+
port = "80"
365+
}
366+
}
367+
368+
resource "google_compute_network" "psc_ilb_network" {
369+
provider = google-beta
370+
name = "tf-test-psc-ilb-network%{random_suffix}"
371+
auto_create_subnetworks = false
372+
}
373+
374+
resource "google_compute_subnetwork" "psc_ilb_producer_subnetwork" {
375+
provider = google-beta
376+
name = "tf-test-psc-ilb-producer-subnetwork%{random_suffix}"
377+
region = "us-west2"
378+
379+
network = google_compute_network.psc_ilb_network.id
380+
ip_cidr_range = "10.0.0.0/16"
381+
}
382+
383+
resource "google_compute_subnetwork" "psc_ilb_nat" {
384+
provider = google-beta
385+
name = "tf-test-psc-ilb-nat%{random_suffix}"
386+
region = "us-west2"
387+
388+
network = google_compute_network.psc_ilb_network.id
389+
purpose = "PRIVATE_SERVICE_CONNECT"
390+
ip_cidr_range = "10.1.0.0/16"
391+
}
392+
`, context)
393+
}
394+
<% end -%>
395+
235396
func TestAccComputeServiceAttachment_serviceAttachmentBasicExampleGateway(t *testing.T) {
236397
t.Parallel()
237398

0 commit comments

Comments
 (0)