Skip to content

Commit e19a833

Browse files
authored
Allow updating Deployment Groups field in Custom Mirroring Security Profile. (#15908)
1 parent abfbd1c commit e19a833

File tree

2 files changed

+116
-1
lines changed

2 files changed

+116
-1
lines changed

mmv1/products/networksecurity/SecurityProfile.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ properties:
309309
This field is used for Packet Broker mirroring endpoint groups to specify
310310
the deployment groups that the packet should be mirrored to by the broker.
311311
Format: projects/{project_id}/locations/global/mirroringDeploymentGroups/{deployment_group_id}
312-
immutable: true
313312
min_version: 'beta'
314313
- name: 'mirroringEndpointGroupType'
315314
type: String

mmv1/third_party/terraform/services/networksecurity/resource_network_security_security_profile_test.go.tmpl

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,46 @@ func TestAccNetworkSecuritySecurityProfile_networkSecuritySecurityProfileUrlFilt
157157
},
158158
})
159159
}
160+
161+
func TestAccNetworkSecuritySecurityProfile_networkSecuritySecurityProfileMirroringBrokerUpdate(t *testing.T) {
162+
t.Parallel()
163+
164+
context := map[string]interface{}{
165+
"org_id": envvar.GetTestOrgFromEnv(t),
166+
"random_suffix": acctest.RandString(t, 10),
167+
}
168+
169+
acctest.VcrTest(t, resource.TestCase{
170+
PreCheck: func() { acctest.AccTestPreCheck(t) },
171+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
172+
CheckDestroy: testAccCheckNetworkSecuritySecurityProfileDestroyProducer(t),
173+
Steps: []resource.TestStep{
174+
{
175+
Config: testAccNetworkSecuritySecurityProfile_networkSecuritySecurityProfileMirroringBroker_basic(context),
176+
},
177+
{
178+
ResourceName: "google_network_security_security_profile.default",
179+
ImportState: true,
180+
ImportStateVerify: true,
181+
ImportStateVerifyIgnore: []string{"labels", "location", "name", "parent", "terraform_labels"},
182+
},
183+
{
184+
Config: testAccNetworkSecuritySecurityProfile_networkSecuritySecurityProfileMirroringBroker_update(context),
185+
ConfigPlanChecks: resource.ConfigPlanChecks{
186+
PreApply: []plancheck.PlanCheck{
187+
plancheck.ExpectResourceAction("google_network_security_security_profile.default", plancheck.ResourceActionUpdate),
188+
},
189+
},
190+
},
191+
{
192+
ResourceName: "google_network_security_security_profile.default",
193+
ImportState: true,
194+
ImportStateVerify: true,
195+
ImportStateVerifyIgnore: []string{"labels", "location", "name", "parent", "terraform_labels"},
196+
},
197+
},
198+
})
199+
}
160200
{{- end }}
161201

162202
func testAccNetworkSecuritySecurityProfiles_basic(orgId string, randomSuffix string) string {
@@ -329,4 +369,80 @@ resource "google_network_security_security_profile" "default" {
329369
}
330370
`, context)
331371
}
372+
373+
func testAccNetworkSecuritySecurityProfile_networkSecuritySecurityProfileMirroringBroker_basic(context map[string]interface{}) string {
374+
return acctest.Nprintf(`
375+
resource "google_compute_network" "default" {
376+
provider = google-beta
377+
name = "tf-test-my-network%{random_suffix}"
378+
auto_create_subnetworks = false
379+
}
380+
381+
resource "google_network_security_mirroring_deployment_group" "default" {
382+
provider = google-beta
383+
mirroring_deployment_group_id = "tf-test-my-dg%{random_suffix}"
384+
location = "global"
385+
network = google_compute_network.default.id
386+
}
387+
388+
resource "google_network_security_mirroring_endpoint_group" "default" {
389+
provider = google-beta
390+
mirroring_endpoint_group_id = "tf-test-my-eg%{random_suffix}"
391+
location = "global"
392+
type = "BROKER"
393+
mirroring_deployment_groups = [google_network_security_mirroring_deployment_group.default.id]
394+
}
395+
396+
resource "google_network_security_security_profile" "default" {
397+
provider = google-beta
398+
name = "tf-test-my-security-profile%{random_suffix}"
399+
parent = "organizations/%{org_id}"
400+
description = "my description"
401+
type = "CUSTOM_MIRRORING"
402+
403+
custom_mirroring_profile {
404+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.default.id
405+
mirroring_deployment_groups = [google_network_security_mirroring_deployment_group.default.id]
406+
}
407+
}
408+
`, context)
409+
}
410+
411+
func testAccNetworkSecuritySecurityProfile_networkSecuritySecurityProfileMirroringBroker_update(context map[string]interface{}) string {
412+
return acctest.Nprintf(`
413+
resource "google_compute_network" "default" {
414+
provider = google-beta
415+
name = "tf-test-my-network%{random_suffix}"
416+
auto_create_subnetworks = false
417+
}
418+
419+
resource "google_network_security_mirroring_deployment_group" "default" {
420+
provider = google-beta
421+
mirroring_deployment_group_id = "tf-test-my-dg%{random_suffix}"
422+
location = "global"
423+
network = google_compute_network.default.id
424+
}
425+
426+
resource "google_network_security_mirroring_endpoint_group" "default" {
427+
provider = google-beta
428+
mirroring_endpoint_group_id = "tf-test-my-eg%{random_suffix}"
429+
location = "global"
430+
type = "BROKER"
431+
mirroring_deployment_groups = [google_network_security_mirroring_deployment_group.default.id]
432+
}
433+
434+
resource "google_network_security_security_profile" "default" {
435+
provider = google-beta
436+
name = "tf-test-my-security-profile%{random_suffix}"
437+
parent = "organizations/%{org_id}"
438+
description = "my description"
439+
type = "CUSTOM_MIRRORING"
440+
441+
custom_mirroring_profile {
442+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.default.id
443+
mirroring_deployment_groups = []
444+
}
445+
}
446+
`, context)
447+
}
332448
{{- end }}

0 commit comments

Comments
 (0)