@@ -25,30 +25,71 @@ A connection to a GitHub App installation.
25
25
See [ Provider Versions] ( https://terraform.io/docs/providers/google/guides/provider_versions.html ) for more details on beta resources.
26
26
27
27
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
+ ```
28
64
<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 " >
30
66
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
31
67
</a >
32
68
</div >
33
- ## Example Usage - Developer Connect Connection Basic
69
+ ## Example Usage - Developer Connect Connection Existing Credentials
34
70
35
71
36
72
``` hcl
37
73
resource "google_developer_connect_connection" "my-connection" {
38
74
provider = google-beta
39
75
location = "us-central1"
40
- connection_id = "tf-test-connection"
76
+ connection_id = "tf-test-connection-cred "
41
77
42
78
github_config {
43
79
github_app = "DEVELOPER_CONNECT"
44
80
45
81
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 "
47
83
}
48
84
}
49
85
}
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
+ }
50
91
```
51
- ## Example Usage - Developer Connect Connection Github Doc
92
+ ## Example Usage - Developer Connect Connection Existing Installation
52
93
53
94
54
95
``` hcl
@@ -69,11 +110,17 @@ resource "google_secret_manager_secret_version" "github-token-secret-version" {
69
110
secret_data = file("my-github-token.txt")
70
111
}
71
112
113
+ resource "google_project_service_identity" "devconnect-p4sa" {
114
+ provider = google-beta
115
+
116
+ service = "developerconnect.googleapis.com"
117
+ }
118
+
72
119
data "google_iam_policy" "p4sa-secretAccessor" {
73
120
binding {
74
121
role = "roles/secretmanager.secretAccessor"
75
122
// 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 ]
77
124
}
78
125
}
79
126
0 commit comments