- 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.
- Required infrastructure (S3 artifact bucket, IAM roles) is already provisioned for this demo.
- The example GitHub repository contains a
buildspec.ymland a small sample application.

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.

github-devops-demo).

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.
- Select the S3 bucket to store pipeline artifacts.
- Choose encryption: AWS-managed key or customer-managed KMS key.


- 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).
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, branchmain).

- CodePipeline default: repository content packaged as a ZIP (no Git metadata).
- Full clone: performs a
git cloneand 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.
Example inline commands (Commands provider):
- 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.).
- 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.


- 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).

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.
- 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.,
SourceandBuild).

- From the pipeline details page you can view the pipeline ARN, service role ARN, execution mode, and recent execution history.


- 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
- AWS CodePipeline documentation: https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome.html
- AWS CodeBuild documentation: https://docs.aws.amazon.com/codebuild/latest/userguide/welcome.html
- GitHub Apps overview: https://docs.github.com/en/developers/apps/overview-of-github-apps