Skip to content

Commit

Permalink
Move assertion ref to attribute mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcurtis committed Sep 2, 2023
1 parent c943002 commit f22d717
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ repos:
- id: no-commit-to-branch

- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.81.0
rev: v1.83.0
hooks:
- id: terraform_fmt
- id: terraform_validate
args:
- --hook-config=--retry-once-with-cleanup=true
- --tf-init-args=-upgrade
- id: terraform_docs
args:
- --hook-config=--path-to-file=README.md
Expand Down
2 changes: 1 addition & 1 deletion global/infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ No requirements.

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | 4.72.0 |
| <a name="provider_google"></a> [google](#provider\_google) | 4.80.0 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.5.1 |

## Modules
Expand Down
2 changes: 2 additions & 0 deletions global/infra/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ locals {
}

"plt-lz-backend" = {
github_ref = var.environment == "sb" ? null : "refs/heads/main"
github_repositories = ["google-cloud-terraform-backend"]
billing_user_group_manager = true
}
Expand Down Expand Up @@ -66,6 +67,7 @@ locals {
for repository in name.github_repositories : {
name = service_account_key
repository = repository
ref = lookup(local.service_accounts[service_account_key], "github_ref", null)
}
]
]) : service_account.repository => service_account }
Expand Down
3 changes: 2 additions & 1 deletion global/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ resource "google_service_account" "github_actions" {
resource "google_service_account_iam_member" "github_actions" {
for_each = local.github_repositories

member = "principalSet://iam.googleapis.com/${var.workload_identity_pool_name}/attribute.repository/osinfra-io/${each.value.repository}"
#member = "principalSet://iam.googleapis.com/${var.workload_identity_pool_name}/attribute.repository/osinfra-io/${each.value.repository}/attribute.ref/${each.value.ref}}"
member = lookup(each.value, "github_ref", null) == null ? "principalSet://iam.googleapis.com/${var.workload_identity_pool_name}/attribute.repository/osinfra-io/${each.value.repository}" : "principalSet://iam.googleapis.com/${var.workload_identity_pool_name}/attribute.repository/osinfra-io/${each.value.repository}/attribute.ref/${each.value.ref}"
role = "roles/iam.workloadIdentityUser"
service_account_id = google_service_account.github_actions[each.value.name].id
}
Expand Down

0 comments on commit f22d717

Please sign in to comment.