Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AWS CI/CD Pipeline with GitHub Integration

A complete CI/CD pipeline implementation using AWS services that automatically builds and deploys code from GitHub repositories.

Overview

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.

Architecture

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

Pipeline Flow

  1. Source Stage: Monitors GitHub repository for changes on the main branch
  2. Build Stage: Executes build commands using CodeBuild with Node.js 14 runtime
  3. Artifact Storage: Stores build outputs in versioned S3 bucket

Prerequisites

  • AWS Account with appropriate permissions
  • GitHub account and repository
  • GitHub Personal Access Token with repo permissions

Deployment

1. GitHub Authentication

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:

  1. Go to GitHub Settings → Developer settings → Personal access tokens
  2. Generate new token with repo scope
  3. Copy the token (you won't see it again)

2. Deploy CloudFormation Stack

  1. Open AWS CloudFormation console
  2. Create new stack with cicd-stack.yaml
  3. 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

3. Create GitHub Repository

Create a repository with the exact name specified in the GitHubRepo parameter.

Build Configuration

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.

Resources Created

  • S3 bucket: {ProjectName}-artifacts-{AccountId}
  • CodeBuild project: {ProjectName}-build
  • CodePipeline: {ProjectName}-pipeline
  • IAM roles with least-privilege permissions

Monitoring

  • View pipeline status in AWS CodePipeline console
  • Check build logs in AWS CodeBuild console
  • Monitor S3 bucket for artifacts

Security Features

  • IAM roles with minimal required permissions
  • GitHub token stored securely (NoEcho parameter)
  • S3 bucket versioning enabled
  • CloudWatch logging for build processes

Customization

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

Troubleshooting

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.

Cost Considerations

  • CodeBuild charges per build minute
  • S3 storage costs for artifacts
  • CodePipeline has a free tier for the first pipeline

Cleanup

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors