-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add google_beyondcorp_security_gateway_application resource.
#13918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SirGitsalot
merged 15 commits into
GoogleCloudPlatform:main
from
Berro321:beyondcorp-rename
May 20, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6736834
Add SecurityGatewayApplication resource.
Berro321 525af15
Add EOF to yaml
Berro321 8895a03
Slightly rename test names.
Berro321 8437595
Rename some tests.
Berro321 b15031f
Rename SG application test names in resource.
Berro321 e0a5261
Update to unique test names from existing
Berro321 e0482e7
add prefix to iam test
Berro321 676bc57
Fix misnamed test.
Berro321 04c2469
Re-format SG reference in application.
Berro321 cd2b0bd
Fix typo on resource name
Berro321 05b07b8
Expand application test
Berro321 76a19f3
remove extra upstream as API does not support
Berro321 4f3c094
Add ports field to test
Berro321 9ae3a97
Merge remote-tracking branch 'origin/main' into beyondcorp-rename
Berro321 0bd49dc
Update application deprecation message.
Berro321 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
mmv1/products/beyondcorp/SecurityGatewayApplication.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| # Copyright 2024 Google Inc. | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| --- | ||
| name: SecurityGatewayApplication | ||
| description: Specifies application endpoint(s) to protect behind a Security Gateway. | ||
| base_url: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications | ||
| update_mask: true | ||
| self_link: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}} | ||
| create_url: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications?applicationId={{application_id}} | ||
| update_verb: PATCH | ||
| id_format: projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}} | ||
| import_format: | ||
| - projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}} | ||
| iam_policy: | ||
| method_name_separator: ':' | ||
| iam_conditions_request_type: 'QUERY_PARAM_NESTED' | ||
| allowed_iam_role: 'roles/beyondcorp.securityGatewayUser' | ||
| parent_resource_attribute: 'application_id' | ||
| import_format: | ||
| - 'projects/{{project}}/locations/global/securityGateways/{{security_gateway_id}}/applications/{{application_id}}' | ||
| - '{{application_id}}' | ||
| examples: | ||
| - name: beyondcorp_security_gateway_application_basic | ||
| primary_resource_id: example | ||
| primary_resource_name: 'fmt.Sprintf("tf-test-default-sg%s", context["random_suffix"]), fmt.Sprintf("tf-test-google-sga%s", context["random_suffix"])' | ||
| vars: | ||
| security_gateway_name: default-sg | ||
| application_name: google-sga | ||
| - name: beyondcorp_security_gateway_application_vpc | ||
| primary_resource_id: example | ||
| primary_resource_name: 'fmt.Sprintf("tf-test-default-sg%s", context["random_suffix"]), fmt.Sprintf("tf-test-google-sga%s", context["random_suffix"])' | ||
| vars: | ||
| security_gateway_name: default-sg | ||
| application_name: my-vm-service2 | ||
| autogen_async: true | ||
| async: | ||
| operation: | ||
| timeouts: | ||
| insert_minutes: 20 | ||
| update_minutes: 20 | ||
| delete_minutes: 20 | ||
| base_url: '{{op_id}}' | ||
| actions: | ||
| - create | ||
| - delete | ||
| - update | ||
| type: OpAsync | ||
| result: | ||
| resource_inside_response: true | ||
| include_project: false | ||
| autogen_status: QXBwbGljYXRpb24= | ||
| parameters: | ||
| - name: securityGatewayId | ||
| type: String | ||
| description: ID of the Security Gateway resource this belongs to. | ||
| immutable: true | ||
| url_param_only: true | ||
| required: true | ||
| - name: applicationId | ||
| type: String | ||
| description: |- | ||
| User-settable Application resource ID. | ||
| * Must start with a letter. | ||
| * Must contain between 4-63 characters from `/a-z-/`. | ||
| * Must end with a number or letter. | ||
| immutable: true | ||
| url_param_only: true | ||
| required: true | ||
| properties: | ||
| - name: createTime | ||
| type: String | ||
| description: Output only. Timestamp when the resource was created. | ||
| output: true | ||
| - name: displayName | ||
| type: String | ||
| description: |- | ||
| Optional. An arbitrary user-provided name for the Application resource. | ||
| Cannot exceed 64 characters. | ||
| - name: endpointMatchers | ||
| type: Array | ||
| description: |- | ||
| Required. Endpoint matchers associated with an application. | ||
| A combination of hostname and ports as endpoint matcher is used to match | ||
| the application. | ||
| Match conditions for OR logic. | ||
| An array of match conditions to allow for multiple matching criteria. | ||
| The rule is considered a match if one the conditions are met. | ||
| The conditions can be one of the following combination | ||
| (Hostname), (Hostname & Ports) | ||
|
|
||
| EXAMPLES: | ||
| Hostname - ("*.abc.com"), ("xyz.abc.com") | ||
| Hostname and Ports - ("abc.com" and "22"), ("abc.com" and "22,33") etc | ||
| required: true | ||
| item_type: | ||
| type: NestedObject | ||
| properties: | ||
| - name: hostname | ||
| type: String | ||
| description: Required. Hostname of the application. | ||
| required: true | ||
| - name: ports | ||
| type: Array | ||
| description: Optional. Ports of the application. | ||
| item_type: | ||
| type: Integer | ||
| - name: upstreams | ||
Berro321 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type: Array | ||
| description: Optional. List of which upstream resource(s) to forward traffic to. | ||
| item_type: | ||
| type: NestedObject | ||
| properties: | ||
| - name: egressPolicy | ||
| type: NestedObject | ||
| description: Optional. Routing policy information. | ||
| properties: | ||
| - name: regions | ||
| type: Array | ||
| description: Required. List of regions where the application sends traffic to. | ||
| required: true | ||
| item_type: | ||
| type: String | ||
| - name: network | ||
| type: NestedObject | ||
| description: Network to forward traffic to. | ||
| properties: | ||
| - name: name | ||
| type: string | ||
| description: |- | ||
| Required. Network name is of the format: | ||
| `projects/{project}/global/networks/{network}` | ||
| required: true | ||
| - name: name | ||
| type: String | ||
| description: Identifier. Name of the resource. | ||
| output: true | ||
| - name: updateTime | ||
| type: String | ||
| description: Output only. Timestamp when the resource was last modified. | ||
| output: true | ||
13 changes: 13 additions & 0 deletions
13
mmv1/templates/terraform/examples/beyondcorp_security_gateway_application_basic.tf.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| resource "google_beyondcorp_security_gateway" "default" { | ||
| security_gateway_id = "{{index $.Vars "security_gateway_name"}}" | ||
| display_name = "My Security Gateway resource" | ||
| hubs { region = "us-central1" } | ||
| } | ||
|
|
||
| resource "google_beyondcorp_security_gateway_application" "{{$.PrimaryResourceId}}" { | ||
| security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id | ||
| application_id = "{{index $.Vars "application_name"}}" | ||
| endpoint_matchers { | ||
| hostname = "google.com" | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
mmv1/templates/terraform/examples/beyondcorp_security_gateway_application_vpc.tf.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| data "google_project" "project" {} | ||
|
|
||
| resource "google_beyondcorp_security_gateway" "default" { | ||
| security_gateway_id = "{{index $.Vars "security_gateway_name"}}" | ||
| display_name = "My Security Gateway resource" | ||
| hubs { region = "us-central1" } | ||
| } | ||
|
|
||
| resource "google_beyondcorp_security_gateway_application" "{{$.PrimaryResourceId}}" { | ||
| security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id | ||
| application_id = "{{index $.Vars "application_name"}}" | ||
| endpoint_matchers { | ||
| hostname = "my-vm-service.com" | ||
| } | ||
| upstreams { | ||
| egress_policy { | ||
| regions = ["us-central1"] | ||
| } | ||
| network { | ||
| name = "projects/${data.google_project.project.project_id}/global/networks/default" | ||
| } | ||
| } | ||
| } |
98 changes: 98 additions & 0 deletions
98
...ty/terraform/services/beyondcorp/resource_beyondcorp_security_gateway_application_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| package beyondcorp_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
| "github.com/hashicorp/terraform-plugin-testing/plancheck" | ||
|
|
||
| "github.com/hashicorp/terraform-provider-google/google/acctest" | ||
| ) | ||
|
|
||
| func TestAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_update(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| context := map[string]interface{}{ | ||
| "random_suffix": acctest.RandString(t, 10), | ||
| } | ||
|
|
||
| acctest.VcrTest(t, resource.TestCase{ | ||
| PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
| ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
| Steps: []resource.TestStep{ | ||
| { | ||
| Config: testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_basic(context), | ||
| }, | ||
| { | ||
| ResourceName: "google_beyondcorp_security_gateway_application.example", | ||
| ImportState: true, | ||
| ImportStateVerify: true, | ||
| ImportStateVerifyIgnore: []string{"application_id", "security_gateway_id"}, | ||
| }, | ||
| { | ||
| Config: testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_update(context), | ||
| ConfigPlanChecks: resource.ConfigPlanChecks{ | ||
| PreApply: []plancheck.PlanCheck{ | ||
| plancheck.ExpectResourceAction("google_beyondcorp_security_gateway_application.example", plancheck.ResourceActionUpdate), | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| ResourceName: "google_beyondcorp_security_gateway_application.example", | ||
| ImportState: true, | ||
| ImportStateVerify: true, | ||
| ImportStateVerifyIgnore: []string{"application_id", "security_gateway_id"}, | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_basic(context map[string]interface{}) string { | ||
| return acctest.Nprintf(` | ||
| data "google_project" "project" {} | ||
|
|
||
| resource "google_beyondcorp_security_gateway" "default" { | ||
| security_gateway_id = "default-sg%{random_suffix}" | ||
| display_name = "My Security Gateway resource" | ||
| hubs { region = "us-central1" } | ||
| } | ||
|
|
||
| resource "google_beyondcorp_security_gateway_application" "example" { | ||
| security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id | ||
| application_id = "google-sga%{random_suffix}" | ||
| endpoint_matchers { | ||
| hostname = "google.com" | ||
| } | ||
| } | ||
| `, context) | ||
| } | ||
|
|
||
| func testAccBeyondcorpSecurityGatewayApplication_beyondcorpSecurityGatewayApplicationBasicExample_update(context map[string]interface{}) string { | ||
| return acctest.Nprintf(` | ||
| data "google_project" "project" {} | ||
|
|
||
| resource "google_beyondcorp_security_gateway" "default" { | ||
| security_gateway_id = "default-sg%{random_suffix}" | ||
| display_name = "My Security Gateway resource" | ||
| hubs { region = "us-central1" } | ||
| } | ||
|
|
||
| resource "google_beyondcorp_security_gateway_application" "example" { | ||
| security_gateway_id = google_beyondcorp_security_gateway.default.security_gateway_id | ||
| display_name = "Updated Name" | ||
| application_id = "google-sga%{random_suffix}" | ||
| endpoint_matchers { | ||
Berro321 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| hostname = "*.google.com" | ||
| } | ||
| endpoint_matchers { | ||
| hostname = "google.com" | ||
| ports = [443, 80] | ||
| } | ||
| upstreams { | ||
| network { | ||
| name = "projects/${data.google_project.project.project_id}/global/networks/default" | ||
| } | ||
| } | ||
| } | ||
| `, context) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.