AWS Builder Center
Your GitHub Workflow Has AWS Access. Is It Actually Secure?

Your GitHub Workflow Has AWS Access. Is It Actually Secure?

Explore how OpenID Connect (OIDC) helps secure GitHub Actions deployments to AWS without storing long-lived access keys. Discover how IAM roles, temporary credentials, and trust policies work together, and why secure CI/CD pipelines need more than just automation. A practical discussion for AWS learners, cloud enthusiasts, and DevOps builders.

Your GitHub Workflow Has AWS Access. Is It Actually Secure?

Imagine pushing code to GitHub, triggering a GitHub Actions workflow, and automatically deploying your application to AWS. Everything works smoothly. But have you ever thought about how GitHub gets permission to access your AWS account?
A common approach is to store AWS Access Keys and Secret Access Keys in GitHub Secrets. Although this works, it creates a security concern: these are long-lived credentials. If they are exposed or misused, someone could potentially access your AWS resources.
So, is there a safer way to connect GitHub Actions with AWS?

The Problem with Long-Lived Access Keys

In many CI/CD pipelines, developers store AWS credentials as repository secrets and use them whenever a workflow runs.
But consider this:
  • What happens if a key is accidentally exposed?
  • How often do we rotate these credentials?
  • Should an automated workflow have permanent access to our cloud account?
Automation should make deployments easier, but it should not create unnecessary security risks.

A Better Approach: OpenID Connect (OIDC)

AWS supports OpenID Connect (OIDC), which allows GitHub Actions to access AWS without storing permanent access keys.
Instead of using long-lived credentials, GitHub requests temporary credentials through AWS Security Token Service (STS).
Here is how the process works:
  1. A GitHub Actions workflow starts.
  1. GitHub generates an OIDC token to identify the workflow.
  1. AWS validates the token using its configured identity provider and IAM role trust policy.
  1. If the conditions match, AWS provides temporary credentials.
  1. The workflow uses those credentials to access only the AWS resources allowed by the IAM role.
This means we can avoid storing permanent AWS access keys in GitHub Secrets.

What Does the Configuration Look Like?

First, configure an OIDC identity provider in AWS IAM and create an IAM role with a trust policy that restricts which GitHub repository and branch can assume it.
Then, add the required permissions and AWS credentials action to your GitHub Actions workflow:
permissions:
id-token: write
contents: read

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::YOUR_ACCOUNT_ID:role/GitHubActionsRole
aws-region: ap-south-1
The  id-token: write  permission allows the workflow to request an OIDC token. The AWS credentials action exchanges that token for temporary AWS credentials.
The IAM role trust policy is equally important. It should restrict access to the intended repository, branch, or GitHub environment rather than trusting every workflow.

Security Is More Than Just Removing Access Keys

OIDC is a useful improvement, but it does not automatically make a pipeline secure.
A few practices still matter:
  • Least privilege: Give the IAM role only the permissions the workflow actually needs.
  • Repository restrictions: Allow only trusted repositories and branches to assume the role.
  • Credential management: Avoid exposing credentials in logs or workflow outputs.
  • Workflow protection: Review third-party actions and protect important deployment branches.
The goal is not just to automate deployments. It is to make sure automation has only the access it needs.

Let's Discuss!

I'm exploring how cloud security practices fit into real-world CI/CD workflows, and I'd love to hear from other AWS and DevOps builders.
A few questions for the community:
  1. Are you still using AWS Access Keys in GitHub Actions, or have you switched to OIDC?
  1. What was the most confusing part when you first configured GitHub Actions with AWS?
  1. Which security practice do you think is most important in a CI/CD pipeline?
If you've implemented this setup, share your experience or any challenges you faced. Your insights could help someone else learning to build more secure cloud workflows.
Let's learn from each other and make our deployments not just faster, but safer!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article