Skip to content

Commit 479e29d

Browse files
author
Nils
committed
more attributes
1 parent f0a8577 commit 479e29d

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ Attribute mapping:
7575

7676
| Name | Version |
7777
|------|---------|
78-
| <a name="provider_google"></a> [google](#provider\_google) | >= 4.61.0 |
78+
| <a name="provider_google"></a> [google](#provider\_google) | 4.62.0 |
7979

8080
## Inputs
8181

8282
| Name | Description | Type | Default | Required |
8383
|------|-------------|------|---------|:--------:|
84+
| <a name="input_attribute_mapping"></a> [attribute\_mapping](#input\_attribute\_mapping) | Workload Identity Pool Provider attribute mapping | `map(string)` | <pre>{<br> "attribute.actor": "assertion.actor",<br> "attribute.actor_id": "assertion.actor_id",<br> "attribute.base_ref": "assertion.base_ref",<br> "attribute.environment": "assertion.environment",<br> "attribute.event_name": "assertion.event_name",<br> "attribute.head_ref": "assertion.head_ref",<br> "attribute.job_workflow_ref": "assertion.job_workflow_ref",<br> "attribute.job_workflow_sha": "assertion.job_workflow_sha",<br> "attribute.ref": "assertion.ref",<br> "attribute.ref_type": "assertion.ref_type",<br> "attribute.repository": "assertion.repository",<br> "attribute.repository_id": "assertion.repository_id",<br> "attribute.repository_owner": "assertion.repository_owner",<br> "attribute.repository_owner_id": "assertion.repository_owner_id",<br> "attribute.repository_visibility": "assertion.repository_visibility",<br> "attribute.run_attempt": "assertion.run_attempt",<br> "attribute.run_id": "assertion.run_id",<br> "attribute.run_number": "assertion.run_number",<br> "attribute.runner_environment": "assertion.runner_environment",<br> "attribute.sub": "attribute.sub",<br> "attribute.workflow": "assertion.workflow",<br> "attribute.workflow_ref": "assertion.workflow_ref",<br> "attribute.workflow_sha": "assertion.workflow_sha",<br> "google.subject": "assertion.sub"<br>}</pre> | no |
8485
| <a name="input_issuer_uri"></a> [issuer\_uri](#input\_issuer\_uri) | Workload Identity Pool Provider issuer URI | `string` | `"https://token.actions.githubusercontent.com"` | no |
8586
| <a name="input_pool_description"></a> [pool\_description](#input\_pool\_description) | Workload Identity Pool description | `string` | `"Workload Identity Pool for GitHub (Terraform managed)"` | no |
8687
| <a name="input_pool_disabled"></a> [pool\_disabled](#input\_pool\_disabled) | Workload Identity Pool disabled | `bool` | `false` | no |
@@ -107,3 +108,5 @@ Attribute mapping:
107108
## License
108109

109110
All files in this repository are under the [Apache License, Version 2.0](LICENSE) unless noted otherwise.
111+
112+
Based on [Terraform module for workload identity federation on GCP](https://github.com/mscribellito/terraform-google-workload-identity-federation) by [Michael S](https://github.com/mscribellito).

main.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ resource "google_iam_workload_identity_pool_provider" "provider" {
6767
display_name = var.provider_display_name
6868
description = var.provider_description
6969
disabled = var.provider_disabled
70-
71-
attribute_mapping = {
72-
"google.subject" = "assertion.sub"
73-
"attribute.sub" = "attribute.sub"
74-
"attribute.actor" = "assertion.actor"
75-
"attribute.repository" = "assertion.repository"
76-
}
70+
attribute_mapping = var.attribute_mapping
7771
oidc {
7872
issuer_uri = var.issuer_uri
7973
}

variables.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,39 @@ variable "issuer_uri" {
9696
description = "Workload Identity Pool Provider issuer URI"
9797
default = "https://token.actions.githubusercontent.com"
9898
}
99+
100+
variable "attribute_mapping" {
101+
type = map(string)
102+
description = "Workload Identity Pool Provider attribute mapping"
103+
default = {
104+
# Default attributes used in:
105+
# https://registry.terraform.io/modules/Cyclenerd/wif-service-account/google/latest
106+
"google.subject" = "assertion.sub" # Subject
107+
"attribute.sub" = "attribute.sub" # Subject
108+
"attribute.actor" = "assertion.actor" # The personal account that initiated the workflow run.
109+
"attribute.repository" = "assertion.repository" # The repository from where the workflow is running
110+
# More
111+
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#understanding-the-oidc-token
112+
"attribute.actor_id" = "assertion.actor_id" # The ID of personal account that initiated the workflow run.
113+
"attribute.base_ref" = "assertion.base_ref" # The target branch of the pull request in a workflow run.
114+
"attribute.environment" = "assertion.environment" # The name of the environment used by the job.
115+
"attribute.event_name" = "assertion.event_name" # The name of the event that triggered the workflow run.
116+
"attribute.head_ref" = "assertion.head_ref" # The source branch of the pull request in a workflow run.
117+
"attribute.job_workflow_ref" = "assertion.job_workflow_ref" # For jobs using a reusable workflow, the ref path to the reusable workflow. For more information, see "Using OpenID Connect with reusable workflows."
118+
"attribute.job_workflow_sha" = "assertion.job_workflow_sha" # For jobs using a reusable workflow, the commit SHA for the reusable workflow file.
119+
"attribute.ref" = "assertion.ref" # (Reference) The git ref that triggered the workflow run.
120+
"attribute.ref_type" = "assertion.ref_type" # The type of ref, for example: "branch".
121+
"attribute.repository_visibility" = "assertion.repository_visibility" # The visibility of the repository where the workflow is running. Accepts the following values: internal, private, or public.
122+
"attribute.repository" = "assertion.repository" # The repository from where the workflow is running.
123+
"attribute.repository_id" = "assertion.repository_id" # The ID of the repository from where the workflow is running.
124+
"attribute.repository_owner" = "assertion.repository_owner" # The name of the organization in which the repository is stored.
125+
"attribute.repository_owner_id" = "assertion.repository_owner_id" # The ID of the organization in which the repository is stored.
126+
"attribute.run_id" = "assertion.run_id" # The ID of the workflow run that triggered the workflow.
127+
"attribute.run_number" = "assertion.run_number" # The number of times this workflow has been run.
128+
"attribute.run_attempt" = "assertion.run_attempt" # The number of times this workflow run has been retried.
129+
"attribute.runner_environment" = "assertion.runner_environment" # The type of runner used by the job. Accepts the following values: github-hosted or self-hosted.
130+
"attribute.workflow" = "assertion.workflow" # The name of the workflow.
131+
"attribute.workflow_ref" = "assertion.workflow_ref" # The ref path to the workflow. For example, octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch.
132+
"attribute.workflow_sha" = "assertion.workflow_sha" # The commit SHA for the workflow file.
133+
}
134+
}

0 commit comments

Comments
 (0)