forked from jsr-io/jsr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oidc.tf
38 lines (34 loc) · 1.57 KB
/
oidc.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2024 the JSR authors. All rights reserved. MIT license.
resource "google_iam_workload_identity_pool" "github_actions" {
workload_identity_pool_id = "github-actions"
display_name = "GitHub Actions"
description = "Identity pool for Deno Deploy requests from GitHub Actions"
}
resource "google_iam_workload_identity_pool_provider" "github_actions" {
workload_identity_pool_id = google_iam_workload_identity_pool.github_actions.workload_identity_pool_id
workload_identity_pool_provider_id = "github-actions"
oidc {
issuer_uri = "https://token.actions.githubusercontent.com"
}
attribute_mapping = {
"google.subject" = "assertion.sub"
"attribute.actor" = "assertion.actor"
"attribute.repository" = "assertion.repository"
"attribute.environment" = "assertion.environment"
}
attribute_condition = "assertion.repository == 'jsr-io/jsr'"
}
resource "google_service_account" "github_actions" {
account_id = "github-actions"
display_name = "Service account for GitHub Actions"
}
resource "google_project_iam_member" "github_actions_iam_owner" {
project = var.gcp_project
role = "roles/owner"
member = "serviceAccount:${google_service_account.github_actions.email}"
}
resource "google_service_account_iam_member" "github_actions_iam_workload_identity_user" {
service_account_id = google_service_account.github_actions.name
role = "roles/iam.workloadIdentityUser"
member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.github_actions.name}/*"
}