diff --git a/.changelog/12493.txt b/.changelog/12493.txt new file mode 100644 index 00000000000..ccc66093f75 --- /dev/null +++ b/.changelog/12493.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +developerconnect: added support for setting up a brand new `google_developer_connect_connection` +``` \ No newline at end of file diff --git a/website/docs/r/developer_connect_connection.html.markdown b/website/docs/r/developer_connect_connection.html.markdown index 41928170f5d..dda4083bda1 100644 --- a/website/docs/r/developer_connect_connection.html.markdown +++ b/website/docs/r/developer_connect_connection.html.markdown @@ -25,30 +25,71 @@ A connection to a GitHub App installation. See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. +## Example Usage - Developer Connect Connection New + + +```hcl +resource "google_developer_connect_connection" "my-connection" { + provider = google-beta + location = "us-central1" + connection_id = "tf-test-connection-new" + + github_config { + github_app = "FIREBASE" + } + + depends_on = [google_project_iam_member.devconnect-secret] +} + +output "next_steps" { + description = "Follow the action_uri if present to continue setup" + value = google_developer_connect_connection.my-connection.installation_state +} + +# Setup permissions. Only needed once per project +resource "google_project_service_identity" "devconnect-p4sa" { + provider = google-beta + + service = "developerconnect.googleapis.com" +} + +resource "google_project_iam_member" "devconnect-secret" { + provider = google-beta + + project = "my-project-name" + role = "roles/secretmanager.admin" + member = google_project_service_identity.devconnect-p4sa.member +} +```
-## Example Usage - Developer Connect Connection Basic +## Example Usage - Developer Connect Connection Existing Credentials ```hcl resource "google_developer_connect_connection" "my-connection" { provider = google-beta location = "us-central1" - connection_id = "tf-test-connection" + connection_id = "tf-test-connection-cred" github_config { github_app = "DEVELOPER_CONNECT" authorizer_credential { - oauth_token_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-do-not-change-github-oauthtoken-e0b9e7/versions/1" + oauth_token_secret_version = "projects/your-project/secrets/your-secret-id/versions/latest" } } } + +output "next_steps" { + description = "Follow the action_uri if present to continue setup" + value = google_developer_connect_connection.my-connection.installation_state +} ``` -## Example Usage - Developer Connect Connection Github Doc +## Example Usage - Developer Connect Connection Existing Installation ```hcl @@ -69,11 +110,17 @@ resource "google_secret_manager_secret_version" "github-token-secret-version" { secret_data = file("my-github-token.txt") } +resource "google_project_service_identity" "devconnect-p4sa" { + provider = google-beta + + service = "developerconnect.googleapis.com" +} + data "google_iam_policy" "p4sa-secretAccessor" { binding { role = "roles/secretmanager.secretAccessor" // Here, 123456789 is the Google Cloud project number for the project that contains the connection. - members = ["serviceAccount:service-123456789@gcp-sa-devconnect.iam.gserviceaccount.com"] + members = [google_project_service_identity.devconnect-p4sa.member] } }