Skip to content

Commit 30f361e

Browse files
authoredJun 9, 2024··
Add a catalog-syncer service account. (#26)
Signed-off-by: Matt Moore <mattmoor@chainguard.dev>
1 parent c66162c commit 30f361e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
 

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ No modules.
5959
|------|------|
6060
| [google-beta_google_iam_workload_identity_pool.chainguard_pool](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_iam_workload_identity_pool) | resource |
6161
| [google-beta_google_iam_workload_identity_pool_provider.chainguard_provider](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_iam_workload_identity_pool_provider) | resource |
62+
| [google_project_iam_member.catalog-syncer-push](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_member) | resource |
6263
| [google_project_service.iamcredentials-api](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_service) | resource |
64+
| [google_service_account.catalog-syncer](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
6365
| [google_service_account.chainguard_canary](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
6466
| [google_service_account_iam_binding.allow_canary_impersonation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account_iam_binding) | resource |
67+
| [google_service_account_iam_binding.catalog-syncer-impersonation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account_iam_binding) | resource |
6568

6669
## Inputs
6770

‎catalog-syncer.tf

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// The service account to impersonate
2+
resource "google_service_account" "catalog-syncer" {
3+
project = var.project_id
4+
account_id = "chainguard-catalog-syncer"
5+
depends_on = [google_project_service.iamcredentials-api]
6+
}
7+
8+
// Allow the provider (mapped token) to impersonate this service account if
9+
// the subject matches what we expect.
10+
resource "google_service_account_iam_binding" "catalog-syncer-impersonation" {
11+
service_account_id = google_service_account.catalog-syncer.name
12+
role = "roles/iam.workloadIdentityUser"
13+
members = [for id in var.group_ids : "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.chainguard_pool.name}/attribute.sub/catalog-syncer:${id}"]
14+
}
15+
16+
// Grant the service account permissions to access the resources it
17+
// needs to fulfill its purpose.
18+
resource "google_project_iam_member" "catalog-syncer-push" {
19+
project = var.project_id
20+
role = "roles/artifactregistry.writer"
21+
member = "serviceAccount:${google_service_account.catalog-syncer.email}"
22+
}

0 commit comments

Comments
 (0)
Please sign in to comment.