A complete CI/CD pipeline implementation using AWS services that automatically builds and deploys code from GitHub repositories.
This project creates a fully automated CI/CD pipeline using AWS CloudFormation that integrates with GitHub repositories. When code is pushed to the main branch, the pipeline automatically triggers a build process using AWS CodePipeline and CodeBuild.
The pipeline consists of the following AWS components:
- AWS CodePipeline: Orchestrates the entire CI/CD workflow
- AWS CodeBuild: Compiles, tests, and packages the application
- Amazon S3: Stores build artifacts and pipeline assets
- AWS IAM: Manages permissions and security roles
- GitHub Integration: Source code repository and webhook triggers
- Source Stage: Monitors GitHub repository for changes on the main branch
- Build Stage: Executes build commands using CodeBuild with Node.js 14 runtime
- Artifact Storage: Stores build outputs in versioned S3 bucket
- AWS Account with appropriate permissions
- GitHub account and repository
- GitHub Personal Access Token with repo permissions
Option A: If you have an existing GitHub connection in AWS CodePipeline, the token field may be pre-populated.
Option B: Create a new GitHub Personal Access Token:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate new token with
reposcope - Copy the token (you won't see it again)
- Open AWS CloudFormation console
- Create new stack with
cicd-stack.yaml - Provide required parameters:
- ProjectName: Name for your CI/CD project (default: my-first-cicd)
- GitHubOwner: Your GitHub username or organization
- GitHubRepo: Repository name
- GitHubToken: Personal access token from step 1
Create a repository with the exact name specified in the GitHubRepo parameter.
The pipeline uses a basic buildspec that:
- Installs Node.js 14 runtime
- Runs pre-build, build, and post-build phases
- Outputs build logs with timestamps
To customize the build process, modify the BuildSpec section in the CloudFormation template.
- S3 bucket:
{ProjectName}-artifacts-{AccountId} - CodeBuild project:
{ProjectName}-build - CodePipeline:
{ProjectName}-pipeline - IAM roles with least-privilege permissions
- View pipeline status in AWS CodePipeline console
- Check build logs in AWS CodeBuild console
- Monitor S3 bucket for artifacts
- IAM roles with minimal required permissions
- GitHub token stored securely (NoEcho parameter)
- S3 bucket versioning enabled
- CloudWatch logging for build processes
To extend this pipeline:
- Add deployment stages (e.g., to EC2, ECS, or Lambda)
- Include testing phases
- Add approval gates
- Configure notifications (SNS/email)
- Implement multi-environment deployments
Pipeline fails on first run: Ensure GitHub repository exists and has at least one commit on the main branch.
Build failures: Check CodeBuild logs for specific error messages and verify buildspec configuration.
Permission errors: Verify IAM roles have necessary permissions for your specific build requirements.
- CodeBuild charges per build minute
- S3 storage costs for artifacts
- CodePipeline has a free tier for the first pipeline
To avoid ongoing charges, delete the CloudFormation stack when no longer needed. This will remove all created resources except the S3 bucket contents (which must be manually deleted first).