Skip to content

Commit 9ffbaef

Browse files
authored
Add Intercept Endpoint Group resource to Network Security. (#12522)
1 parent 87f3925 commit 9ffbaef

File tree

3 files changed

+233
-0
lines changed

3 files changed

+233
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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: 'InterceptEndpointGroup'
16+
description: An intercept endpoint group is a global resource in the consumer account representing the producer’s deployment group.
17+
min_version: 'beta'
18+
docs:
19+
id_format: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroups/{{intercept_endpoint_group_id}}'
20+
base_url: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroups'
21+
self_link: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroups/{{intercept_endpoint_group_id}}'
22+
create_url: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroups?interceptEndpointGroupId={{intercept_endpoint_group_id}}'
23+
update_verb: 'PATCH'
24+
update_mask: true
25+
import_format:
26+
- 'projects/{{project}}/locations/{{location}}/interceptEndpointGroups/{{intercept_endpoint_group_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_endpoint_group_basic'
48+
config_path: 'templates/terraform/examples/network_security_intercept_endpoint_group_basic.tf.tmpl'
49+
primary_resource_id: 'default'
50+
vars:
51+
network_name: 'example-network'
52+
deployment_group_id: 'example-dg'
53+
endpoint_group_id: 'example-eg'
54+
parameters:
55+
- name: 'location'
56+
type: String
57+
description: 'The location of the Intercept Endpoint Group, currently restricted to `global`.'
58+
min_version: 'beta'
59+
url_param_only: true
60+
required: true
61+
immutable: true
62+
- name: 'interceptEndpointGroupId'
63+
type: String
64+
description: "ID of the Intercept Endpoint Group."
65+
min_version: 'beta'
66+
url_param_only: true
67+
required: true
68+
immutable: true
69+
properties:
70+
- name: 'name'
71+
type: String
72+
description: 'Identifier. The name of the Intercept Endpoint Group.'
73+
min_version: 'beta'
74+
output: true
75+
- name: 'createTime'
76+
type: String
77+
description: 'Create time stamp.'
78+
min_version: 'beta'
79+
output: true
80+
- name: 'updateTime'
81+
type: String
82+
description: 'Update time stamp.'
83+
min_version: 'beta'
84+
output: true
85+
- name: 'labels'
86+
type: KeyValueLabels
87+
description: 'Optional. Labels as key value pairs'
88+
min_version: 'beta'
89+
- name: 'interceptDeploymentGroup'
90+
type: String
91+
description: "Immutable. The Intercept Deployment Group that this resource
92+
is connected to. Format\nis:\n`projects/{project}/locations/global/interceptDeploymentGroups/{interceptDeploymentGroup}`"
93+
min_version: 'beta'
94+
required: true
95+
immutable: true
96+
- name: 'state'
97+
type: String
98+
description: "Current state of the endpoint group. \n Possible values:\n
99+
STATE_UNSPECIFIED\nACTIVE\nCLOSED\nCREATING\nDELETING\nOUT_OF_SYNC"
100+
min_version: 'beta'
101+
output: true
102+
- name: 'reconciling'
103+
type: Boolean
104+
description: "Whether reconciling is in progress, recommended per\nhttps://google.aip.dev/128."
105+
min_version: 'beta'
106+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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_intercept_deployment_group" "deployment_group" {
8+
provider = google-beta
9+
intercept_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_intercept_endpoint_group" "{{$.PrimaryResourceId}}" {
15+
provider = google-beta
16+
intercept_endpoint_group_id = "{{index $.Vars "endpoint_group_id"}}"
17+
location = "global"
18+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
19+
labels = {
20+
foo = "bar"
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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 TestAccNetworkSecurityInterceptEndpointGroup_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: testAccNetworkSecurityInterceptEndpointGroup_basic(context),
26+
},
27+
{
28+
ResourceName: "google_network_security_intercept_endpoint_group.default",
29+
ImportState: true,
30+
ImportStateVerify: true,
31+
ImportStateVerifyIgnore: []string{"labels", "terraform_labels"},
32+
},
33+
{
34+
Config: testAccNetworkSecurityInterceptEndpointGroup_update(context),
35+
ConfigPlanChecks: resource.ConfigPlanChecks{
36+
PreApply: []plancheck.PlanCheck{
37+
plancheck.ExpectResourceAction("google_network_security_intercept_endpoint_group.default", plancheck.ResourceActionUpdate),
38+
},
39+
},
40+
},
41+
{
42+
ResourceName: "google_network_security_intercept_endpoint_group.default",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
ImportStateVerifyIgnore: []string{"update_time", "labels", "terraform_labels"},
46+
},
47+
},
48+
})
49+
}
50+
51+
func testAccNetworkSecurityInterceptEndpointGroup_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_intercept_deployment_group" "deployment_group" {
60+
provider = google-beta
61+
intercept_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_intercept_endpoint_group" "default" {
67+
provider = google-beta
68+
intercept_endpoint_group_id = "tf-test-example-eg%{random_suffix}"
69+
location = "global"
70+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
71+
labels = {
72+
foo = "bar"
73+
}
74+
}
75+
`, context)
76+
}
77+
78+
func testAccNetworkSecurityInterceptEndpointGroup_update(context map[string]interface{}) string {
79+
return acctest.Nprintf(`
80+
resource "google_compute_network" "network" {
81+
provider = google-beta
82+
name = "tf-test-example-network%{random_suffix}"
83+
auto_create_subnetworks = false
84+
}
85+
86+
resource "google_network_security_intercept_deployment_group" "deployment_group" {
87+
provider = google-beta
88+
intercept_deployment_group_id = "tf-test-example-dg%{random_suffix}"
89+
location = "global"
90+
network = google_compute_network.network.id
91+
}
92+
93+
resource "google_network_security_intercept_endpoint_group" "default" {
94+
provider = google-beta
95+
intercept_endpoint_group_id = "tf-test-example-eg%{random_suffix}"
96+
location = "global"
97+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
98+
labels = {
99+
foo = "goo"
100+
}
101+
}
102+
`, context)
103+
}
104+
105+
{{ end }}

0 commit comments

Comments
 (0)