Skip to content

Commit

Permalink
Add updated doc examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnarayanan committed Dec 17, 2024
1 parent dfe76f6 commit 0a6f24d
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
resource "google_secret_manager_secret" "github-enterprise-token-secret" {

secret_id = "github-enterprise-token-secret"
resource "google_secret_manager_secret" "private-key-secret" {
secret_id = "ghe-pk-secret"

replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "github-enterprise-token-secret-version" {
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"

secret = google_secret_manager_secret.github-enterprise-token-secret.id
secret_data = file("my-github-enterprise-token.txt")
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" {
Expand All @@ -21,22 +32,30 @@ data "google_iam_policy" "p4sa-secretAccessor" {
}
}

resource "google_secret_manager_secret_iam_policy" "policy" {

secret_id = google_secret_manager_secret.github-enterprise-token-secret.secret_id
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_developer_connect_connection" "my-connection" {
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://devconnect-terraform.com"
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
authorizer_credential {
oauth_token_secret_version = google_secret_manager_secret_version.github-enterprise-token-secret-version.id
}
}

depends_on = [
google_secret_manager_secret_iam_policy.policy-pk,
google_secret_manager_secret_iam_policy.policy-whs
]
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
resource "google_secret_manager_secret" "gitlab-read-cred" {

resource "google_secret_manager_secret" "gitlab-read-cred-secret" {
secret_id = "gitlab-read-cred"

replication {
auto {}
}
}

resource "google_secret_manager_secret" "gitlab-auth-cred" {
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" "gitlab-webhook-secret" {
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-read-cred-version" {

secret = google_secret_manager_secret.gitlab-read-cred.id
secret_data = file("my-gitlab-read-cred.txt")
}

resource "google_secret_manager_secret_version" "gitlab-auth-cred-version" {

secret = google_secret_manager_secret.gitlab-auth-cred.id
secret_data = file("my-gitlab-auth-cred.txt")
}

resource "google_secret_manager_secret_version" "gitlab-webhook-secret-version" {

secret = google_secret_manager_secret.gitlab-webhook-secret.id
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" {
Expand All @@ -50,11 +41,18 @@ data "google_iam_policy" "p4sa-secretAccessor" {
}
}

resource "google_secret_manager_secret_iam_policy" "policy" {
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
}

secret_id = google_secret_manager_secret.gitlab-read-cred.secret_id
secret_id = google_secret_manager_secret.gitlab-auth-cred.secret_id
secret_id = google_secret_manager_secret.gitlab-webhook-secret.secret_id
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
}

Expand All @@ -64,14 +62,20 @@ resource "google_developer_connect_connection" "my-connection" {
connection_id = "my-connection"

gitlab_config {
webhook_secret_secret_version = google_secret_manager_secret_version.gitlab-webhook-secret-version.id
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-version.id
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-version.id
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
]
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,83 @@
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 {
host_uri: 'https://devconnect-terraform.com'
webhook_secret_secret_version: 'projects/terraform-proj/secrets/webhook-version/versions/latest'
read_authorizer_credential: 'glpat-some-read-auth-credential'
authorizer_credential: 'glpat-some-auth-credential'
gitlab_enterprise_config {
host_uri = "https://gle.com"

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
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ resource "google_developer_connect_git_repository_link" "my-repository" {
location = "us-central1"
git_repository_link_id = "my-repo"
parent_connection = google_developer_connect_connection.my-connection.connection_id
remote_uri = "https://github.com/myuser/myrepo.git"
clone_uri = "https://github.com/myuser/myrepo.git"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
resource "google_secret_manager_secret" "github-enterprise-token-secret" {
secret_id = "github-token-secret"
resource "google_secret_manager_secret" "private-key-secret" {
secret_id = "ghe-pk-secret"

replication {
auto {}
}
}

resource "google_secret_manager_secret_version" "github-enterprise-token-secret-version" {
secret = google_secret_manager_secret.github-token-secret.id
secret_data = file("my-github-enterprise-token.txt")
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" {
Expand All @@ -19,8 +32,13 @@ data "google_iam_policy" "p4sa-secretAccessor" {
}
}

resource "google_secret_manager_secret_iam_policy" "policy" {
secret_id = google_secret_manager_secret.github-enterprise-token-secret.secret_id
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
}

Expand All @@ -29,18 +47,22 @@ resource "google_developer_connect_connection" "my-connection" {
connection_id = "my-connection"

github_enterprise_config {
host_uri = "https://devconnect-terraform.com"
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
authorizer_credential {
oauth_token_secret_version = google_secret_manager_secret_version.github-token-secret-version.id
}
}

depends_on = [
google_secret_manager_secret_iam_policy.policy-pk,
google_secret_manager_secret_iam_policy.policy-whs
]
}

resource "google_developer_connect_git_repository_link" "my-repository" {
location = "us-central1"
git_repository_link_id = "my-repo"
parent_connection = google_developer_connect_connection.my-connection.connection_id
remote_uri = "https://devconnect-terraform.com/myuser/myrepo.git"
clone_uri = "https://ghe.com/myuser/myrepo.git"
}

Loading

0 comments on commit 0a6f24d

Please sign in to comment.