Skip to content

Commit bf7fa1c

Browse files
Add new resource Boundary for AppHub (#15891)
1 parent 93705bc commit bf7fa1c

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed

mmv1/products/apphub/Boundary.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Copyright 2025 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: 'Boundary'
16+
description: 'Application management boundary.'
17+
references:
18+
guides:
19+
'AppHub': 'https://docs.cloud.google.com/app-hub/docs/'
20+
api: 'https://docs.cloud.google.com/app-hub/docs/reference/rest/v1/Boundary'
21+
22+
docs:
23+
self_link: 'projects/{{project}}/locations/{{location}}/boundary'
24+
# Singleton resource, point create_url to update_url.
25+
create_url: 'projects/{{project}}/locations/{{location}}/boundary'
26+
create_verb: 'PATCH'
27+
update_url: 'projects/{{project}}/locations/{{location}}/boundary'
28+
update_verb: 'PATCH'
29+
exclude_delete: true
30+
id_format: 'projects/{{project}}/locations/{{location}}/boundary'
31+
import_format:
32+
- "projects/{{project}}/locations/{{location}}/boundary"
33+
autogen_async: true
34+
async:
35+
actions: ['create', 'update']
36+
type: 'OpAsync'
37+
operation:
38+
base_url: '{{op_id}}'
39+
result:
40+
resource_inside_response: true
41+
parameters:
42+
- name: 'location'
43+
type: String
44+
description: 'The location for the Boundary resource. Must be global.'
45+
url_param_only: true
46+
immutable: true
47+
required: true
48+
properties:
49+
- name: name
50+
type: String
51+
description: |-
52+
Identifier. The resource name of the boundary.
53+
Format: "projects/{project}/locations/{{location}}/boundary"
54+
output: true
55+
- name: crmNode
56+
type: String
57+
description: |-
58+
Optional. The resource name of the CRM node being attached to the
59+
boundary.
60+
Format: `projects/{project-number}`
61+
- name: createTime
62+
type: Time
63+
description: 'Create time.'
64+
output: true
65+
- name: updateTime
66+
type: Time
67+
description: ' Update time.'
68+
output: true
69+
- name: type
70+
type: Enum
71+
description: 'Boundary type.'
72+
output: true
73+
enum_values:
74+
- AUTOMATIC
75+
- MANUAL
76+
- MANAGED_AUTOMATIC
77+
78+
examples:
79+
- name: 'apphub_boundary_basic'
80+
primary_resource_id: 'example'
81+
test_env_vars:
82+
crm_node_project_number: 'PROJECT_NUMBER'
83+
exclude_test: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "google_apphub_boundary" "{{$.PrimaryResourceId}}" {
2+
location = "global"
3+
crm_node = "projects/{{index $.TestEnvVars "crm_node_project_number"}}"
4+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package apphub_test
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"strconv"
7+
"strings"
8+
"testing"
9+
"time"
10+
11+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
12+
"github.com/hashicorp/terraform-plugin-testing/terraform"
13+
14+
"github.com/hashicorp/terraform-provider-google/google/acctest"
15+
"github.com/hashicorp/terraform-provider-google/google/envvar"
16+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
17+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
18+
19+
"google.golang.org/api/googleapi"
20+
)
21+
22+
var (
23+
_ = fmt.Sprintf
24+
_ = log.Print
25+
_ = strconv.Atoi
26+
_ = strings.Trim
27+
_ = time.Now
28+
_ = resource.TestMain
29+
_ = terraform.NewState
30+
_ = envvar.TestEnvVar
31+
_ = tpgresource.SetLabels
32+
_ = transport_tpg.Config{}
33+
_ = googleapi.Error{}
34+
)
35+
36+
func TestAccApphubBoundary_apphubBoundary_update(t *testing.T) {
37+
t.Parallel()
38+
39+
context := map[string]interface{}{
40+
"crm_node_project_number": envvar.GetTestProjectNumberFromEnv(),
41+
"random_suffix": acctest.RandString(t, 10),
42+
}
43+
44+
acctest.VcrTest(t, resource.TestCase{
45+
PreCheck: func() { acctest.AccTestPreCheck(t) },
46+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
47+
Steps: []resource.TestStep{
48+
{
49+
Config: testAccApphubBoundary_apphubBoundaryBasicExample(context),
50+
},
51+
{
52+
ResourceName: "google_apphub_boundary.example",
53+
ImportState: true,
54+
ImportStateVerify: true,
55+
ImportStateVerifyIgnore: []string{"location"},
56+
},
57+
{
58+
Config: testAccApphubBoundary_apphubBoundaryNoCrmNode(context),
59+
},
60+
{
61+
ResourceName: "google_apphub_boundary.example",
62+
ImportState: true,
63+
ImportStateVerify: true,
64+
ImportStateVerifyIgnore: []string{"location"},
65+
},
66+
},
67+
})
68+
}
69+
70+
func testAccApphubBoundary_apphubBoundaryBasicExample(context map[string]interface{}) string {
71+
return acctest.Nprintf(`
72+
resource "google_apphub_boundary" "example" {
73+
location = "global"
74+
crm_node = "projects/%{crm_node_project_number}"
75+
}
76+
`, context)
77+
}
78+
79+
func testAccApphubBoundary_apphubBoundaryNoCrmNode(context map[string]interface{}) string {
80+
return acctest.Nprintf(`
81+
resource "google_apphub_boundary" "example" {
82+
location = "global"
83+
}
84+
`, context)
85+
}

0 commit comments

Comments
 (0)