Skip to content

Commit

Permalink
chore: use less privilege roles for ci service account (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w authored Jan 2, 2025
1 parent 6294316 commit 9c8cb6e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions examples/kms/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ resource "google_project_service_identity" "secretmanager_identity" {
service = "secretmanager.googleapis.com"
}

resource "time_sleep" "wait_service_identity_propagation" {
depends_on = [google_project_service_identity.secretmanager_identity]
create_duration = "180s"
}

resource "google_kms_crypto_key_iam_member" "sm_sa_encrypter_decrypter" {
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:${google_project_service_identity.secretmanager_identity.email}"
crypto_key_id = google_kms_crypto_key.crypto_key.id
depends_on = [time_sleep.wait_service_identity_propagation]
}

module "secret-manager" {
Expand Down
4 changes: 3 additions & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ spec:
roles:
- level: Project
roles:
- roles/owner
- roles/secretmanager.admin
- roles/cloudkms.admin
- roles/pubsub.admin
services:
- cloudresourcemanager.googleapis.com
- storage-api.googleapis.com
Expand Down
4 changes: 3 additions & 1 deletion modules/simple-secret/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ spec:
roles:
- level: Project
roles:
- roles/owner
- roles/secretmanager.admin
- roles/cloudkms.admin
- roles/pubsub.admin
services:
- cloudresourcemanager.googleapis.com
- storage-api.googleapis.com
Expand Down
4 changes: 3 additions & 1 deletion test/setup/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

locals {
int_required_roles = [
"roles/owner"
"roles/secretmanager.admin",
"roles/cloudkms.admin",
"roles/pubsub.admin",
]
}

Expand Down

0 comments on commit 9c8cb6e

Please sign in to comment.