Skip to content

Commit acac7dd

Browse files
authored
Add Mirroring Endpoint resource to Network Security. (#15457)
1 parent fd6dbb9 commit acac7dd

File tree

3 files changed

+285
-0
lines changed

3 files changed

+285
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'MirroringEndpoint'
16+
description: |-
17+
An endpoint is a managed mirroring collector that provides enhanced packet
18+
enrichment capabilities and support for multiple replica destinations.
19+
Endpoints are always part of a global endpoint group which represents a
20+
global "mirroring broker" service.
21+
min_version: 'beta'
22+
id_format: 'projects/{{project}}/locations/{{location}}/mirroringEndpoints/{{mirroring_endpoint_id}}'
23+
base_url: 'projects/{{project}}/locations/{{location}}/mirroringEndpoints'
24+
self_link: 'projects/{{project}}/locations/{{location}}/mirroringEndpoints/{{mirroring_endpoint_id}}'
25+
create_url: 'projects/{{project}}/locations/{{location}}/mirroringEndpoints?mirroringEndpointId={{mirroring_endpoint_id}}'
26+
update_verb: 'PATCH'
27+
update_mask: true
28+
import_format:
29+
- 'projects/{{project}}/locations/{{location}}/mirroringEndpoints/{{mirroring_endpoint_id}}'
30+
autogen_async: true
31+
async:
32+
actions: ['create', 'delete', 'update']
33+
type: 'OpAsync'
34+
operation:
35+
base_url: '{{op_id}}'
36+
result:
37+
resource_inside_response: true
38+
custom_code:
39+
examples:
40+
- name: 'network_security_mirroring_endpoint_basic'
41+
config_path: 'templates/terraform/examples/network_security_mirroring_endpoint_basic.tf.tmpl'
42+
primary_resource_id: 'default'
43+
vars:
44+
network_name: 'example-network'
45+
deployment_group_id: 'example-dg'
46+
endpoint_group_id: 'example-eg'
47+
endpoint_id: 'example-endpoint'
48+
parameters:
49+
- name: 'location'
50+
type: String
51+
description: |-
52+
The cloud location of the endpoint, e.g. `us-central1-a` or `asia-south1-b`.
53+
url_param_only: true
54+
required: true
55+
immutable: true
56+
- name: 'mirroringEndpointId'
57+
type: String
58+
description: |-
59+
The ID to use for the new endpoint, which will become the final
60+
component of the endpoint's resource name.
61+
min_version: 'beta'
62+
url_param_only: true
63+
required: true
64+
immutable: true
65+
properties:
66+
- name: 'name'
67+
type: String
68+
description: |-
69+
The resource name of this endpoint, for example:
70+
`projects/123456789/locations/us-central1-a/mirroringEndpoints/my-endpoint`.
71+
See https://google.aip.dev/122 for more details.
72+
min_version: 'beta'
73+
immutable: true
74+
output: true
75+
- name: 'createTime'
76+
type: String
77+
description: |-
78+
The timestamp when the resource was created.
79+
See https://google.aip.dev/148#timestamps.
80+
min_version: 'beta'
81+
output: true
82+
- name: 'updateTime'
83+
type: String
84+
description: |-
85+
The timestamp when the resource was most recently updated.
86+
See https://google.aip.dev/148#timestamps.
87+
min_version: 'beta'
88+
output: true
89+
- name: 'labels'
90+
type: KeyValueLabels
91+
description: |-
92+
Labels are key/value pairs that help to organize and filter resources.
93+
min_version: 'beta'
94+
- name: 'mirroringEndpointGroup'
95+
type: String
96+
description: |-
97+
The endpoint group that this endpoint belongs to.
98+
Format is:
99+
`projects/{project}/locations/{location}/mirroringEndpointGroups/{mirroringEndpointGroup}`
100+
min_version: 'beta'
101+
required: true
102+
immutable: true
103+
- name: 'state'
104+
type: String
105+
description: |-
106+
The current state of the endpoint.
107+
See https://google.aip.dev/216.
108+
Possible values:
109+
STATE_UNSPECIFIED
110+
CREATING
111+
ACTIVE
112+
DELETING
113+
DELETE_FAILED
114+
OUT_OF_SYNC
115+
min_version: 'beta'
116+
output: true
117+
- name: 'reconciling'
118+
type: Boolean
119+
description: |-
120+
The current state of the resource does not match the user's intended state,
121+
and the system is working to reconcile them. This part of the normal
122+
operation (e.g. linking a new association to the parent group).
123+
See https://google.aip.dev/128.
124+
min_version: 'beta'
125+
output: true
126+
- name: 'description'
127+
type: String
128+
description: |-
129+
User-provided description of the endpoint.
130+
Used as additional context for the endpoint.
131+
min_version: 'beta'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
resource "google_compute_network" "network" {
2+
provider = google-beta
3+
name = "{{index $.Vars "network_name"}}"
4+
auto_create_subnetworks = false
5+
}
6+
7+
resource "google_network_security_mirroring_deployment_group" "deployment_group" {
8+
provider = google-beta
9+
mirroring_deployment_group_id = "{{index $.Vars "deployment_group_id"}}"
10+
location = "global"
11+
network = google_compute_network.network.id
12+
}
13+
14+
resource "google_network_security_mirroring_endpoint_group" "endpoint_group" {
15+
provider = google-beta
16+
mirroring_endpoint_group_id = "{{index $.Vars "endpoint_group_id"}}"
17+
location = "global"
18+
type = "BROKER"
19+
mirroring_deployment_groups = [google_network_security_mirroring_deployment_group.deployment_group.id]
20+
}
21+
22+
resource "google_network_security_mirroring_endpoint" "{{$.PrimaryResourceId}}" {
23+
provider = google-beta
24+
mirroring_endpoint_id = "{{index $.Vars "endpoint_id"}}"
25+
location = "us-west2-a"
26+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.endpoint_group.id
27+
description = "some description"
28+
labels = {
29+
foo = "bar"
30+
}
31+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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 TestAccNetworkSecurityMirroringEndpoint_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: testAccNetworkSecurityMirroringEndpoint_basic(context),
26+
},
27+
{
28+
ResourceName: "google_network_security_mirroring_endpoint.default",
29+
ImportState: true,
30+
ImportStateVerify: true,
31+
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
32+
},
33+
{
34+
Config: testAccNetworkSecurityMirroringEndpoint_update(context),
35+
ConfigPlanChecks: resource.ConfigPlanChecks{
36+
PreApply: []plancheck.PlanCheck{
37+
plancheck.ExpectResourceAction("google_network_security_mirroring_endpoint.default", plancheck.ResourceActionUpdate),
38+
},
39+
},
40+
},
41+
{
42+
ResourceName: "google_network_security_mirroring_endpoint.default",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
ImportStateVerifyIgnore: []string{"update_time", "labels", "terraform_labels"},
46+
},
47+
},
48+
})
49+
}
50+
51+
func testAccNetworkSecurityMirroringEndpoint_basic(context map[string]interface{}) string {
52+
return acctest.Nprintf(`
53+
resource "google_compute_network" "network" {
54+
provider = google-beta
55+
name = "tf-test-example-network%{random_suffix}"
56+
auto_create_subnetworks = false
57+
}
58+
59+
resource "google_network_security_mirroring_deployment_group" "deployment_group" {
60+
provider = google-beta
61+
mirroring_deployment_group_id = "tf-test-example-dg%{random_suffix}"
62+
location = "global"
63+
network = google_compute_network.network.id
64+
}
65+
66+
resource "google_network_security_mirroring_endpoint_group" "endpoint_group" {
67+
provider = google-beta
68+
mirroring_endpoint_group_id = "tf-test-example-eg%{random_suffix}"
69+
location = "global"
70+
type = "BROKER"
71+
mirroring_deployment_groups = [google_network_security_mirroring_deployment_group.deployment_group.id]
72+
}
73+
74+
resource "google_network_security_mirroring_endpoint" "default" {
75+
provider = google-beta
76+
mirroring_endpoint_id = "tf-test-example-endpoint%{random_suffix}"
77+
location = "us-west2-a"
78+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.endpoint_group.id
79+
description = "some description"
80+
labels = {
81+
foo = "bar"
82+
}
83+
}
84+
`, context)
85+
}
86+
87+
func testAccNetworkSecurityMirroringEndpoint_update(context map[string]interface{}) string {
88+
return acctest.Nprintf(`
89+
resource "google_compute_network" "network" {
90+
provider = google-beta
91+
name = "tf-test-example-network%{random_suffix}"
92+
auto_create_subnetworks = false
93+
}
94+
95+
resource "google_network_security_mirroring_deployment_group" "deployment_group" {
96+
provider = google-beta
97+
mirroring_deployment_group_id = "tf-test-example-dg%{random_suffix}"
98+
location = "global"
99+
network = google_compute_network.network.id
100+
}
101+
102+
resource "google_network_security_mirroring_endpoint_group" "endpoint_group" {
103+
provider = google-beta
104+
mirroring_endpoint_group_id = "tf-test-example-eg%{random_suffix}"
105+
location = "global"
106+
type = "BROKER"
107+
mirroring_deployment_groups = [google_network_security_mirroring_deployment_group.deployment_group.id]
108+
}
109+
110+
resource "google_network_security_mirroring_endpoint" "default" {
111+
provider = google-beta
112+
mirroring_endpoint_id = "tf-test-example-endpoint%{random_suffix}"
113+
location = "us-west2-a"
114+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.endpoint_group.id
115+
description = "some description"
116+
labels = {
117+
foo = "goo"
118+
}
119+
}
120+
`, context)
121+
}
122+
123+
{{ end }}

0 commit comments

Comments
 (0)