1. What Is OIDC?
OpenID Connect allows GitHub Actions to prove its identity to AWS without storing long-lived AWS access keys.
Instead of keeping permanent credentials, GitHub provides a temporary identity token. AWS verifies that token and allows an authorized workflow to assume an IAM role and receive temporary credentials.
2. How Does It Work?
The workflow involves three main components:
- GitHub Actions: Runs your deployment workflow.
- OpenID Connect (OIDC): Provides identity verification.
- AWS IAM: Validates the identity and grants permissions through an IAM role.
The workflow:
- A developer pushes code to GitHub.
- GitHub Actions starts the deployment workflow.
- GitHub requests an OIDC identity token.
- AWS Security Token Service (STS) validates the token and grants temporary credentials through an authorized IAM role.
- GitHub Actions uses those credentials to access permitted AWS resources.
3. How to Implement It
Getting started requires three main steps:
Step 1: Add GitHub's OIDC identity provider in AWS IAM.
Provider URL: https://token.actions.githubusercontent.com
Audience: sts.amazonaws.com
Step 2: Create an IAM role with a trust policy that restricts access to your intended GitHub repository and branch.
Step 3: Configure your GitHub Actions workflow with the required permission:
permissions:
id-token: write
contents: read
Then use the official AWS credentials action:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ap-south-1
The role must also have only the AWS permissions required by the deployment.
4. Why Does It Matter?
- No long-lived AWS access keys stored in GitHub.
- Temporary credentials instead of permanent credentials.
- Repository and branch-based access restrictions.
- Better alignment with least-privilege security.
Remember, OIDC does not automatically make a deployment secure. A restrictive IAM trust policy and appropriate role permissions are essential.
Conclusion
Cloud security isn't just about protecting applications after deployment. It also starts with how applications receive access to cloud resources.
OIDC offers a cleaner way to connect GitHub Actions with AWS while reducing dependence on long-lived credentials.
Sometimes, improving security means removing something rather than adding another layer.
💬 Let's Discuss!
Would you trust your deployment pipeline with permanent AWS access keys, or would you switch to temporary credentials using OIDC?
And one more question: Should every CI/CD pipeline adopt passwordless cloud authentication by default?
Share your thoughts in the comments! 🚀
Loading article