Skip to content

Commit 8ffa156

Browse files
Berro321BBBmau
authored andcommitted
Add google_beyondcorp_security_gateway_application resource. (GoogleCloudPlatform#13918)
1 parent d870fd6 commit 8ffa156

File tree

5 files changed

+286
-1
lines changed

5 files changed

+286
-1
lines changed

mmv1/products/beyondcorp/Application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
---
1515
name: Application
16-
deprecation_message: '`google_beyondcorp_application` is deprecated.'
16+
deprecation_message: '`google_beyondcorp_application` is deprecated. Use `google_beyondcorp_security_gateway_application` instead.'
1717
description: Specifies application endpoint(s) to protect behind a Security Gateway.
1818
base_url: projects/{{project}}/locations/global/securityGateways/{{security_gateways_id}}/applications
1919
update_mask: true
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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: SecurityGatewayApplication
16+
description: Specifies application endpoint(s) to protect behind a Security Gateway.
17+
base_url: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications
18+
update_mask: true
19+
self_link: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}}
20+
create_url: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications?applicationId={{application_id}}
21+
update_verb: PATCH
22+
id_format: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}}
23+
import_format:
24+
- projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}}
25+
iam_policy:
26+
method_name_separator: ':'
27+
iam_conditions_request_type: 'QUERY_PARAM_NESTED'
28+
allowed_iam_role: 'roles/beyondcorp.securityGatewayUser'
29+
parent_resource_attribute: 'application_id'
30+
import_format:
31+
- 'projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}}'
32+
- '{{application_id}}'
33+
examples:
34+
- name: beyondcorp_security_gateway_application_basic
35+
primary_resource_id: example
36+
primary_resource_name: 'fmt.Sprintf("tf-test-default-sg%s", context["random_suffix"]), fmt.Sprintf("tf-test-google-sga%s", context["random_suffix"])'
37+
vars:
38+
security_gateway_name: default-sg
39+
application_name: google-sga
40+
- name: beyondcorp_security_gateway_application_vpc
41+
primary_resource_id: example
42+
primary_resource_name: 'fmt.Sprintf("tf-test-default-sg%s", context["random_suffix"]), fmt.Sprintf("tf-test-google-sga%s", context["random_suffix"])'
43+
vars:
44+
security_gateway_name: default-sg
45+
application_name: my-vm-service2
46+
autogen_async: true
47+
async:
48+
operation:
49+
timeouts:
50+
insert_minutes: 20
51+
update_minutes: 20
52+
delete_minutes: 20
53+
base_url: '{{op_id}}'
54+
actions:
55+
- create
56+
- delete
57+
- update
58+
type: OpAsync
59+
result:
60+
resource_inside_response: true
61+
include_project: false
62+
autogen_status: QXBwbGljYXRpb24=
63+
parameters:
64+
- name: securityGatewayId
65+
type: String
66+
description: ID of the Security Gateway resource this belongs to.
67+
immutable: true
68+
url_param_only: true
69+
required: true
70+
- name: applicationId
71+
type: String
72+
description: |-
73+
User-settable Application resource ID.
74+
* Must start with a letter.
75+
* Must contain between 4-63 characters from `/a-z-/`.
76+
* Must end with a number or letter.
77+
immutable: true
78+
url_param_only: true
79+
required: true
80+
properties:
81+
- name: createTime
82+
type: String
83+
description: Output only. Timestamp when the resource was created.
84+
output: true
85+
- name: displayName
86+
type: String
87+
description: |-
88+
Optional. An arbitrary user-provided name for the Application resource.
89+
Cannot exceed 64 characters.
90+
- name: endpointMatchers
91+
type: Array
92+
description: |-
93+
Required. Endpoint matchers associated with an application.
94+
A combination of hostname and ports as endpoint matcher is used to match
95+
the application.
96+
Match conditions for OR logic.
97+
An array of match conditions to allow for multiple matching criteria.
98+
The rule is considered a match if one the conditions are met.
99+
The conditions can be one of the following combination
100+
(Hostname), (Hostname & Ports)
101+
102+
EXAMPLES:
103+
Hostname - ("*.abc.com"), ("xyz.abc.com")
104+
Hostname and Ports - ("abc.com" and "22"), ("abc.com" and "22,33") etc
105+
required: true
106+
item_type:
107+
type: NestedObject
108+
properties:
109+
- name: hostname
110+
type: String
111+
description: Required. Hostname of the application.
112+
required: true
113+
- name: ports
114+
type: Array
115+
description: Optional. Ports of the application.
116+
item_type:
117+
type: Integer
118+
- name: upstreams
119+
type: Array
120+
description: Optional. List of which upstream resource(s) to forward traffic to.
121+
item_type:
122+
type: NestedObject
123+
properties:
124+
- name: egressPolicy
125+
type: NestedObject
126+
description: Optional. Routing policy information.
127+
properties:
128+
- name: regions
129+
type: Array
130+
description: Required. List of regions where the application sends traffic to.
131+
required: true
132+
item_type:
133+
type: String
134+
- name: network
135+
type: NestedObject
136+
description: Network to forward traffic to.
137+
properties:
138+
- name: name
139+
type: string
140+
description: |-
141+
Required. Network name is of the format:
142+
`projects/{project}/global/networks/{network}`
143+
required: true
144+
- name: name
145+
type: String
146+
description: Identifier. Name of the resource.
147+
output: true
148+
- name: updateTime
149+
type: String
150+
description: Output only. Timestamp when the resource was last modified.
151+
output: true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "google_beyondcorp_security_gateway" "default" {
2+
security_gateway_id = "{{index $.Vars "security_gateway_name"}}"
3+
display_name = "My Security Gateway resource"
4+
hubs { region = "us-central1" }
5+
}
6+
7+
resource "google_beyondcorp_security_gateway_application" "{{$.PrimaryResourceId}}" {
8+
security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id
9+
application_id = "{{index $.Vars "application_name"}}"
10+
endpoint_matchers {
11+
hostname = "google.com"
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
data "google_project" "project" {}
2+
3+
resource "google_beyondcorp_security_gateway" "default" {
4+
security_gateway_id = "{{index $.Vars "security_gateway_name"}}"
5+
display_name = "My Security Gateway resource"
6+
hubs { region = "us-central1" }
7+
}
8+
9+
resource "google_beyondcorp_security_gateway_application" "{{$.PrimaryResourceId}}" {
10+
security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id
11+
application_id = "{{index $.Vars "application_name"}}"
12+
endpoint_matchers {
13+
hostname = "my-vm-service.com"
14+
}
15+
upstreams {
16+
egress_policy {
17+
regions = ["us-central1"]
18+
}
19+
network {
20+
name = "projects/${data.google_project.project.project_id}/global/networks/default"
21+
}
22+
}
23+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package beyondcorp_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
8+
9+
"github.com/hashicorp/terraform-provider-google/google/acctest"
10+
)
11+
12+
func TestAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_update(t *testing.T) {
13+
t.Parallel()
14+
15+
context := map[string]interface{}{
16+
"random_suffix": acctest.RandString(t, 10),
17+
}
18+
19+
acctest.VcrTest(t, resource.TestCase{
20+
PreCheck: func() { acctest.AccTestPreCheck(t) },
21+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
22+
Steps: []resource.TestStep{
23+
{
24+
Config: testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_basic(context),
25+
},
26+
{
27+
ResourceName: "google_beyondcorp_security_gateway_application.example",
28+
ImportState: true,
29+
ImportStateVerify: true,
30+
ImportStateVerifyIgnore: []string{"application_id", "security_gateway_id"},
31+
},
32+
{
33+
Config: testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_update(context),
34+
ConfigPlanChecks: resource.ConfigPlanChecks{
35+
PreApply: []plancheck.PlanCheck{
36+
plancheck.ExpectResourceAction("google_beyondcorp_security_gateway_application.example", plancheck.ResourceActionUpdate),
37+
},
38+
},
39+
},
40+
{
41+
ResourceName: "google_beyondcorp_security_gateway_application.example",
42+
ImportState: true,
43+
ImportStateVerify: true,
44+
ImportStateVerifyIgnore: []string{"application_id", "security_gateway_id"},
45+
},
46+
},
47+
})
48+
}
49+
50+
func testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_basic(context map[string]interface{}) string {
51+
return acctest.Nprintf(`
52+
data "google_project" "project" {}
53+
54+
resource "google_beyondcorp_security_gateway" "default" {
55+
security_gateway_id = "default-sg%{random_suffix}"
56+
display_name = "My Security Gateway resource"
57+
hubs { region = "us-central1" }
58+
}
59+
60+
resource "google_beyondcorp_security_gateway_application" "example" {
61+
security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id
62+
application_id = "google-sga%{random_suffix}"
63+
endpoint_matchers {
64+
hostname = "google.com"
65+
}
66+
}
67+
`, context)
68+
}
69+
70+
func testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_update(context map[string]interface{}) string {
71+
return acctest.Nprintf(`
72+
data "google_project" "project" {}
73+
74+
resource "google_beyondcorp_security_gateway" "default" {
75+
security_gateway_id = "default-sg%{random_suffix}"
76+
display_name = "My Security Gateway resource"
77+
hubs { region = "us-central1" }
78+
}
79+
80+
resource "google_beyondcorp_security_gateway_application" "example" {
81+
security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id
82+
display_name = "Updated Name"
83+
application_id = "google-sga%{random_suffix}"
84+
endpoint_matchers {
85+
hostname = "*.google.com"
86+
}
87+
endpoint_matchers {
88+
hostname = "google.com"
89+
ports = [443, 80]
90+
}
91+
upstreams {
92+
network {
93+
name = "projects/${data.google_project.project.project_id}/global/networks/default"
94+
}
95+
}
96+
}
97+
`, context)
98+
}

0 commit comments

Comments
 (0)