|
| 1 | +<% autogen_exception -%> |
1 | 2 | package compute_test
|
2 | 3 |
|
3 | 4 | import (
|
@@ -50,6 +51,54 @@ func TestAccComputeServiceAttachment_serviceAttachmentBasicExampleUpdate(t *test
|
50 | 51 | })
|
51 | 52 | }
|
52 | 53 |
|
| 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 | + |
53 | 102 | func testAccComputeServiceAttachment_serviceAttachmentBasicExampleFork(context map[string]interface{}) string {
|
54 | 103 | return acctest.Nprintf(`
|
55 | 104 | resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
|
@@ -232,6 +281,118 @@ resource "google_compute_subnetwork" "psc_ilb_nat" {
|
232 | 281 | `, context)
|
233 | 282 | }
|
234 | 283 |
|
| 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 | + |
235 | 396 | func TestAccComputeServiceAttachment_serviceAttachmentBasicExampleGateway(t *testing.T) {
|
236 | 397 | t.Parallel()
|
237 | 398 |
|
|
0 commit comments