Skip to content

Commit 9d7cced

Browse files
jimmygnsPhilip Jonany
authored and
Philip Jonany
committed
Add Developer connect to terraform beta (GoogleCloudPlatform#11623)
1 parent 6409e66 commit 9d7cced

10 files changed

+528
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
--- !ruby/object:Api::Resource
14+
base_url: projects/{{project}}/locations/{{location}}/connections
15+
create_url: projects/{{project}}/locations/{{location}}/connections?connectionId={{connection_id}}
16+
self_link: projects/{{project}}/locations/{{location}}/connections/{{connection_id}}
17+
id_format: projects/{{project}}/locations/{{location}}/connections/{{connection_id}}
18+
import_format:
19+
- projects/{{project}}/locations/{{location}}/connections/{{connection_id}}
20+
examples:
21+
- !ruby/object:Provider::Terraform::Examples
22+
min_version: beta
23+
name: "developer_connect_connection_basic"
24+
primary_resource_id: "my-connection"
25+
primary_resource_name: "fmt.Sprintf(\"tf-test-connection%s\",
26+
context[\"random_suffix\"\
27+
])"
28+
vars:
29+
connection_name: "tf-test-connection"
30+
- !ruby/object:Provider::Terraform::Examples
31+
min_version: beta
32+
name: "developer_connect_connection_github_doc"
33+
skip_test: true
34+
name: Connection
35+
description: "A connection to a GitHub App installation."
36+
min_version: "beta"
37+
update_verb: :PATCH
38+
update_mask: true
39+
autogen_async: true
40+
parameters:
41+
- !ruby/object:Api::Type::String
42+
name: location
43+
description:
44+
"Resource ID segment making up resource `name`. It identifies the resource
45+
within its parent collection as described in https://google.aip.dev/122. See documentation
46+
for resource type `developerconnect.googleapis.com/GitRepositoryLink`. "
47+
url_param_only: true
48+
required: true
49+
immutable: true
50+
- !ruby/object:Api::Type::String
51+
name: connectionId
52+
description:
53+
"Required. Id of the requesting object\nIf auto-generating Id server-side,
54+
remove this field and\nconnection_id from the method_signature of Create RPC "
55+
url_param_only: true
56+
required: true
57+
immutable: true
58+
async: !ruby/object:Api::OpAsync
59+
operation: !ruby/object:Api::OpAsync::Operation
60+
path: name
61+
base_url: "{{op_id}}"
62+
wait_ms: 1000
63+
timeouts:
64+
result: !ruby/object:Api::OpAsync::Result
65+
path: response
66+
resource_inside_response: true
67+
status: !ruby/object:Api::OpAsync::Status
68+
path: done
69+
complete: true
70+
allowed:
71+
- true
72+
- false
73+
error: !ruby/object:Api::OpAsync::Error
74+
path: error
75+
message: message
76+
properties:
77+
- !ruby/object:Api::Type::NestedObject
78+
name: githubConfig
79+
description: "Configuration for connections to github.com. "
80+
properties:
81+
- !ruby/object:Api::Type::String
82+
name: githubApp
83+
description:
84+
"Required. Immutable. The GitHub Application that was installed to
85+
the GitHub user or\norganization. \n Possible values:\n GIT_HUB_APP_UNSPECIFIED\nDEVELOPER_CONNECT\nFIREBASE"
86+
required: true
87+
immutable: true
88+
- !ruby/object:Api::Type::NestedObject
89+
name: authorizerCredential
90+
description:
91+
"Represents an OAuth token of the account that authorized the Connection,\nand
92+
associated metadata. "
93+
properties:
94+
- !ruby/object:Api::Type::String
95+
name: oauthTokenSecretVersion
96+
description:
97+
"Required. A SecretManager resource containing the OAuth token
98+
that authorizes\nthe connection. Format: `projects/*/secrets/*/versions/*`. "
99+
required: true
100+
- !ruby/object:Api::Type::String
101+
name: username
102+
description: "Output only. The username associated with this token. "
103+
output: true
104+
- !ruby/object:Api::Type::String
105+
name: appInstallationId
106+
description: "Optional. GitHub App installation id. "
107+
- !ruby/object:Api::Type::String
108+
name: installationUri
109+
description:
110+
"Output only. The URI to navigate to in order to manage the installation
111+
associated\nwith this GitHubConfig. "
112+
output: true
113+
- !ruby/object:Api::Type::String
114+
name: name
115+
description: "Identifier. The resource name of the connection, in the format\n`projects/{project}/locations/{location}/connections/{connection_id}`. "
116+
output: true
117+
- !ruby/object:Api::Type::String
118+
name: createTime
119+
description: "Output only. [Output only] Create timestamp "
120+
output: true
121+
- !ruby/object:Api::Type::String
122+
name: updateTime
123+
description: "Output only. [Output only] Update timestamp "
124+
output: true
125+
- !ruby/object:Api::Type::String
126+
name: deleteTime
127+
description: "Output only. [Output only] Delete timestamp "
128+
output: true
129+
- !ruby/object:Api::Type::KeyValueLabels
130+
name: labels
131+
description: "Optional. Labels as key value pairs "
132+
- !ruby/object:Api::Type::NestedObject
133+
name: installationState
134+
description:
135+
"Describes stage and necessary actions to be taken by the\nuser to
136+
complete the installation. Used for GitHub and GitHub Enterprise\nbased connections. "
137+
output: true
138+
properties:
139+
- !ruby/object:Api::Type::String
140+
name: stage
141+
description:
142+
"Output only. Current step of the installation process. \n Possible
143+
values:\n STAGE_UNSPECIFIED\nPENDING_CREATE_APP\nPENDING_USER_OAUTH\nPENDING_INSTALL_APP\nCOMPLETE"
144+
output: true
145+
- !ruby/object:Api::Type::String
146+
name: message
147+
description:
148+
"Output only. Message of what the user should do next to continue
149+
the installation.\nEmpty string if the installation is already complete. "
150+
- !ruby/object:Api::Type::String
151+
name: actionUri
152+
description:
153+
"Output only. Link to follow for next action. Empty string if the
154+
installation is already\ncomplete. "
155+
- !ruby/object:Api::Type::Boolean
156+
name: disabled
157+
description:
158+
"Optional. If disabled is set to true, functionality is disabled for
159+
this connection.\nRepository based API methods and webhooks processing for repositories
160+
in\nthis connection will be disabled. "
161+
- !ruby/object:Api::Type::Boolean
162+
name: reconciling
163+
description:
164+
"Output only. Set to true when the connection is being set up or updated
165+
in the\nbackground. "
166+
output: true
167+
- !ruby/object:Api::Type::KeyValueAnnotations
168+
name: annotations
169+
description: "Optional. Allows clients to store small amounts of arbitrary data. "
170+
- !ruby/object:Api::Type::String
171+
name: etag
172+
description:
173+
"Optional. This checksum is computed by the server based on the value
174+
of other\nfields, and may be sent on update and delete requests to ensure the\nclient
175+
has an up-to-date value before proceeding. "
176+
- !ruby/object:Api::Type::String
177+
name: uid
178+
description: "Output only. A system-assigned unique identifier for a the GitRepositoryLink. "
179+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
--- !ruby/object:Api::Resource
2+
base_url: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks
3+
create_url: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks?gitRepositoryLinkId={{git_repository_link_id}}
4+
self_link: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}
5+
id_format: projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}
6+
import_format:
7+
- projects/{{project}}/locations/{{location}}/connections/{{parent_connection}}/gitRepositoryLinks/{{git_repository_link_id}}
8+
examples:
9+
# These tests depend on secrets stored in a separate project, so we prefer not
10+
# to show them in the docs.
11+
- !ruby/object:Provider::Terraform::Examples
12+
name: "developer_connect_git_repository_link_github"
13+
primary_resource_id: "primary"
14+
skip_docs: true
15+
min_version: beta
16+
vars:
17+
connection_name: "my-connection"
18+
git_repository_link_name: "my-repository"
19+
- !ruby/object:Provider::Terraform::Examples
20+
name: "developer_connect_git_repository_link_github_doc"
21+
min_version: beta
22+
skip_test: true
23+
name: GitRepositoryLink
24+
description: "A git repository link to a parent connection."
25+
min_version: "beta"
26+
autogen_async: true
27+
parameters:
28+
- !ruby/object:Api::Type::String
29+
name: location
30+
description:
31+
"Resource ID segment making up resource `name`. It identifies the resource
32+
within its parent collection as described in https://google.aip.dev/122. See documentation
33+
for resource type `developerconnect.googleapis.com/GitRepositoryLink`. "
34+
url_param_only: true
35+
required: true
36+
immutable: true
37+
- !ruby/object:Api::Type::String
38+
name: parent_connection
39+
description:
40+
"Resource ID segment making up resource `name`. It identifies the resource
41+
within its parent collection as described in https://google.aip.dev/122. See documentation
42+
for resource type `developerconnect.googleapis.com/GitRepositoryLink`. "
43+
url_param_only: true
44+
required: true
45+
immutable: true
46+
- !ruby/object:Api::Type::String
47+
name: gitRepositoryLinkId
48+
description:
49+
"Required. The ID to use for the repository, which will become the
50+
final component of\nthe repository's resource name. This ID should be unique in
51+
the connection.\nAllows alphanumeric characters and any of -._~%!$&'()*+,;=@. "
52+
url_param_only: true
53+
required: true
54+
immutable: true
55+
async: !ruby/object:Api::OpAsync
56+
operation: !ruby/object:Api::OpAsync::Operation
57+
path: name
58+
base_url: "{{op_id}}"
59+
wait_ms: 1000
60+
timeouts:
61+
result: !ruby/object:Api::OpAsync::Result
62+
path: response
63+
resource_inside_response: true
64+
status: !ruby/object:Api::OpAsync::Status
65+
path: done
66+
complete: true
67+
allowed:
68+
- true
69+
- false
70+
error: !ruby/object:Api::OpAsync::Error
71+
path: error
72+
message: message
73+
immutable: true
74+
properties:
75+
- !ruby/object:Api::Type::String
76+
name: name
77+
description: "Identifier. Resource name of the repository, in the format\n`projects/*/locations/*/connections/*/gitRepositoryLinks/*`. "
78+
output: true
79+
- !ruby/object:Api::Type::String
80+
name: cloneUri
81+
description: "Required. Git Clone URI. "
82+
required: true
83+
- !ruby/object:Api::Type::String
84+
name: createTime
85+
description: "Output only. [Output only] Create timestamp "
86+
output: true
87+
- !ruby/object:Api::Type::String
88+
name: updateTime
89+
description: "Output only. [Output only] Update timestamp "
90+
output: true
91+
- !ruby/object:Api::Type::String
92+
name: deleteTime
93+
description: "Output only. [Output only] Delete timestamp "
94+
output: true
95+
- !ruby/object:Api::Type::KeyValueLabels
96+
name: labels
97+
description: "Optional. Labels as key value pairs "
98+
- !ruby/object:Api::Type::String
99+
name: etag
100+
description:
101+
"Optional. This checksum is computed by the server based on the value
102+
of other\nfields, and may be sent on update and delete requests to ensure the\nclient
103+
has an up-to-date value before proceeding. "
104+
- !ruby/object:Api::Type::Boolean
105+
name: reconciling
106+
description:
107+
"Output only. Set to true when the connection is being set up or updated
108+
in the\nbackground. "
109+
output: true
110+
- !ruby/object:Api::Type::KeyValueAnnotations
111+
name: annotations
112+
description: "Optional. Allows clients to store small amounts of arbitrary data. "
113+
- !ruby/object:Api::Type::String
114+
name: uid
115+
description: "Output only. A system-assigned unique identifier for a the GitRepositoryLink. "
116+
output: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- !ruby/object:Api::Product
2+
versions:
3+
- !ruby/object:Api::Product::Version
4+
base_url: https://developerconnect.googleapis.com/v1/
5+
name: beta
6+
name: DeveloperConnect
7+
display_name: Developer Connect
8+
scopes:
9+
- https://www.googleapis.com/auth/cloud-platform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resource "google_developer_connect_connection" "<%= ctx[:primary_resource_id] %>" {
2+
provider = google-beta
3+
location = "us-central1"
4+
connection_id = "<%= ctx[:vars]['connection_name'] %>"
5+
6+
github_config {
7+
github_app = "DEVELOPER_CONNECT"
8+
9+
authorizer_credential {
10+
oauth_token_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1"
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
resource "google_secret_manager_secret" "github-token-secret" {
2+
3+
provider = google-beta
4+
secret_id = "github-token-secret"
5+
6+
replication {
7+
auto {}
8+
}
9+
}
10+
11+
resource "google_secret_manager_secret_version" "github-token-secret-version" {
12+
13+
provider = google-beta
14+
secret = google_secret_manager_secret.github-token-secret.id
15+
secret_data = file("my-github-token.txt")
16+
}
17+
18+
data "google_iam_policy" "p4sa-secretAccessor" {
19+
binding {
20+
role = "roles/secretmanager.secretAccessor"
21+
// Here, 123456789 is the Google Cloud project number for the project that contains the connection.
22+
members = ["serviceAccount:[email protected]"]
23+
}
24+
}
25+
26+
resource "google_secret_manager_secret_iam_policy" "policy" {
27+
28+
provider = google-beta
29+
secret_id = google_secret_manager_secret.github-token-secret.secret_id
30+
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data
31+
}
32+
33+
resource "google_developer_connect_connection" "my-connection" {
34+
35+
provider = google-beta
36+
location = "us-central1"
37+
connection_id = "my-connection"
38+
39+
github_config {
40+
github_app = "DEVELOPER_CONNECT"
41+
app_installation_id = 123123
42+
authorizer_credential {
43+
oauth_token_secret_version = google_secret_manager_secret_version.github-token-secret-version.id
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
resource "google_developer_connect_git_repository_link" "<%= ctx[:primary_resource_id] %>" {
2+
provider = google-beta
3+
git_repository_link_id = "<%= ctx[:vars]['git_repository_link_name'] %>"
4+
parent_connection = google_developer_connect_connection.github_conn.connection_id
5+
clone_uri = "https://github.com/gcb-developerconnect-robot/tf-demo.git"
6+
location = "us-central1"
7+
annotations = {}
8+
}
9+
10+
resource "google_developer_connect_connection" "github_conn" {
11+
12+
provider = google-beta
13+
location = "us-central1"
14+
connection_id = "<%= ctx[:vars]['connection_name'] %>"
15+
disabled = false
16+
17+
github_config {
18+
github_app = "DEVELOPER_CONNECT"
19+
app_installation_id = 49439208
20+
21+
authorizer_credential {
22+
oauth_token_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1"
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)