Skip to main content
This hands-on lesson shows how to wire GitHub into an AWS CodePipeline (source + build) and run a basic CI workflow using CodeBuild. We will:
  • Create an AWS Code Connection to GitHub (GitHub App).
  • Create a custom CodePipeline that pulls source from GitHub.
  • Add a CodeBuild stage that uses the repository buildspec.yml.
  • Verify artifacts are stored in S3.
This lesson covers source and build only — no deployment stage is configured. Prerequisites and context
  • Required infrastructure (S3 artifact bucket, IAM roles) is already provisioned for this demo.
  • The example GitHub repository contains a buildspec.yml and a small sample application.
A screenshot of a dark-themed GitHub repository page for "020-060-sample-app" by user peopleforrester. The file list (src, tests, .gitignore, README.md, buildspec.yml, requirements.txt) and the README heading "Sample Application for Demo 020-060" are visible.

1) Create a Code Connection from AWS to GitHub

Use the AWS Connector for GitHub (a GitHub App) to integrate GitHub with CodePipeline. This is preferred over OAuth tokens because it is managed on the GitHub side and can be scoped to specific repositories. Steps:
  • In the AWS Console: Developer Tools > CodePipeline > Settings > Connections.
  • Create a new connection and choose GitHub (AWS Connector for GitHub/GitHub App).
  • During installation, select access to either all repositories or specific repositories.
A dark‑mode GitHub settings screen showing an installed "AWS Connector for GitHub" app with its permissions and repository access options. The left sidebar displays account and access settings like Profile, Appearance, Billing, and SSH/keys.
After successful creation you should see the connection in the same AWS region (example: github-devops-demo).
A screenshot of the AWS Management Console showing a Code Connection named "github-devops-demo" (provider: GitHub) with its ARN and status marked "Available." A green banner at the top indicates the connection was created successfully.
Note: a Code Connection is implemented as a GitHub App (not an OAuth token). IAM principals with permission to use the connection can reference it in pipeline stages.

2) Create a Custom CodePipeline

  • Go to Developer Tools > CodePipeline > Pipelines and click Create pipeline.
  • Choose Custom pipeline so you can define the artifact store and stages.
Artifact store and encryption:
  • Select the S3 bucket to store pipeline artifacts.
  • Choose encryption: AWS-managed key or customer-managed KMS key.
A screenshot of the AWS CodePipeline "Create new pipeline" screen showing Artifact store settings with "Custom location" selected, an S3 bucket name entered, and the Encryption key set to "Default AWS Managed Key." The Variables section is visible below with no variables defined.
You may optionally define pipeline variables here (not required for this demo).
A screenshot of the AWS CodePipeline "Create new pipeline" page showing encryption key options (Default AWS Managed Key selected), a Variables section with no variables defined and an "Add variable" button, and navigation buttons including "Previous" and "Next."
Pipeline execution mode:
  • Supersede — new run replaces a currently running execution.
  • Queue — executions are queued and run sequentially (safe default; preserves order).
  • Parallel — multiple executions run concurrently (useful for independent branch builds).
For this demo, select Queue to preserve execution order and avoid conflicts.

3) Configure the Source Stage (GitHub)

  • For the Source provider choose GitHub and pick the Code Connection created earlier.
  • Select your repository and branch (e.g., peopleforrester/020-060-sample-app, branch main).
A screenshot of the AWS CodePipeline "Create new pipeline" setup page. It shows a GitHub connection, the repository "peopleforrester/020-060-sample-app", the default branch set to "main", and artifact format options.
Source artifact format options:
  • CodePipeline default: repository content packaged as a ZIP (no Git metadata).
  • Full clone: performs a git clone and retains Git metadata/history. Required if build steps run Git commands or need commit metadata.
  • Webhook triggers: enable “Start pipeline on push and pull request events” for near real-time triggers.

4) Add a Build Stage (CodeBuild)

Adding a build stage is optional but typical for CI pipelines. In the pipeline creation workflow, add a Build stage and choose a build provider.
A screenshot of the AWS CodePipeline "Add build stage - optional" page showing build provider options (Commands or Other build providers) with AWS CodeBuild selected and fields to choose or create a build project. Environment variables and optional buildspec override settings are visible below.
Build provider overview: Example inline commands (Commands provider):
Creating or selecting a CodeBuild project:
  • Choose project name, environment image (e.g., aws/codebuild/standard:5.0), and compute type.
  • Specify the service role (an IAM role allowing access to S3, CloudWatch Logs, etc.).
Example references you might see in configuration:
Buildspec configuration:
  • Use the repository buildspec.yml (recommended) or override inline in the project UI.
  • Because the demo repo already contains buildspec.yml, CodeBuild will pick it up by default.
A screenshot of the AWS Developer Tools/CodeBuild project creation page showing the "Buildspec" section with the "Use a buildspec file" option selected and a buildspec.yml field. The lower part of the screen displays batch configuration options and the AWS footer.
A dark-themed GitHub repository page for a sample application showing the main branch file list (src, tests, .gitignore, README.md, buildspec.yml, requirements.txt) and the README section titled "Sample Application for Demo 020-060."
Logging and artifacts:
  • Configure CodeBuild logging to CloudWatch Logs and/or S3 for later debugging.
  • Build outputs are stored in the pipeline artifact store (the S3 bucket defined earlier).
A screenshot of a GitHub repository page in dark mode with an overlaid AWS Developer Tools/CodeBuild "Logs" settings panel. The panel shows options for CloudWatch logs (group name and stream prefix) and S3 logs.

5) Complete Pipeline Creation and Inspect a Run

  • Skip test/deploy stages for this demo (we demonstrate source + build only).
  • Create the pipeline. An initial run will start automatically based on the repository state. Subsequent runs will trigger on commits if webhook triggers are enabled.
Artifacts and S3:
  • Source ZIP artifact and build artifacts are stored in the pipeline artifact S3 bucket. Inspect them in the S3 console under the pipeline’s prefixes (e.g., Source and Build).
A screenshot of the Amazon S3 web console showing the "SourceArti/" bucket contents with an objects list (two files) and action buttons like Create folder, Upload, Copy S3 URI, and Download. The left sidebar shows S3 navigation sections such as Buckets and Access management and security.
Pipeline metadata and ARNs:
  • From the pipeline details page you can view the pipeline ARN, service role ARN, execution mode, and recent execution history.
A screenshot of the AWS CodePipeline Settings page for a pipeline named "github-demo-pipeline," showing its Pipeline ARN and Service role ARN plus details like Version 1, Pipeline type V2, and Execution mode QUEUED. The breadcrumb bar at the top shows Developer Tools > CodePipeline > Pipelines > github-demo-pipeline.
To inspect a build artifact’s metadata in S3:
Screenshot of the Amazon S3 console showing an object overview page with metadata (owner, AWS region, last modified date, size) and S3 URI/ARN details. The left sidebar shows S3 navigation items like Buckets and Access management.
What this pipeline did in the demo
  • Source stage pulled the repo and uploaded a packaged artifact (ZIP) to S3.
  • Build stage ran CodeBuild using the repo buildspec.yml, executed tests/linting, and produced build artifacts.
  • Artifacts are now available in S3 for future deployment pipelines.
Tip: Configure a pipeline for CI-only (source + build + test) to validate changes and gate merges before a separate release/deploy pipeline handles production promotion.

Key takeaways

  • Use AWS Code Connections (GitHub App) to connect GitHub with CodePipeline — it’s different from OAuth and is managed as a GitHub App.
  • Pipeline execution modes:
    • Queue — ordered sequential runs (safe default).
    • Supersede — new run replaces a currently running execution.
    • Parallel — concurrent runs for independent workflows.
  • Source artifacts are produced by the Source stage and stored in the pipeline S3 artifact bucket; CodeBuild consumes those artifacts.
  • CodeBuild uses buildspec.yml (in-repo or inline) to define phases, commands, and artifacts.
  • Ensure IAM service roles for CodePipeline and CodeBuild have required permissions (S3, CloudWatch Logs, and any additional services your build uses).
Warning: Incorrect or missing IAM permissions for CodeBuild/CodePipeline (S3 read/write, CloudWatch Logs, etc.) are a common cause of failed builds or missing artifacts. Verify roles and policies before troubleshooting pipelines.

References

This completes the lesson on wiring GitHub into a CodePipeline source and running a simple CodeBuild build that stores artifacts in S3, ready for a later deploy stage.

Watch Video

Practice Lab