Skip to content

Commit c53f2b3

Browse files
authored
Add Intercept Endpoint Group Association resource to Network Security. (#12577)
1 parent 55ec241 commit c53f2b3

File tree

3 files changed

+301
-0
lines changed

3 files changed

+301
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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: 'InterceptEndpointGroupAssociation'
16+
description: Creates an association between a VPC and an Intercept Endpoint Group in order to intercept traffic in that VPC.
17+
min_version: 'beta'
18+
docs:
19+
id_format: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroupAssociations/{{intercept_endpoint_group_association_id}}'
20+
base_url: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroupAssociations'
21+
self_link: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroupAssociations/{{intercept_endpoint_group_association_id}}'
22+
create_url: 'projects/{{project}}/locations/{{location}}/interceptEndpointGroupAssociations?interceptEndpointGroupAssociationId={{intercept_endpoint_group_association_id}}'
23+
update_verb: 'PATCH'
24+
update_mask: true
25+
import_format:
26+
- 'projects/{{project}}/locations/{{location}}/interceptEndpointGroupAssociations/{{intercept_endpoint_group_association_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_association_basic'
48+
config_path: 'templates/terraform/examples/network_security_intercept_endpoint_group_association_basic.tf.tmpl'
49+
primary_resource_id: 'default'
50+
vars:
51+
producer_network_name: 'example-prod-network'
52+
consumer_network_name: 'example-cons-network'
53+
deployment_group_id: 'example-dg'
54+
endpoint_group_id: 'example-eg'
55+
endpoint_group_association_id: 'example-ega'
56+
parameters:
57+
- name: 'location'
58+
type: String
59+
description: 'The location of the Intercept Endpoint Group Association, currently restricted to `global`.'
60+
min_version: 'beta'
61+
url_param_only: true
62+
required: true
63+
immutable: true
64+
- name: 'interceptEndpointGroupAssociationId'
65+
type: String
66+
description: 'ID of the Intercept Endpoint Group Association.'
67+
min_version: 'beta'
68+
url_param_only: true
69+
immutable: true
70+
properties:
71+
- name: 'name'
72+
type: String
73+
description: 'Identifier. The name of the Intercept Endpoint Group Association.'
74+
min_version: 'beta'
75+
output: true
76+
- name: 'createTime'
77+
type: String
78+
description: 'Create time stamp.'
79+
min_version: 'beta'
80+
output: true
81+
- name: 'updateTime'
82+
type: String
83+
description: 'Update time stamp.'
84+
min_version: 'beta'
85+
output: true
86+
- name: 'labels'
87+
type: KeyValueLabels
88+
description: 'Optional. Labels as key value pairs.'
89+
min_version: 'beta'
90+
- name: 'interceptEndpointGroup'
91+
type: String
92+
description: "Immutable. The Intercept Endpoint Group that this resource
93+
is connected to. Format\nis:\n`projects/{project}/locations/global/interceptEndpointGroups/{interceptEndpointGroup}`."
94+
min_version: 'beta'
95+
required: true
96+
immutable: true
97+
- name: 'network'
98+
type: String
99+
description: "Immutable. The VPC network associated. Format:\n`projects/{project}/global/networks/{network}`."
100+
min_version: 'beta'
101+
required: true
102+
immutable: true
103+
- name: 'locationsDetails'
104+
type: Array
105+
description: 'The list of locations that are currently supported by the associated Intercept Deployment Group and their state.'
106+
min_version: 'beta'
107+
output: true
108+
item_type:
109+
type: NestedObject
110+
properties:
111+
- name: 'location'
112+
type: String
113+
min_version: 'beta'
114+
description: 'Location supported by the Intercept Deployment Group, for example `us-central1-a`'
115+
output: true
116+
- name: 'state'
117+
type: String
118+
description: "The association state in this location. \n Possible
119+
values:\n STATE_UNSPECIFIED\nACTIVE\nOUT_OF_SYNC"
120+
min_version: 'beta'
121+
output: true
122+
- name: 'state'
123+
type: String
124+
description: "Current state of the Intercept Endpoint Group Association. \n Possible
125+
values:\n STATE_UNSPECIFIED\nACTIVE\nCREATING\nDELETING\nCLOSED\nOUT_OF_SYNC\nDELETE_FAILED"
126+
min_version: 'beta'
127+
output: true
128+
- name: 'reconciling'
129+
type: Boolean
130+
description: "Whether reconciling is in progress."
131+
min_version: 'beta'
132+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
resource "google_compute_network" "producer_network" {
2+
provider = google-beta
3+
name = "{{index $.Vars "producer_network_name"}}"
4+
auto_create_subnetworks = false
5+
}
6+
7+
resource "google_compute_network" "consumer_network" {
8+
provider = google-beta
9+
name = "{{index $.Vars "consumer_network_name"}}"
10+
auto_create_subnetworks = false
11+
}
12+
13+
resource "google_network_security_intercept_deployment_group" "deployment_group" {
14+
provider = google-beta
15+
intercept_deployment_group_id = "{{index $.Vars "deployment_group_id"}}"
16+
location = "global"
17+
network = google_compute_network.producer_network.id
18+
}
19+
20+
resource "google_network_security_intercept_endpoint_group" "endpoint_group" {
21+
provider = google-beta
22+
intercept_endpoint_group_id = "{{index $.Vars "endpoint_group_id"}}"
23+
location = "global"
24+
intercept_deployment_group = google_network_security_intercept_deployment_group.deployment_group.id
25+
}
26+
27+
resource "google_network_security_intercept_endpoint_group_association" "{{$.PrimaryResourceId}}" {
28+
provider = google-beta
29+
intercept_endpoint_group_association_id = "{{index $.Vars "endpoint_group_association_id"}}"
30+
location = "global"
31+
network = google_compute_network.consumer_network.id
32+
intercept_endpoint_group = google_network_security_intercept_endpoint_group.endpoint_group.id
33+
labels = {
34+
foo = "bar"
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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

Comments
 (0)