Skip to content

Commit 0054497

Browse files
edwinfrancissDawid212
authored andcommitted
Add HostProjectRegistration resource in API hub (GoogleCloudPlatform#13092)
1 parent 734381c commit 0054497

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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: HostProjectRegistration
16+
description: |-
17+
Host project registration refers to the registration of a Google cloud project with API hub as a host project.
18+
This is the project where API hub is provisioned.
19+
It acts as the consumer project for the API hub instance provisioned.
20+
Multiple runtime projects can be attached to the host project and these attachments define the scope of API hub.
21+
base_url: projects/{{project}}/locations/{{location}}/hostProjectRegistrations
22+
immutable: true
23+
self_link: projects/{{project}}/locations/{{location}}/hostProjectRegistrations/{{host_project_registration_id}}
24+
create_url: projects/{{project}}/locations/{{location}}/hostProjectRegistrations?hostProjectRegistrationId={{host_project_registration_id}}
25+
id_format: projects/{{project}}/locations/{{location}}/hostProjectRegistrations/{{host_project_registration_id}}
26+
import_format:
27+
- projects/{{project}}/locations/{{location}}/hostProjectRegistrations/{{host_project_registration_id}}
28+
examples:
29+
- name: apihub_host_project_registration_basic
30+
primary_resource_id: apihub_host_project
31+
vars:
32+
project_id: 'apihub-proj'
33+
test_env_vars:
34+
org_id: 'ORG_ID'
35+
billing_account: 'BILLING_ACCT'
36+
external_providers: ["time"]
37+
exclude_delete: true
38+
autogen_status: SG9zdFByb2plY3RSZWdpc3RyYXRpb24=
39+
parameters:
40+
- name: location
41+
type: String
42+
description: Part of `parent`. See documentation of `projectsId`.
43+
immutable: true
44+
url_param_only: true
45+
required: true
46+
- name: hostProjectRegistrationId
47+
type: String
48+
description: |-
49+
Required. The ID to use for the Host Project Registration, which will become the
50+
final component of the host project registration's resource name. The ID
51+
must be the same as the Google cloud project specified in the
52+
host_project_registration.gcp_project field.
53+
immutable: true
54+
url_param_only: true
55+
required: true
56+
properties:
57+
- name: name
58+
type: String
59+
description: |-
60+
Identifier. The name of the host project registration.
61+
Format:
62+
"projects/{project}/locations/{location}/hostProjectRegistrations/{host_project_registration}".
63+
output: true
64+
- name: gcpProject
65+
type: String
66+
description: |-
67+
Required. Immutable. Google cloud project name in the format: "projects/abc" or "projects/123".
68+
As input, project name with either project id or number are accepted.
69+
As output, this field will contain project number.
70+
immutable: true
71+
required: true
72+
diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
73+
- name: createTime
74+
type: String
75+
description: Output only. The time at which the host project registration was created.
76+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resource "google_project" "project" {
2+
name = "{{index $.Vars "project_id"}}"
3+
project_id = "{{index $.Vars "project_id"}}"
4+
org_id = "{{index $.TestEnvVars "org_id"}}"
5+
billing_account = "{{index $.TestEnvVars "billing_account"}}"
6+
deletion_policy = "DELETE"
7+
}
8+
9+
resource "time_sleep" "wait_60_seconds" {
10+
create_duration = "60s"
11+
depends_on = [google_project.project]
12+
}
13+
14+
# Enable API hub API
15+
resource "google_project_service" "apihub_service" {
16+
project = google_project.project.project_id
17+
service = "apihub.googleapis.com"
18+
depends_on = [time_sleep.wait_60_seconds]
19+
}
20+
21+
resource "google_apihub_host_project_registration" "{{$.PrimaryResourceId}}"{
22+
project = google_project.project.project_id
23+
location = "asia-south1"
24+
host_project_registration_id = google_project.project.project_id
25+
gcp_project = "projects/${google_project.project.project_id}"
26+
27+
depends_on = [google_project_service.apihub_service]
28+
}

0 commit comments

Comments
 (0)