|
| 1 | +package networksecurity_test |
| 2 | +{{- if ne $.TargetVersionName "ga" }} |
| 3 | + |
| 4 | +import ( |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 8 | + "github.com/hashicorp/terraform-plugin-testing/plancheck" |
| 9 | + |
| 10 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 11 | +) |
| 12 | + |
| 13 | +func TestAccNetworkSecurityInterceptEndpointGroupAssociation_update(t *testing.T) { |
| 14 | + t.Parallel() |
| 15 | + |
| 16 | + context := map[string]interface{}{ |
| 17 | + "random_suffix": acctest.RandString(t, 10), |
| 18 | + } |
| 19 | + |
| 20 | + acctest.VcrTest(t, resource.TestCase{ |
| 21 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 22 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), |
| 23 | + Steps: []resource.TestStep{ |
| 24 | + { |
| 25 | + Config: testAccNetworkSecurityInterceptEndpointGroupAssociation_basic(context), |
| 26 | + }, |
| 27 | + { |
| 28 | + ResourceName: "google_network_security_intercept_endpoint_group_association.default", |
| 29 | + ImportState: true, |
| 30 | + ImportStateVerify: true, |
| 31 | + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, |
| 32 | + }, |
| 33 | + { |
| 34 | + Config: testAccNetworkSecurityInterceptEndpointGroupAssociation_update(context), |
| 35 | + ConfigPlanChecks: resource.ConfigPlanChecks{ |
| 36 | + PreApply: []plancheck.PlanCheck{ |
| 37 | + plancheck.ExpectResourceAction("google_network_security_intercept_endpoint_group_association.default", plancheck.ResourceActionUpdate), |
| 38 | + }, |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + ResourceName: "google_network_security_intercept_endpoint_group_association.default", |
| 43 | + ImportState: true, |
| 44 | + ImportStateVerify: true, |
| 45 | + ImportStateVerifyIgnore: []string{"update_time", "labels", "terraform_labels"}, |
| 46 | + }, |
| 47 | + }, |
| 48 | + }) |
| 49 | +} |
| 50 | + |
| 51 | +func testAccNetworkSecurityInterceptEndpointGroupAssociation_basic(context map[string]interface{}) string { |
| 52 | + return acctest.Nprintf(` |
| 53 | +resource "google_compute_network" "producer_network" { |
| 54 | + provider = google-beta |
| 55 | + name = "tf-test-example-prod-network%{random_suffix}" |
| 56 | + auto_create_subnetworks = false |
| 57 | +} |
| 58 | + |
| 59 | +resource "google_compute_network" "consumer_network" { |
| 60 | + provider = google-beta |
| 61 | + name = "tf-test-example-cons-network%{random_suffix}" |
| 62 | + auto_create_subnetworks = false |
| 63 | +} |
| 64 | + |
| 65 | +resource "google_network_security_intercept_deployment_group" "deployment_group" { |
| 66 | + provider = google-beta |
| 67 | + intercept_deployment_group_id = "tf-test-example-dg%{random_suffix}" |
| 68 | + location = "global" |
| 69 | + network = google_compute_network.producer_network.id |
| 70 | +} |
| 71 | + |
| 72 | +resource "google_network_security_intercept_endpoint_group" "endpoint_group" { |
| 73 | + provider = google-beta |
| 74 | + intercept_endpoint_group_id = "tf-test-example-eg%{random_suffix}" |
| 75 | + location = "global" |
| 76 | + intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id |
| 77 | +} |
| 78 | + |
| 79 | +resource "google_network_security_intercept_endpoint_group_association" "default" { |
| 80 | + provider = google-beta |
| 81 | + intercept_endpoint_group_association_id = "tf-test-example-ega%{random_suffix}" |
| 82 | + location = "global" |
| 83 | + network = google_compute_network.consumer_network.id |
| 84 | + intercept_endpoint_group = google_network_security_intercept_endpoint_group.endpoint_group.id |
| 85 | + labels = { |
| 86 | + foo = "bar" |
| 87 | + } |
| 88 | +} |
| 89 | +`, context) |
| 90 | +} |
| 91 | + |
| 92 | +func testAccNetworkSecurityInterceptEndpointGroupAssociation_update(context map[string]interface{}) string { |
| 93 | + return acctest.Nprintf(` |
| 94 | +resource "google_compute_network" "producer_network" { |
| 95 | + provider = google-beta |
| 96 | + name = "tf-test-example-prod-network%{random_suffix}" |
| 97 | + auto_create_subnetworks = false |
| 98 | +} |
| 99 | + |
| 100 | +resource "google_compute_network" "consumer_network" { |
| 101 | + provider = google-beta |
| 102 | + name = "tf-test-example-cons-network%{random_suffix}" |
| 103 | + auto_create_subnetworks = false |
| 104 | +} |
| 105 | + |
| 106 | +resource "google_network_security_intercept_deployment_group" "deployment_group" { |
| 107 | + provider = google-beta |
| 108 | + intercept_deployment_group_id = "tf-test-example-dg%{random_suffix}" |
| 109 | + location = "global" |
| 110 | + network = google_compute_network.producer_network.id |
| 111 | +} |
| 112 | + |
| 113 | +resource "google_network_security_intercept_endpoint_group" "endpoint_group" { |
| 114 | + provider = google-beta |
| 115 | + intercept_endpoint_group_id = "tf-test-example-eg%{random_suffix}" |
| 116 | + location = "global" |
| 117 | + intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id |
| 118 | +} |
| 119 | + |
| 120 | +resource "google_network_security_intercept_endpoint_group_association" "default" { |
| 121 | + provider = google-beta |
| 122 | + intercept_endpoint_group_association_id = "tf-test-example-ega%{random_suffix}" |
| 123 | + location = "global" |
| 124 | + network = google_compute_network.consumer_network.id |
| 125 | + intercept_endpoint_group = google_network_security_intercept_endpoint_group.endpoint_group.id |
| 126 | + labels = { |
| 127 | + foo = "goo" |
| 128 | + } |
| 129 | +} |
| 130 | +`, context) |
| 131 | +} |
| 132 | + |
| 133 | +{{ end }} |
0 commit comments