github-oidc¶
Example of the github-oidc module: an IAM OIDC provider for GitHub Actions and
an IAM role whose trust policy is limited to the subjects you pass (repo/branch/environment patterns).
subjectsis required and has no default, so no repository is trusted until you choose one.- The role starts with no permissions; pass
managed_policy_arnsto grant some. - If the account already has the GitHub OIDC provider, set
create_oidc_provider = falseandoidc_provider_arn.
Usage in a workflow:
permissions:
id-token: write
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: <role_arn output>
aws-region: us-east-1
Requires AWS credentials for the target account; review with terraform plan before applying.
Requirements¶
| Name | Version |
|---|---|
| terraform | >= 1.6.0 |
| aws | >= 5.0 |
Providers¶
No providers.
Modules¶
| Name | Source | Version |
|---|---|---|
| github_oidc | ../../modules/github-oidc | n/a |
Resources¶
No resources.
Inputs¶
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| subjects | GitHub OIDC sub patterns allowed to assume the role, e.g. repo:<owner>/<repo>:ref:refs/heads/main. Must use a literal owner. |
list(string) |
n/a | yes |
| create_oidc_provider | Whether to create the GitHub Actions OIDC provider. Set to false when the account already has one and pass oidc_provider_arn. |
bool |
true |
no |
| managed_policy_arns | ARNs of managed IAM policies to attach to the role. Defaults to none (a role with no permissions). | list(string) |
[] |
no |
| oidc_provider_arn | ARN of an existing GitHub Actions OIDC provider. Required when create_oidc_provider is false. |
string |
null |
no |
| region | AWS region used by the provider (IAM is global, but the provider needs one). | string |
"us-east-1" |
no |
| role_name | Name of the IAM role assumed by GitHub Actions. | string |
"github-oidc-example" |
no |
Outputs¶
| Name | Description |
|---|---|
| oidc_provider_arn | ARN of the GitHub Actions OIDC provider (created or reused). |
| role_arn | ARN of the IAM role to set as role-to-assume in aws-actions/configure-aws-credentials. |
| role_name | Name of the IAM role assumed by GitHub Actions. |