AWS Builder Center
Automating Cloud Deployments: Integrating GitHub Actions with AWS CodePipeline

Automating Cloud Deployments: Integrating GitHub Actions with AWS CodePipeline

Learn how to combine the developer-friendly workflow of GitHub Actions with AWS CodePipeline to build a secure, automated CI/CD pipeline for cloud applications.

In modern cloud development, continuous integration and continuous delivery (CI/CD) pipelines form the backbone of fast, reliable software releases. While GitHub Actions excels at source control integration, pull request workflows, and initial code testing, AWS-native tools like AWS CodePipeline, AWS CodeBuild, and AWS CodeDeploy offer deep, secure integration with AWS infrastructure.
Combining both tools allows developers to run fast code checks directly on GitHub, while leaving the heavy lifting of environment promotion, IAM security enforcement, and deployment orchestration to AWS.
In this guide, we will walk through setting up an automated pipeline that connects GitHub Actions to AWS CodePipeline using OpenID Connect (OIDC) for secure authentication.



Architecture Overview

  1. Developer Push / Pull Request: A developer pushes code or opens a PR in a GitHub repository.
  1. GitHub Actions (CI): GitHub Actions runs linting, unit tests, and builds artifacts.
  1. Secure Authentication (OIDC): GitHub Actions assumes an AWS IAM Role via OpenID Connect (no static credentials stored).
  1. AWS CodePipeline (CD): The compiled artifact or trigger payload is passed to AWS CodePipeline, which manages multi-stage deployments (e.g., Staging to Production) with approval gates.



Step 1: Secure GitHub with AWS IAM OIDC

Avoid using long-lived AWS IAM access keys in GitHub Secrets. Instead, configure AWS to trust GitHub's OIDC provider.

Create an IAM Role for GitHub Actions

  1. Open the AWS IAM Console and navigate to Identity Providers.
  1. Add an OpenID Connect provider:
  • Provider URL:  https://token.actions.githubusercontent.com 
  • Audience:  sts.amazonaws.com 
  1. Create an IAM Role attached to this provider with an assume-role trust policy similar to:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::YOUR_ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:YOUR_GITHUB_ORG/YOUR_REPO:*"
}
}
}
]
}
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