-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand Terraform for Developer Connect (#12391)
- Loading branch information
1 parent
1375842
commit 5ee445e
Showing
17 changed files
with
1,039 additions
and
204 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
mmv1/templates/terraform/examples/developer_connect_connection_github.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" { | ||
location = "us-central1" | ||
connection_id = "{{index $.Vars "connection_name"}}" | ||
|
||
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" | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
mmv1/templates/terraform/examples/developer_connect_connection_github_doc.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
resource "google_secret_manager_secret" "github-token-secret" { | ||
|
||
secret_id = "github-token-secret" | ||
|
||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "github-token-secret-version" { | ||
|
||
secret = google_secret_manager_secret.github-token-secret.id | ||
secret_data = file("my-github-token.txt") | ||
} | ||
|
||
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:[email protected]"] | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_policy" "policy" { | ||
|
||
secret_id = google_secret_manager_secret.github-token-secret.secret_id | ||
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data | ||
} | ||
|
||
resource "google_developer_connect_connection" "my-connection" { | ||
|
||
location = "us-central1" | ||
connection_id = "my-connection" | ||
|
||
github_config { | ||
github_app = "DEVELOPER_CONNECT" | ||
app_installation_id = 123123 | ||
authorizer_credential { | ||
oauth_token_secret_version = google_secret_manager_secret_version.github-token-secret-version.id | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
mmv1/templates/terraform/examples/developer_connect_connection_github_enterprise.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" { | ||
location = "us-central1" | ||
connection_id = "{{index $.Vars "connection_name"}}" | ||
|
||
github_enterprise_config { | ||
host_uri = "https://ghe.proctor-staging-test.com" | ||
app_id = 864434 | ||
private_key_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-ghe-do-not-change-ghe-private-key-f522d2/versions/latest" | ||
webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/tf-test-ghe-do-not-change-ghe-webhook-secret-3c806f/versions/latest" | ||
app_installation_id = 837537 | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
mmv1/templates/terraform/examples/developer_connect_connection_github_enterprise_doc.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
resource "google_secret_manager_secret" "private-key-secret" { | ||
secret_id = "ghe-pk-secret" | ||
|
||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "private-key-secret-version" { | ||
secret = google_secret_manager_secret.private-key-secret.id | ||
secret_data = file("private-key.pem") | ||
} | ||
|
||
resource "google_secret_manager_secret" "webhook-secret-secret" { | ||
secret_id = "ghe-token-secret" | ||
|
||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "webhook-secret-secret-version" { | ||
secret = google_secret_manager_secret.webhook-secret-secret.id | ||
secret_data = "<webhook-secret-data>" | ||
} | ||
|
||
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:[email protected]"] | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_policy" "policy-pk" { | ||
secret_id = google_secret_manager_secret.private-key-secret.secret_id | ||
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_policy" "policy-whs" { | ||
secret_id = google_secret_manager_secret.webhook-secret-secret.secret_id | ||
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data | ||
} | ||
|
||
resource "google_developer_connect_connection" "my-connection" { | ||
location = "us-central1" | ||
connection_id = "my-connection" | ||
|
||
github_enterprise_config { | ||
host_uri = "https://ghe.com" | ||
private_key_secret_version = google_secret_manager_secret_version.private-key-secret-version.id | ||
webhook_secret_secret_version = google_secret_manager_secret_version.webhook-secret-secret-version.id | ||
app_id = 100 | ||
app_installation_id = 123123 | ||
} | ||
|
||
depends_on = [ | ||
google_secret_manager_secret_iam_policy.policy-pk, | ||
google_secret_manager_secret_iam_policy.policy-whs | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
mmv1/templates/terraform/examples/developer_connect_connection_gitlab.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "google_developer_connect_connection" "{{$.PrimaryResourceId}}" { | ||
location = "us-central1" | ||
connection_id = "{{index $.Vars "connection_name"}}" | ||
|
||
gitlab_config { | ||
webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/gitlab-webhook/versions/latest" | ||
|
||
read_authorizer_credential { | ||
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/gitlab-read-cred/versions/latest" | ||
} | ||
|
||
authorizer_credential { | ||
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/gitlab-auth-cred/versions/latest" | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
mmv1/templates/terraform/examples/developer_connect_connection_gitlab_doc.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
resource "google_secret_manager_secret" "gitlab-read-cred-secret" { | ||
secret_id = "gitlab-read-cred" | ||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "gitlab-read-cred-secret-version" { | ||
secret = google_secret_manager_secret.gitlab-read-cred-secret.id | ||
secret_data = file("my-gitlab-read-cred.txt") | ||
} | ||
|
||
resource "google_secret_manager_secret" "gitlab-auth-cred-secret" { | ||
secret_id = "gitlab-auth-cred" | ||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "gitlab-auth-cred-secret-version" { | ||
secret = google_secret_manager_secret.gitlab-auth-cred-secret.id | ||
secret_data = file("my-gitlab-auth-cred.txt") | ||
} | ||
|
||
resource "google_secret_manager_secret" "gitlab-webhook-secret-secret" { | ||
secret_id = "gitlab-webhook-secret" | ||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "gitlab-webhook-secret-secret-version" { | ||
secret = google_secret_manager_secret.gitlab-webhook-secret-secret.id | ||
secret_data = file("my-gitlab-webhook-secret.txt") | ||
|
||
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:[email protected]"] | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_policy" "policy-rc" { | ||
secret_id = google_secret_manager_secret.gitlab-read-cred-secret.secret_id | ||
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_policy" "policy-ac" { | ||
secret_id = google_secret_manager_secret.gitlab-auth-cred-secret.secret_id | ||
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_policy" "policy-wh" { | ||
secret_id = google_secret_manager_secret.gitlab-webhook-secret-secret.secret_id | ||
policy_data = data.google_iam_policy.p4sa-secretAccessor.policy_data | ||
} | ||
|
||
resource "google_developer_connect_connection" "my-connection" { | ||
|
||
location = "us-central1" | ||
connection_id = "my-connection" | ||
|
||
gitlab_config { | ||
webhook_secret_secret_version = google_secret_manager_secret_version.gitlab-webhook-secret-secret-version.id | ||
|
||
read_authorizer_credential { | ||
user_token_secret_version = google_secret_manager_secret_version.gitlab-read-cred-secret-version.id | ||
} | ||
|
||
authorizer_credential { | ||
user_token_secret_version = google_secret_manager_secret_version.gitlab-auth-cred-secret-version.id | ||
} | ||
} | ||
|
||
depends_on = [ | ||
google_secret_manager_secret_iam_policy.policy-rc, | ||
google_secret_manager_secret_iam_policy.policy-ac, | ||
google_secret_manager_secret_iam_policy.policy-wh | ||
] | ||
} |
Oops, something went wrong.