Created
October 15, 2022 08:47
-
-
Save CJ1138/b4039ef05cd79684aa46db60d7b1954e to your computer and use it in GitHub Desktop.
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
#Workload Identity Federation | |
resource "google_iam_workload_identity_pool" "counter-wi-pool" { | |
workload_identity_pool_id = "counter-wi-pool" | |
display_name = "Visitor Counter WI Pool" | |
} | |
resource "google_iam_workload_identity_pool_provider" "github_wi_provider" { | |
workload_identity_pool_id = google_iam_workload_identity_pool.counter-wi-pool.workload_identity_pool_id | |
workload_identity_pool_provider_id = "github-provider" | |
display_name = "GitHub Actions" | |
attribute_mapping = { | |
"google.subject" = "assertion.sub" | |
"attribute.actor" = "assertion.actor" | |
"attribute.repository" = "assertion.repository" | |
} | |
oidc { | |
issuer_uri = "https://token.actions.githubusercontent.com" | |
} | |
} | |
resource "google_service_account_iam_binding" "service-account-iam" { | |
service_account_id = google_service_account.gh_actions_account.id | |
role = "roles/iam.workloadIdentityUser" | |
members = [ | |
var.wif_repo | |
] | |
depends_on = [ | |
google_service_account.gh_actions_account | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment