Skip to content

Commit 9349899

Browse files
author
Nils
committed
more attributes
1 parent 557ddd1 commit 9349899

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This Terraform module creates a Workload Identity Pool and Provider for GitHub.
1010

1111
Service account keys are a security risk if compromised.
12-
Avoid service account keys and instead use the [Workload Identity Federation](https://cloud.google.com/iam/docs/configuring-workload-identity-federation).
12+
Avoid service account keys and instead use the [Workload Identity Federation](https://github.com/Cyclenerd/google-workload-identity-federation#readme).
1313
For more information about Workload Identity Federation and how to best authenticate service accounts on Google Cloud, please see my GitHub repo [Cyclenerd/google-workload-identity-federation](https://github.com/Cyclenerd/google-workload-identity-federation#readme).
1414

1515
> There is also a ready-to-use Terraform module for [GitLab](https://github.com/Cyclenerd/terraform-google-wif-gitlab#readme).
@@ -61,37 +61,42 @@ module "github-service-account" {
6161

6262
## OIDC Token Attribute Mapping
6363

64+
> The attributes `attribute.sub` and `attribute.repository` are used in the Terrform module [Cyclenerd/wif-service-account/google](https://github.com/Cyclenerd/terraform-google-wif-service-account).
65+
> Please do not remove these attributes.
66+
6467
Default attribute mapping:
6568

6669
| Attribute | Claim | Description |
6770
|-----------------------------------|-----------------------------------|-------------|
6871
| `google.subject` | `assertion.sub` | Subject
6972
| `attribute.sub` | `assertion.sub` | Defines the subject claim that is to be validated by the cloud provider. This setting is essential for making sure that access tokens are only allocated in a predictable way.
70-
| `attribute.actor` | `assertion.actor` | The personal account that initiated the workflow run.
7173
| `attribute.repository` | `assertion.repository` | The repository from where the workflow is running
74+
| `attribute.aud` | `assertion.aud` | Audience
75+
| `attribute.iss` | `assertion.iss` | The issuer of the OIDC token: `https://token.actions.githubusercontent.com`
76+
| `attribute.actor` | `assertion.actor` | The personal account that initiated the workflow run.
7277
| `attribute.actor_id` | `assertion.actor_id` | The ID of personal account that initiated the workflow run.
7378
| `attribute.base_ref` | `assertion.base_ref` | The target branch of the pull request in a workflow run.
7479
| `attribute.environment` | `assertion.environment` | The name of the environment used by the job.
7580
| `attribute.event_name` | `assertion.event_name` | The name of the event that triggered the workflow run.
7681
| `attribute.head_ref` | `assertion.head_ref` | The source branch of the pull request in a workflow run.
77-
| `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.
82+
| `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](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/using-openid-connect-with-reusable-workflows).
7883
| `attribute.job_workflow_sha` | `assertion.job_workflow_sha` | For jobs using a reusable workflow, the commit SHA for the reusable workflow file.
7984
| `attribute.ref` | `assertion.ref` | (Reference) The git ref that triggered the workflow run.
80-
| `attribute.ref_type` | `assertion.ref_type` | The type of ref, for example: "branch".
81-
| `attribute.repository_visibility` | `assertion.repository_visibility` | The visibility of the repository where the workflow is running. Accepts the following values: internal, private, or public.
85+
| `attribute.ref_type` | `assertion.ref_type` | The type of `ref`, for example: "branch".
86+
| `attribute.repository_visibility` | `assertion.repository_visibility` | The visibility of the repository where the workflow is running. Accepts the following values: `internal`, `private`, or `public`.
8287
| `attribute.repository_id` | `assertion.repository_id` | The ID of the repository from where the workflow is running.
83-
| `attribute.repository_owner` | `assertion.repository_owner` | The name of the organization in which the repository is stored.
84-
| `attribute.repository_owner_id` | `assertion.repository_owner_id` | The ID of the organization in which the repository is stored.
88+
| `attribute.repository_owner` | `assertion.repository_owner` | The name of the organization in which the `repository` is stored.
89+
| `attribute.repository_owner_id` | `assertion.repository_owner_id` | The ID of the organization in which the `repository` is stored.
8590
| `attribute.run_id` | `assertion.run_id` | The ID of the workflow run that triggered the workflow.
8691
| `attribute.run_number` | `assertion.run_number` | The number of times this workflow has been run.
8792
| `attribute.run_attempt` | `assertion.run_attempt` | The number of times this workflow run has been retried.
88-
| `attribute.runner_environment` | `assertion.runner_environment` | The type of runner used by the job. Accepts the following values: github-hosted or self-hosted.
93+
| `attribute.runner_environment` | `assertion.runner_environment` | The type of runner used by the job. Accepts the following values: `github-hosted` or `self-hosted`.
8994
| `attribute.workflow` | `assertion.workflow` | The name of the workflow.
90-
| `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.
91-
| `attribute.workflow_sha` | `assertion.workflow_sha` | The commit SHA for the workflow file.|
95+
| `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`.
96+
| `attribute.workflow_sha` | `assertion.workflow_sha` | The commit SHA for the workflow file.
9297

9398
<!-- BEGIN_TF_DOCS -->
94-
## Provi| s
99+
## Providers
95100

96101
| Name | Version |
97102
|------|---------|
@@ -102,7 +107,7 @@ Default attribute mapping:
102107
| Name | Description | Type | Default | Required |
103108
|------|-------------|------|---------|:--------:|
104109
| <a name="input_attribute_condition"></a> [attribute\_condition](#input\_attribute\_condition) | (Optional) Workload Identity Pool Provider attribute condition expression | `string` | `null` | no |
105-
| <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 |
110+
| <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.aud": "attribute.aud",<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.iss": "attribute.iss",<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 |
106111
| <a name="input_issuer_uri"></a> [issuer\_uri](#input\_issuer\_uri) | Workload Identity Pool Provider issuer URI | `string` | `"https://token.actions.githubusercontent.com"` | no |
107112
| <a name="input_pool_description"></a> [pool\_description](#input\_pool\_description) | Workload Identity Pool description | `string` | `"Workload Identity Pool for GitHub (Terraform managed)"` | no |
108113
| <a name="input_pool_disabled"></a> [pool\_disabled](#input\_pool\_disabled) | Workload Identity Pool disabled | `bool` | `false` | no |

variables.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ variable "attribute_mapping" {
105105
# https://registry.terraform.io/modules/Cyclenerd/wif-service-account/google/latest
106106
"google.subject" = "assertion.sub" # Subject
107107
"attribute.sub" = "attribute.sub" # Subject
108-
"attribute.actor" = "assertion.actor" # The personal account that initiated the workflow run.
109108
"attribute.repository" = "assertion.repository" # The repository from where the workflow is running
110109
# More
111110
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#understanding-the-oidc-token
111+
"attribute.aud" = "attribute.aud" # Audience
112+
"attribute.iss" = "attribute.iss" # Issuer
113+
"attribute.actor" = "assertion.actor" # The personal account that initiated the workflow run.
112114
"attribute.actor_id" = "assertion.actor_id" # The ID of personal account that initiated the workflow run.
113115
"attribute.base_ref" = "assertion.base_ref" # The target branch of the pull request in a workflow run.
114116
"attribute.environment" = "assertion.environment" # The name of the environment used by the job.

0 commit comments

Comments
 (0)