AWS CodePipeline (CI/CD Pipeline)
CICD Pipeline with CodeCommit CodeBuild and CodeDeploy
CodeCommit Demo
Welcome to this comprehensive tutorial on using AWS CodeCommit as your source stage in a CI/CD pipeline. You’ll learn how to:
- Create a CodeCommit repository
- Upload and manage files
- Work with branches
- Open and merge a pull request
Feel free to follow along in your own AWS account!
Note
AWS CodeCommit seamlessly integrates with other AWS Developer Tools. You can also connect it to your local Git client for advanced workflows.
Table of Contents
- Create a Repository
- Upload Files
- appspec.yml
- before-install.bat
- index.html
- Branch Management
- Pull Request Workflow
- Merge and Verify
- Conclusion & References
Create a Repository
- Sign in to the AWS Management Console and open CodeCommit.
- Click Create repository.
- Provide a name (e.g.,
MyDemoRepo
) and an optional description. - Click Create.
Upload Files
Start by adding the deployment configuration and application assets.
File | Description |
---|---|
appspec.yml | Defines deployment hooks and file mappings |
before-install.bat | Installs IIS on Windows target |
index.html | Sample HTML page for testing deployment |
1. Upload appspec.yml
- In the repository, click Add file > Upload file.
- Select your local
appspec.yml
. - Enter author name, email, commit message (optional), and click Commit changes.
version: 0.0
os: windows
files:
- source: \index.html
destination: C:\inetpub\wwwroot
hooks:
BeforeInstall:
location: \before-install.bat
timeout: 900
2. Upload before-install.bat
- Click Add file > Upload file.
- Choose
before-install.bat
from your machine. - Fill in author details and click Commit changes.
REM Install Internet Information Server (IIS).
c:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe -Command Import-Module -Name ServerManager
c:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe -Command Install-WindowsFeature Web-Server
3. Upload index.html
- Click Add file > Upload file.
- Select
index.html
. - Add author info and commit.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sample Deployment</title>
<style>
body {
color: #ffffff;
background-color: #0073f3;
font-family: Arial, sans-serif;
font-size: 14px;
}
h1 { font-size: 500%; margin-bottom: 0; }
h2 { font-size: 200%; margin-bottom: 0; }
</style>
</head>
<body>
<h1>Deployment Successful</h1>
<h2>Welcome to AWS CodeCommit</h2>
</body>
</html>
Branch Management
- Select Branches in the sidebar. You’ll see the default branch named
main
. - Click Create branch, enter
branch2
as the new branch name, and choosemain
as the source. - Click Create.
Best Practice
Use descriptive branch names that reflect the feature or fix you’re working on.
Edit a File in branch2
- Switch to
branch2
. - Open
appspec.yml
and click Edit. - Add a comment line at the end, then commit your changes.
version: 0.0
os: windows
files:
- source: \index.html
destination: C:\inetpub\wwwroot
hooks:
BeforeInstall:
location: \before-install.bat
timeout: 900
# Demo Testing
Pull Request Workflow
- Click Pull requests in the sidebar.
- Click Create pull request.
- Set Source to
branch2
and Destination tomain
, then click Compare.
Review the changes:
BeforeInstall:
location: \before-install.bat
timeout: 900
+ # Demo Testing
- Enter a title like Demo Pull Request and an optional description.
- Click Create pull request.
Merge and Verify
- In the pull request view, click Merge.
- Select Fast-forward merge and confirm.
- Optionally uncheck Delete branch if you wish to preserve
branch2
.
# You can also merge locally:
git fetch origin
git checkout main
git merge --ff-only origin/branch2
Warning
Deleting a branch removes its history in the console view. Make sure you no longer need it before deleting.
Verify on main
Switch back to main
and open appspec.yml
to see the merged comment:
version: 0.0
os: windows
files:
- source: \index.html
destination: C:\inetpub\wwwroot
hooks:
BeforeInstall:
location: \before-install.bat
timeout: 900
# Demo Testing
Conclusion & References
You’ve successfully created a CodeCommit repository, uploaded files, managed branches, and completed a pull request merge—all via the AWS Console.
Next, explore how to integrate CodeCommit with AWS CodeBuild and CodeDeploy for automated builds and deployments.
Useful Links
Watch Video
Watch video content
Practice Lab
Practice lab