Skip to content

Commit 296a14f

Browse files
Allow brand new setup for google_developer_connect_connection (#12493) (#20756)
[upstream:2c08e3c28009860b49e893f48b67b29619c8c3f8] Signed-off-by: Modular Magician <[email protected]>
1 parent a0e1d74 commit 296a14f

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

.changelog/12493.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
developerconnect: added support for setting up a brand new `google_developer_connect_connection`
3+
```

website/docs/r/developer_connect_connection.html.markdown

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,71 @@ A connection to a GitHub App installation.
2525
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
2626

2727

28+
## Example Usage - Developer Connect Connection New
29+
30+
31+
```hcl
32+
resource "google_developer_connect_connection" "my-connection" {
33+
provider = google-beta
34+
location = "us-central1"
35+
connection_id = "tf-test-connection-new"
36+
37+
github_config {
38+
github_app = "FIREBASE"
39+
}
40+
41+
depends_on = [google_project_iam_member.devconnect-secret]
42+
}
43+
44+
output "next_steps" {
45+
description = "Follow the action_uri if present to continue setup"
46+
value = google_developer_connect_connection.my-connection.installation_state
47+
}
48+
49+
# Setup permissions. Only needed once per project
50+
resource "google_project_service_identity" "devconnect-p4sa" {
51+
provider = google-beta
52+
53+
service = "developerconnect.googleapis.com"
54+
}
55+
56+
resource "google_project_iam_member" "devconnect-secret" {
57+
provider = google-beta
58+
59+
project = "my-project-name"
60+
role = "roles/secretmanager.admin"
61+
member = google_project_service_identity.devconnect-p4sa.member
62+
}
63+
```
2864
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
29-
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=developer_connect_connection_basic&open_in_editor=main.tf" target="_blank">
65+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=developer_connect_connection_existing_credentials&open_in_editor=main.tf" target="_blank">
3066
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
3167
</a>
3268
</div>
33-
## Example Usage - Developer Connect Connection Basic
69+
## Example Usage - Developer Connect Connection Existing Credentials
3470

3571

3672
```hcl
3773
resource "google_developer_connect_connection" "my-connection" {
3874
provider = google-beta
3975
location = "us-central1"
40-
connection_id = "tf-test-connection"
76+
connection_id = "tf-test-connection-cred"
4177
4278
github_config {
4379
github_app = "DEVELOPER_CONNECT"
4480
4581
authorizer_credential {
46-
oauth_token_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1"
82+
oauth_token_secret_version = "projects/your-project/secrets/your-secret-id/versions/latest"
4783
}
4884
}
4985
}
86+
87+
output "next_steps" {
88+
description = "Follow the action_uri if present to continue setup"
89+
value = google_developer_connect_connection.my-connection.installation_state
90+
}
5091
```
51-
## Example Usage - Developer Connect Connection Github Doc
92+
## Example Usage - Developer Connect Connection Existing Installation
5293

5394

5495
```hcl
@@ -69,11 +110,17 @@ resource "google_secret_manager_secret_version" "github-token-secret-version" {
69110
secret_data = file("my-github-token.txt")
70111
}
71112
113+
resource "google_project_service_identity" "devconnect-p4sa" {
114+
provider = google-beta
115+
116+
service = "developerconnect.googleapis.com"
117+
}
118+
72119
data "google_iam_policy" "p4sa-secretAccessor" {
73120
binding {
74121
role = "roles/secretmanager.secretAccessor"
75122
// Here, 123456789 is the Google Cloud project number for the project that contains the connection.
76-
members = ["serviceAccount:service-123456789@gcp-sa-devconnect.iam.gserviceaccount.com"]
123+
members = [google_project_service_identity.devconnect-p4sa.member]
77124
}
78125
}
79126

0 commit comments

Comments
 (0)