Skip to content

Commit a88f911

Browse files
authored
Add Intercept Deployment resource to Network Security. (#12521)
1 parent 673112a commit a88f911

File tree

3 files changed

+365
-0
lines changed

3 files changed

+365
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Copyright 2024 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: 'InterceptDeployment'
16+
description: InterceptDeployment represents the collectors within a Zone and is associated with a deployment group.
17+
min_version: 'beta'
18+
docs:
19+
id_format: 'projects/{{project}}/locations/{{location}}/interceptDeployments/{{intercept_deployment_id}}'
20+
base_url: 'projects/{{project}}/locations/{{location}}/interceptDeployments'
21+
self_link: 'projects/{{project}}/locations/{{location}}/interceptDeployments/{{intercept_deployment_id}}'
22+
create_url: 'projects/{{project}}/locations/{{location}}/interceptDeployments?interceptDeploymentId={{intercept_deployment_id}}'
23+
update_verb: 'PATCH'
24+
update_mask: true
25+
import_format:
26+
- 'projects/{{project}}/locations/{{location}}/interceptDeployments/{{intercept_deployment_id}}'
27+
timeouts:
28+
insert_minutes: 20
29+
update_minutes: 20
30+
delete_minutes: 20
31+
autogen_async: true
32+
async:
33+
actions: ['create', 'delete', 'update']
34+
type: 'OpAsync'
35+
operation:
36+
base_url: '{{op_id}}'
37+
path: 'name'
38+
wait_ms: 1000
39+
result:
40+
path: 'response'
41+
resource_inside_response: true
42+
error:
43+
path: 'error'
44+
message: 'message'
45+
custom_code:
46+
examples:
47+
- name: 'network_security_intercept_deployment_basic'
48+
config_path: 'templates/terraform/examples/network_security_intercept_deployment_basic.tf.tmpl'
49+
primary_resource_id: 'default'
50+
vars:
51+
network_name: 'example-network'
52+
subnetwork_name: 'example-subnet'
53+
health_check_name: 'example-hc'
54+
backend_service_name: 'example-bs'
55+
forwarding_rule_name: 'example-fwr'
56+
deployment_group_id: 'example-dg'
57+
deployment_id: 'example-deployment'
58+
parameters:
59+
- name: 'location'
60+
type: String
61+
description: 'Resource ID segment making up resource `name`. It identifies the resource
62+
within its parent collection as described in https://google.aip.dev/122. See documentation
63+
for resource type `networksecurity.googleapis.com/InterceptDeployment`. '
64+
min_version: 'beta'
65+
url_param_only: true
66+
required: true
67+
immutable: true
68+
- name: 'interceptDeploymentId'
69+
type: String
70+
description: "Id of the requesting object\nIf auto-generating Id server-side,
71+
remove this field and\nintercept_deployment_id from the method_signature of Create
72+
RPC "
73+
min_version: 'beta'
74+
url_param_only: true
75+
required: true
76+
immutable: true
77+
properties:
78+
- name: 'name'
79+
type: String
80+
description: 'Identifier. The name of the InterceptDeployment. '
81+
min_version: 'beta'
82+
output: true
83+
- name: 'createTime'
84+
type: String
85+
description: 'Create time stamp '
86+
min_version: 'beta'
87+
output: true
88+
- name: 'updateTime'
89+
type: String
90+
description: 'Update time stamp '
91+
min_version: 'beta'
92+
output: true
93+
- name: 'labels'
94+
type: KeyValueLabels
95+
description: 'Optional. Labels as key value pairs '
96+
min_version: 'beta'
97+
- name: 'forwardingRule'
98+
type: String
99+
description: "Immutable. The regional load balancer which the intercepted
100+
traffic should be forwarded\nto. Format is:\nprojects/{project}/regions/{region}/forwardingRules/{forwardingRule} "
101+
min_version: 'beta'
102+
required: true
103+
immutable: true
104+
- name: 'interceptDeploymentGroup'
105+
type: String
106+
description: "Immutable. The Intercept Deployment Group that this resource
107+
is part of. Format is:\n`projects/{project}/locations/global/interceptDeploymentGroups/{interceptDeploymentGroup}` "
108+
min_version: 'beta'
109+
required: true
110+
immutable: true
111+
- name: 'state'
112+
type: String
113+
description: "Current state of the deployment. \n Possible values:\n
114+
STATE_UNSPECIFIED\nACTIVE\nCREATING\nDELETING\nOUT_OF_SYNC\nDELETE_FAILED"
115+
min_version: 'beta'
116+
output: true
117+
- name: 'reconciling'
118+
type: Boolean
119+
description: "Whether reconciling is in progress, recommended per\nhttps://google.aip.dev/128. "
120+
min_version: 'beta'
121+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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_compute_subnetwork" "subnetwork" {
8+
provider = google-beta
9+
name = "{{index $.Vars "subnetwork_name"}}"
10+
region = "us-central1"
11+
ip_cidr_range = "10.1.0.0/16"
12+
network = google_compute_network.network.name
13+
}
14+
15+
resource "google_compute_region_health_check" "health_check" {
16+
provider = google-beta
17+
name = "{{index $.Vars "health_check_name"}}"
18+
region = "us-central1"
19+
http_health_check {
20+
port = 80
21+
}
22+
}
23+
24+
resource "google_compute_region_backend_service" "backend_service" {
25+
provider = google-beta
26+
name = "{{index $.Vars "backend_service_name"}}"
27+
region = "us-central1"
28+
health_checks = [google_compute_region_health_check.health_check.id]
29+
protocol = "UDP"
30+
load_balancing_scheme = "INTERNAL"
31+
}
32+
33+
resource "google_compute_forwarding_rule" "forwarding_rule" {
34+
provider = google-beta
35+
name = "{{index $.Vars "forwarding_rule_name"}}"
36+
region = "us-central1"
37+
network = google_compute_network.network.name
38+
subnetwork = google_compute_subnetwork.subnetwork.name
39+
backend_service = google_compute_region_backend_service.backend_service.id
40+
load_balancing_scheme = "INTERNAL"
41+
ports = [6081]
42+
ip_protocol = "UDP"
43+
}
44+
45+
resource "google_network_security_intercept_deployment_group" "deployment_group" {
46+
provider = google-beta
47+
intercept_deployment_group_id = "{{index $.Vars "deployment_group_id"}}"
48+
location = "global"
49+
network = google_compute_network.network.id
50+
}
51+
52+
resource "google_network_security_intercept_deployment" "{{$.PrimaryResourceId}}" {
53+
provider = google-beta
54+
intercept_deployment_id = "{{index $.Vars "deployment_id"}}"
55+
location = "us-central1-a"
56+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule.id
57+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
58+
labels = {
59+
foo = "bar"
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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 TestAccNetworkSecurityInterceptDeployment_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: testAccNetworkSecurityInterceptDeployment_basic(context),
26+
},
27+
{
28+
ResourceName: "google_network_security_intercept_deployment.default",
29+
ImportState: true,
30+
ImportStateVerify: true,
31+
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
32+
},
33+
{
34+
Config: testAccNetworkSecurityInterceptDeployment_update(context),
35+
ConfigPlanChecks: resource.ConfigPlanChecks{
36+
PreApply: []plancheck.PlanCheck{
37+
plancheck.ExpectResourceAction("google_network_security_intercept_deployment.default", plancheck.ResourceActionUpdate),
38+
},
39+
},
40+
},
41+
{
42+
ResourceName: "google_network_security_intercept_deployment.default",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
ImportStateVerifyIgnore: []string{"update_time", "labels", "terraform_labels"},
46+
},
47+
},
48+
})
49+
}
50+
51+
func testAccNetworkSecurityInterceptDeployment_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_compute_subnetwork" "subnetwork" {
60+
provider = google-beta
61+
name = "tf-test-example-subnet%{random_suffix}"
62+
region = "us-central1"
63+
ip_cidr_range = "10.1.0.0/16"
64+
network = google_compute_network.network.name
65+
}
66+
67+
resource "google_compute_region_health_check" "health_check" {
68+
provider = google-beta
69+
name = "tf-test-example-hc%{random_suffix}"
70+
region = "us-central1"
71+
http_health_check {
72+
port = 80
73+
}
74+
}
75+
76+
resource "google_compute_region_backend_service" "backend_service" {
77+
provider = google-beta
78+
name = "tf-test-example-bs%{random_suffix}"
79+
region = "us-central1"
80+
health_checks = [google_compute_region_health_check.health_check.id]
81+
protocol = "UDP"
82+
load_balancing_scheme = "INTERNAL"
83+
}
84+
85+
resource "google_compute_forwarding_rule" "forwarding_rule" {
86+
provider = google-beta
87+
name = "tf-test-example-fwr%{random_suffix}"
88+
region = "us-central1"
89+
network = google_compute_network.network.name
90+
subnetwork = google_compute_subnetwork.subnetwork.name
91+
backend_service = google_compute_region_backend_service.backend_service.id
92+
load_balancing_scheme = "INTERNAL"
93+
ports = [6081]
94+
ip_protocol = "UDP"
95+
}
96+
97+
resource "google_network_security_intercept_deployment_group" "deployment_group" {
98+
provider = google-beta
99+
intercept_deployment_group_id = "tf-test-example-dg%{random_suffix}"
100+
location = "global"
101+
network = google_compute_network.network.id
102+
}
103+
104+
resource "google_network_security_intercept_deployment" "default" {
105+
provider = google-beta
106+
intercept_deployment_id = "tf-test-example-deployment%{random_suffix}"
107+
location = "us-central1-a"
108+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule.id
109+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
110+
labels = {
111+
foo = "bar"
112+
}
113+
}
114+
`, context)
115+
}
116+
117+
func testAccNetworkSecurityInterceptDeployment_update(context map[string]interface{}) string {
118+
return acctest.Nprintf(`
119+
resource "google_compute_network" "network" {
120+
provider = google-beta
121+
name = "tf-test-example-network%{random_suffix}"
122+
auto_create_subnetworks = false
123+
}
124+
125+
resource "google_compute_subnetwork" "subnetwork" {
126+
provider = google-beta
127+
name = "tf-test-example-subnet%{random_suffix}"
128+
region = "us-central1"
129+
ip_cidr_range = "10.1.0.0/16"
130+
network = google_compute_network.network.name
131+
}
132+
133+
resource "google_compute_region_health_check" "health_check" {
134+
provider = google-beta
135+
name = "tf-test-example-hc%{random_suffix}"
136+
region = "us-central1"
137+
http_health_check {
138+
port = 80
139+
}
140+
}
141+
142+
resource "google_compute_region_backend_service" "backend_service" {
143+
provider = google-beta
144+
name = "tf-test-example-bs%{random_suffix}"
145+
region = "us-central1"
146+
health_checks = [google_compute_region_health_check.health_check.id]
147+
protocol = "UDP"
148+
load_balancing_scheme = "INTERNAL"
149+
}
150+
151+
resource "google_compute_forwarding_rule" "forwarding_rule" {
152+
provider = google-beta
153+
name = "tf-test-example-fwr%{random_suffix}"
154+
region = "us-central1"
155+
network = google_compute_network.network.name
156+
subnetwork = google_compute_subnetwork.subnetwork.name
157+
backend_service = google_compute_region_backend_service.backend_service.id
158+
load_balancing_scheme = "INTERNAL"
159+
ports = [6081]
160+
ip_protocol = "UDP"
161+
}
162+
163+
resource "google_network_security_intercept_deployment_group" "deployment_group" {
164+
provider = google-beta
165+
intercept_deployment_group_id = "tf-test-example-dg%{random_suffix}"
166+
location = "global"
167+
network = google_compute_network.network.id
168+
}
169+
170+
resource "google_network_security_intercept_deployment" "default" {
171+
provider = google-beta
172+
intercept_deployment_id = "tf-test-example-deployment%{random_suffix}"
173+
location = "us-central1-a"
174+
forwarding_rule = google_compute_forwarding_rule.forwarding_rule.id
175+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
176+
labels = {
177+
foo = "goo"
178+
}
179+
}
180+
`, context)
181+
}
182+
183+
{{ end }}

0 commit comments

Comments
 (0)