{"id":26584142,"url":"https://github.com/chrispsheehan/terraform-aws-github-oidc","last_synced_at":"2026-04-20T03:02:41.480Z","repository":{"id":215292162,"uuid":"738556020","full_name":"chrispsheehan/terraform-aws-github-oidc","owner":"chrispsheehan","description":"A terraform module for creating a validate and a defined scoped deploy role.","archived":false,"fork":false,"pushed_at":"2024-01-17T11:25:24.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T09:19:11.535Z","etag":null,"topics":["aws","github-actions","gitops","iam","oidc","terraform","terraform-module"],"latest_commit_sha":null,"homepage":"https://registry.terraform.io/modules/chrispsheehan/github-oidc/aws/latest","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrispsheehan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-03T13:55:50.000Z","updated_at":"2024-10-09T21:08:45.000Z","dependencies_parsed_at":"2024-01-03T16:26:37.091Z","dependency_job_id":"796ce210-16e9-470e-8377-c2f527aee37e","html_url":"https://github.com/chrispsheehan/terraform-aws-github-oidc","commit_stats":null,"previous_names":["chrispsheehan/terraform-aws-github-oidc"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/chrispsheehan/terraform-aws-github-oidc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Fterraform-aws-github-oidc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Fterraform-aws-github-oidc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Fterraform-aws-github-oidc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Fterraform-aws-github-oidc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrispsheehan","download_url":"https://codeload.github.com/chrispsheehan/terraform-aws-github-oidc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrispsheehan%2Fterraform-aws-github-oidc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32031070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","github-actions","gitops","iam","oidc","terraform","terraform-module"],"created_at":"2025-03-23T09:19:09.764Z","updated_at":"2026-04-20T03:02:41.464Z","avatar_url":"https://github.com/chrispsheehan.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform AWS Github Action OIDC Roles module\n\nThis module creates OIDC roles to be used in terraform related Github Actions. More details [here](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services).\n\nThe below will create two iam roles for `octo-org/octo-repo` (replace with your repo);\n\n- `octo-org-oidc-gha-validate-role`\n- `octo-org-oidc-gha-deploy-branch-role`\n\n## Usage\n\nRun the below to create the OIDC provider and roles. This can live in it's own repo, separate to the code deployed via Github actions.\n\n*NOTE*: You may have an existing provider; in which case remove `aws_iam_openid_connect_provider.github` or alternatively [import](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider#import).\n\n```terraform\nlocals {\n  github_oidc_domain = \"token.actions.githubusercontent.com\"\n}\n\n\u003c!-- REQUIRED create aws openid provider --\u003e\nresource \"aws_iam_openid_connect_provider\" \"github\" {\n  url             = \"https://${local.local.github_oidc_domain}\"\n  client_id_list  = [\"token.actions.githubusercontent.com\"]\n  thumbprint_list = [\"a031c46782e6e6c662c2c87c76da9aa62ccabd8e\"]\n}\n\nmodule \"example-oidc-roles\" {\n  depends_on = [aws_iam_openid_connect_provider.github]\n\n  source  = \"chrispsheehan/github-oidc/aws\"\n  version = \"2.0.0\"\n\n  github-oidc-domain = local.github_oidc_domain\n  role-name-base     = \"octo-org-oidc-example\"\n  repo               = \"octo-org/octo-repo\"\n  branch             = \"main\"\n  branch-actions     = [\"dynamodb:*\", \"s3:*\", \"cloudfront:*\", \"wafv2:*\", \"acm:*\", \"route53:*\"]\n  repo-refs          = [\"heads/main\", \"tags/*\"]\n}\n\noutput \"branch-specific-defined-role\" {\n  description = \"CI defined actions role for specified branch\"\n  value       = module.example-oidc-roles.branch-specific-defined-role\n}\n\noutput \"branch-agnostic-validate-role\" {\n  description = \"CI readonly role for all branches\"\n  value       = module.example-oidc-roles.branch-agnostic-validate-role\n}\n```\n\n## Github Actions\n\n### Init and validate\n\n- Any branch can run the below jobs.\n\n```yaml\nname: Branch Check\non:\n  push:\n    branches-ignore:\n      - main\n\nenv:\n  AWS_REGION: ${{ vars.AWS_REGION }}\n  AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}\n\njobs:\n  terraform-init-validate:\n    runs-on: ubuntu-latest\n    permissions:\n      id-token: write\n      contents: read\n    steps:\n      - name: checkout\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n\n      - name: Configure AWS Credentials\n        uses: aws-actions/configure-aws-credentials@v4\n        with:\n          aws-region: ${{ env.AWS_REGION }}\n          role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/octo-oidc-gha-validate-role\n          role-session-name: GitHubActions\n\n      - name: Proof of concept terraform Init\n        run: |\n          cd tf\n          terraform init\n\n      - name: Proof of concept terraform Validate\n        run: |\n          cd tf\n          terraform validate\n\n```\n\n### Defined branch deployment\n\n- In the below job we only allow `[\"dynamodb:*\", \"s3:*\", \"cloudfront:*\", \"wafv2:*\", \"acm:*\", \"route53:*\"]` actions, as specified above. Any other actions are blocked.\n- Only `main` (or new tags) can execute the below. All other branches are blocked.\n\n```yaml\nname: Defined branch deploy\non:\n  push:\n    branches-ignore:\n      - main\n\nenv:\n  AWS_REGION: ${{ vars.AWS_REGION }}\n  AWS_ACCOUNT_ID: ${{ vars.AWS_ACCOUNT_ID }}\n\njobs:\n  terraform-deploy:\n    runs-on: ubuntu-latest\n    permissions:\n      id-token: write\n      contents: read\n    steps:\n      - name: Configure AWS Credentials\n        uses: aws-actions/configure-aws-credentials@v4\n        with:\n          aws-region: ${{ env.AWS_REGION }}\n          role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/octo-org-oidc-gha-deploy-branch-role\n          role-session-name: GitHubActions\n\n      - run: terraform init\n      - run: terraform apply -auto-approve\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispsheehan%2Fterraform-aws-github-oidc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrispsheehan%2Fterraform-aws-github-oidc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrispsheehan%2Fterraform-aws-github-oidc/lists"}