CI/CD pipeline on AWS
Table of contents
- What is CodeCommit?
- 1. Version Control
- 2. Security
- 3. Scalability
- 4. Integration
- 5. Collaboration
- 6. High Availability
- Task-01 :
- Set up a code repository on CodeCommit and clone it on your local.
- You need to set up GitCredentials in your AWS IAM.
- Use those credentials locally and then clone the repository from CodeCommit.
- Step 1: Create a Repository in AWS CodeCommit
- Step 2: Set Up Git Credentials in AWS IAM
- Step 3: Configure Git with AWS Credentials Locally
- Step 4: Clone the CodeCommit Repository Locally
- Step 5: Verify the Clone
- Optional Step: Push Initial Code
- Set up a code repository on CodeCommit and clone it on your local.
- You need to set up GitCredentials in your AWS IAM.
- Use those credentials locally and then clone the repository from CodeCommit.
- Step 1: Create a Repository in AWS CodeCommit
- Step 2: Set Up Git Credentials in AWS IAM
- Step 3: Configure Git with AWS Credentials Locally
- Step 4: Clone the CodeCommit Repository Locally
- Step 5: Verify the Clone
- Optional Step: Push Initial Code
- Task-02 :
- Add a new file from local and commit to your local branch
- Push the local changes to the CodeCommit repository.
- Step 1: Add a New File Locally
- Step 2: Stage the New File
- Step 3: Commit the Changes
- Step 4: Push the Changes to CodeCommit
- Step 5: Verify the Changes
- What is CodeBuild?
- Key Features of CodeBuild
- How AWS CodeBuild Works
- Use Cases
- Example Workflow with CodeBuild
- Task-03 :
- Read about the Buildspec file for Codebuild.
- create a simple index.html file in the CodeCommit Repository
- you have to build the index.html using the NGINX server
- Step 1: Understand the Buildspec File
- Step 2: Create an index.html in CodeCommit
- Step 3: Create the buildspec.yml File
- Step 4: Configure a CodeBuild Project in AWS
- Step 5: Verify Nginx is Serving index.html
- Task-04 :
- What is CodeDeploy?
- Key Features of CodeDeploy
- How AWS CodeDeploy Works
- Deployment Lifecycle Hooks
- Use Cases
- Task-05 :
- Read about Appspec.yaml file for CodeDeploy.
- Deploy index.html file on EC2 machine using nginx
- you have to set a CodeDeploy agent to deploy code on EC2.
- Step 1: Understand appspec.yml
- Step 2: Prepare Your index.html File
- Step 3: Create the appspec.yml File
- Step 4: Create Supporting Shell Scripts
- Step 5: Set Up an EC2 Instance for CodeDeploy
- Step 6: Set Up a CodeDeploy Application
- Step 7: Create a Deployment
- Step 8: Verify the Deployment
- Task-06 :
- Add app spec.yaml file to CodeCommit Repository and complete the deployment process.
- Step 1: Add the appspec.yml to the CodeCommit Repository
- Step 2: Verify Files in CodeCommit
- Step 3: Start the Deployment Process
- Step 4: Monitor Deployment Progress
- Step 5: Verify the Deployment
- Tips for Debugging (If Deployment Fails):
- What is CodePipeline?
- Key Features of CodePipeline
- How CodePipeline Works
- Example Use Case
- Benefits of CodePipeline
- Task-07 :
- Create a Deployment group of Ec2 Instance.
- Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild, and deploys it to a Deployment Group.
- Step 1: Create a Deployment Group for EC2 Instances
- Step 2: Create the CodePipeline
- Step 3: Add Source Stage (CodeCommit)
- Step 4: Add Build Stage (CodeBuild)
- Step 5: Add Deploy Stage (CodeDeploy)
- Step 6: Review and Create a Pipeline
- Step 7: Verify the Deployment
What is CodeCommit?
AWS CodeCommit is a fully managed source control service from Amazon Web Services. It allows you to host secure, scalable Git repositories in the cloud. Here’s a quick overview of its key features:
1. Version Control
CodeCommit uses Git, supporting distributed version control to help developers manage code changes.
2. Security
It offers encryption at rest and in transit. Integration with AWS Identity and Access Management (IAM) enables fine-grained access control.
3. Scalability
It can handle any size of repository and automatically scales to accommodate large projects or teams.
4. Integration
CodeCommit integrates with other AWS services like CodePipeline for CI/CD workflows, CloudWatch for monitoring, and AWS Lambda for triggering actions based on repository changes.
5. Collaboration
Developers can work together by pushing and pulling changes, creating branches, and submitting pull requests for code reviews.
6. High Availability
The service is designed for high durability and availability, ensuring your repositories are accessible when needed.
CodeCommit is often used in DevOps workflows to securely store and version application code while integrating with CI/CD processes. It’s ideal for teams or enterprises already using the AWS ecosystem.
Task-01 :
Set up a code repository on CodeCommit and clone it on your local.
You need to set up GitCredentials in your AWS IAM.
Use those credentials locally and then clone the repository from CodeCommit.
Step 1: Create a Repository in AWS CodeCommit
Sign in to AWS Management Console:
- Navigate to CodeCommit under the Developer Tools section.
Create a Repository:
Click on "Create Repository".
Enter a name and optional description.
Click Create.
Step 2: Set Up Git Credentials in AWS IAM
Open the IAM Console:
- Go to the IAM dashboard.
Select or Create a User:
If you already have a user, click on the user name.
If not, create a new user with programmatic access.
Add Git Credentials:
On the user details page, go to the Security Credentials tab.
Scroll down to HTTPS Git credentials for AWS CodeCommit.
Click Generate credentials.
Download the credentials or note down the username and password.
Step 3: Configure Git with AWS Credentials Locally
Open a Terminal/Command Prompt:
Run the following commands to configure your Git credentials:
git config --global credential.helper store
When you first clone the repository, Git will prompt you to enter the credentials. They will be stored locally for future use.
Step 4: Clone the CodeCommit Repository Locally
Go back to your CodeCommit repository page.
Click on Clone URL (choose HTTPS).
Run the following command in your terminal (replace
your-repo-url
with the actual URL):git clone https://git-codecommit.<region>.amazonaws.com/v1/repos/your-repo-name
When prompted, enter the Git credentials you set up in Step 2.
Step 5: Verify the Clone
Once cloned, navigate into the directory using:
cd your-repo-name
Run:
git status
This should show the working directory as clean, confirming the repository is cloned successfully.
Optional Step: Push Initial Code
If you want to push some initial code to the repository:
Create a sample file in the cloned directory:
echo "Hello, CodeCommit!" > sample.txt
Add and commit the file:
git add sample.txt git commit -m "Initial commit"
Push the changes:
git push origin main
Task-02 :
Add a new file from local and commit to your local branch
Push the local changes to the CodeCommit repository.
Step 1: Add a New File Locally
Navigate to your cloned CodeCommit repository on your local system:
cd your-repo-name
Create a new file (e.g.,
new-file.txt
) with some content:echo "This is a new file for Task-02" > new-file.txt
Step 2: Stage the New File
Stage the new file to prepare it for the commit:
git add new-file.txt
You can confirm the file is staged by running:
git status
It should display the new file under "Changes to be committed."
Step 3: Commit the Changes
Commit the changes with a message:
git commit -m "Added new-file.txt for Task-02"
Step 4: Push the Changes to CodeCommit
Push the changes to the CodeCommit repository:
git push origin main
If your repository uses a different branch name (e.g., master
or development
), replace main
with the appropriate branch.
Step 5: Verify the Changes
Go to the AWS CodeCommit repository in the AWS Management Console.
Check that
new-file.txt
is now visible in the repository.
What is CodeBuild?
AWS CodeBuild is a fully managed continuous integration (CI) service provided by Amazon Web Services (AWS). It compiles source code, runs tests, and produces software packages that are ready for deployment. Here's a detailed overview:
Key Features of CodeBuild
Build Automation
Automates the build process, eliminating the need for on-premise build servers.Scalability
Scales automatically meet the size and number of concurrent builds, ensuring fast execution even for large projects.No Server Management
Since it’s fully managed, AWS handles all infrastructure and maintenance.Flexible Environment
Supports multiple environments and programming languages such as Java, Python, Node.js, Ruby, Go, Docker, .NET Core, and more. You can also create custom-built environments.Integration with AWS Services
Works well with other AWS services like CodeCommit, CodePipeline, S3, and CloudWatch, making it ideal for DevOps workflows.Security
CodeBuild encrypts artifacts and environment variables and integrates with AWS Identity and Access Management (IAM) for access control.Parallel Builds
You can run multiple builds concurrently, which speeds up your CI/CD pipeline and reduces development time.
How AWS CodeBuild Works
Source
The source code is pulled from supported repositories (e.g., CodeCommit, GitHub, GitHub Enterprise, Bitbucket, or S3).Build
CodeBuild executes the build process according to the instructions in a buildspec.yml file (or inline build commands).Artifacts
The output of the build process (e.g., binaries or Docker images) is uploaded to a specified storage location (e.g., S3).Logs
Build logs are sent to Amazon CloudWatch, allowing developers to monitor and debug the build process in real time.
Use Cases
Continuous Integration: Automates code compilation and testing every time new code is committed.
Automated Testing: Run unit tests, integration tests, or performance tests on every code change.
Container Builds: Build and package Docker images for containerized applications.
Multi-Platform Builds: Create builds for different platforms or languages in the same project.
Example Workflow with CodeBuild
A developer commits code to CodeCommit.
CodePipeline triggers a build in CodeBuild.
CodeBuild compiles the code, runs tests, and stores artifacts in S3.
Successful builds are then deployed or moved to the next stage in the pipeline.
Task-03 :
Read about the Buildspec file for Codebuild.
create a simple index.html file in the CodeCommit Repository
you have to build the index.html using the NGINX server
Step 1: Understand the Buildspec File
The buildspec.yml
the file is a configuration file used by AWS CodeBuild to define build steps. It contains:
Version: Specifies the build spec version.
Phases: Defines the build steps (install, pre-build, build, post-build).
Artifacts: Specifies files to store or upload as build outputs.
Step 2: Create an index.html
in CodeCommit
Navigate to Your CodeCommit Repository:
- Clone the repository or navigate to it in the AWS Management Console.
Create a Simple
index.html
: Add anindex.html
file with basic content:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hello, Nginx!</title> </head> <body> <h1>Hello from AWS CodeBuild with Nginx!</h1> </body> </html>
Commit this file to your repository.
Step 3: Create the buildspec.yml
File
Add a buildspec.yml
file in the root of your repository:
version: 0.2
phases:
install:
commands:
- echo "Installing Nginx..."
- yum install -y nginx
pre_build:
commands:
- echo "Starting Nginx service"
- service nginx start
build:
commands:
- echo "Copying index.html to Nginx directory"
- cp index.html /usr/share/nginx/html/
post_build:
commands:
- echo "Build complete. Index.html is now being served by Nginx."
Step 4: Configure a CodeBuild Project in AWS
Open the AWS Management Console and navigate to CodeBuild.
Create a New Build Project:
Source: Select your CodeCommit repository.
Build spec: Ensure the option is set to "Use the buildspec.yml file in the source code".
Environment:
Choose a managed Ubuntu environment.
Runtime: Use a standard runtime (Amazon Linux 2).
Service Role: Create or select an appropriate IAM role with CodeBuild permissions.
Start the Build:
- Run the build and monitor the logs.
Step 5: Verify Nginx is Serving index.html
During the build process, CodeBuild should log that Nginx has started and
index.html
has been copied to the Nginx web directory (/usr/share/nginx/html/
).This confirms that
index.html
was successfully built and served by Nginx.
Task-04 :
Add the build spec.yaml file to CodeCommit Repository and complete the build process.
Step 1: Add buildspec.yml
to CodeCommit Repository
Navigate to Your Local Repository (if cloned locally):
cd your-repo-name
Create the
buildspec.yml
File in the root directory with the following content:version: 0.2 phases: install: commands: - echo "Installing Nginx..." - yum install -y nginx pre_build: commands: - echo "Starting Nginx service" - service nginx start build: commands: - echo "Copying index.html to Nginx directory" - cp index.html /usr/share/nginx/html/ post_build: commands: - echo "Build complete. Index.html is now being served by Nginx."
Stage and Commit the Changes:
git add buildspec.yml git commit -m "Added buildspec.yml to automate the Nginx build process" git push origin main
Step 2: Start a Build in AWS CodeBuild
Navigate to the AWS Management Console:
- Go to CodeBuild and select your build project.
Start a New Build:
Click on Start Build for your existing CodeBuild project.
Ensure the project is configured to pull the latest changes from CodeCommit.
Click Start Build to begin.
Step 3: Monitor the Build Process
Check the Build Logs:
You can view detailed logs in the Build Logs section of the CodeBuild project dashboard.
Ensure that each phase (
install
,pre_build
,build
,post_build
) runs without errors.
Expected log output:
Installation of Nginx
Starting Nginx service
Copying
index.html
to the Nginx directoryConfirmation message: "Build complete. Index.html is now being served by Nginx."
Step 4: Verify Build Completion
The build should be completed successfully without errors.
If you set up artifact storage (e.g., S3) or additional post-build actions, check that they are also executed.
What is CodeDeploy?
AWS CodeDeploy is a fully managed deployment service that automates software deployment to a variety of computing services such as Amazon EC2 instances, on-premises servers, AWS Lambda, and Amazon ECS. It is designed to facilitate reliable, automated deployments for various application types.
Key Features of CodeDeploy
Automated Deployments
- Automates the deployment process to reduce manual errors and ensure consistent deployments across different environments.
Blue/Green and In-Place Deployments
In-Place Deployment: Updates the existing instances in the deployment group.
Blue/Green Deployment: Creates a new environment (green), tests it, and switches traffic from the old environment (blue) to the new one once validated.
Wide Compute Support
- Supports Amazon EC2, ECS, on-premises servers, and AWS Lambda functions.
Application Lifecycle Hooks
- Supports pre- and post-deployment hooks to run custom scripts at different stages of the deployment process (e.g.,
BeforeInstall
,AfterInstall
).
- Supports pre- and post-deployment hooks to run custom scripts at different stages of the deployment process (e.g.,
Monitoring and Rollbacks
- Monitors the deployment status in real-time and can automatically roll back in case of deployment failure.
Integration with Other AWS Services
- Works with CodePipeline for end-to-end CI/CD pipelines and CloudWatch for monitoring and alarms.
How AWS CodeDeploy Works
Application Setup
- An application is defined in CodeDeploy, and a deployment group is created (a set of EC2 instances, ECS services, or Lambda functions).
AppSpec File
- The
appspec.yml
orappspec.json
the file defines the deployment instructions, including where to copy files and what commands to run at various lifecycle hooks.
- The
Deployment
- CodeDeploy pulls the specified code or artifact from an S3 bucket, GitHub, or CodeCommit and deploys it according to the instructions in the
appspec
file.
- CodeDeploy pulls the specified code or artifact from an S3 bucket, GitHub, or CodeCommit and deploys it according to the instructions in the
Post-Deployment Monitoring
- The deployment is monitored, and CodeDeploy can automatically roll back if errors are detected or health checks fail.
Deployment Lifecycle Hooks
BeforeInstall
: Runs before application files are copied to the instance.AfterInstall
: Runs after the files have been copied.ApplicationStart
: Runs after the application has started.ApplicationStop
: Runs before the application is stopped (during redeployments).ValidateService
: Runs to validate the deployed application’s health.
Use Cases
Web Application Deployment: Automating the rollout of new versions of a web app to EC2 instances or on-premises servers.
Lambda Deployment: Automatically deploying new versions of AWS Lambda functions in response to new code pushes.
Microservices Deployment: Managing complex deployments of containerized services running on Amazon ECS.
Task-05 :
Read about Appspec.yaml file for CodeDeploy.
Deploy index.html file on EC2 machine using nginx
you have to set a CodeDeploy agent to deploy code on EC2.
Step 1: Understand appspec.yml
The appspec.yml
the file is used by AWS CodeDeploy to define how to manage files and run commands during a deployment. Key sections:
version: The version of the AppSpec file (usually
0.0
for EC2).os: The operating system type (
linux
orwindows
).files: Specifies the source and destination of files to be deployed.
hooks: Defines lifecycle event hooks (e.g.,
BeforeInstall
,AfterInstall
,ApplicationStart
).
Step 2: Prepare Your index.html
File
In your CodeCommit repository, create a simple
index.html
file if it doesn’t exist:<!DOCTYPE html> <html> <head> <title>Hello from CodeDeploy!</title> </head> <body> <h1>Deployed using AWS CodeDeploy</h1> </body> </html>
Step 3: Create the appspec.yml
File
In the root of your repository, create the appspec.yml
file with the following content:
version: 0.0
os: linux
files:
- source: /
destination: /usr/share/nginx/html/
hooks:
BeforeInstall:
- location: scripts/install_nginx.sh
timeout: 300
ApplicationStart:
- location: scripts/start_nginx.sh
timeout: 300
Step 4: Create Supporting Shell Scripts
Create a scripts/
directory in your repository with the following two scripts:
install_
nginx.sh
: Installs and starts Nginx.#!/bin/bash yum update -y yum install -y nginx
start_
nginx.sh
: Ensures Nginx is started.#!/bin/bash service nginx start
Make sure both scripts are executable:
chmod +x scripts/install_nginx.sh scripts/start_nginx.sh
Step 5: Set Up an EC2 Instance for CodeDeploy
Launch an EC2 Instance:
Choose Amazon Linux 2 or Ubuntu as the AMI.
Ensure that the security group allows inbound traffic on port 80 (for Nginx).
Assign an appropriate IAM role to the instance with the AWSCodeDeployRole policy.
Install the CodeDeploy Agent (on the EC2 instance):
Connect to the EC2 instance via SSH and run:
sudo yum update -y sudo yum install -y ruby sudo yum install -y wget wget https://aws-codedeploy-<region>-latest.s3.amazonaws.com/latest/install sudo chmod +x ./install sudo ./install auto
Start and verify the agent:
sudo service codedeploy-agent start sudo service codedeploy-agent status
Step 6: Set Up a CodeDeploy Application
Go to the AWS CodeDeploy Console:
Create a new application.
Choose the compute platform as "EC2/On-premises".
Create a Deployment Group:
Name the deployment group.
Attach it to the EC2 instance (using tags or manually selecting the instance).
Ensure the service role has
AWSCodeDeployRole
permissions.
Step 7: Create a Deployment
In CodeDeploy, click "Create Deployment".
Select Your Application and Deployment Group.
Choose the Revision Source:
- If using CodeCommit, select the repository and branch.
Click Deploy.
Step 8: Verify the Deployment
Once the deployment is complete, access the EC2 instance’s public IP or domain name in a browser:
http://<ec2-public-ip>
You should see the
index.html
page with the message "Deployed using AWS CodeDeploy".
Task-06 :
Add app spec.yaml file to CodeCommit Repository and complete the deployment process.
Step 1: Add the appspec.yml
to the CodeCommit Repository
Navigate to Your Local Repository:
cd your-repo-name
Ensure the
appspec.yml
the file is present at the root of your repository. The content should be similar to this:version: 0.0 os: linux files: - source: / destination: /usr/share/nginx/html/ hooks: BeforeInstall: - location: scripts/install_nginx.sh timeout: 300 ApplicationStart: - location: scripts/start_nginx.sh timeout: 300
Stage, Commit, and Push the Changes:
git add appspec.yml git commit -m "Added appspec.yml for CodeDeploy" git push origin main
Step 2: Verify Files in CodeCommit
Go to the AWS CodeCommit Console.
Confirm that the
appspec.yml
and related scripts (install_
nginx.sh
andstart_
nginx.sh
) are present in the repository.
Step 3: Start the Deployment Process
Go to the AWS CodeDeploy Console.
Select Your Application and Deployment Group that were previously created.
Create a New Deployment:
Application Name: Select the appropriate application.
Deployment Group: Choose the group linked to your EC2 instance.
Revision Type: Select "CodeCommit".
Repository: Choose the repository where you added the
appspec.yml
.Branch: Choose the branch where you committed the file.
Click Deploy.
Step 4: Monitor Deployment Progress
Check the Deployment Status:
In the CodeDeploy console, monitor the status of each lifecycle event (e.g.,
BeforeInstall
,ApplicationStart
).Ensure that each event runs successfully.
View Logs:
- If any phase fails, view the logs for detailed error messages and troubleshoot accordingly.
Step 5: Verify the Deployment
Once the deployment is complete, open your browser and navigate to:
http://<your-ec2-instance-public-ip>
You should see the
index.html
page, confirming a successful deployment.
Tips for Debugging (If Deployment Fails):
Check Logs:
- View logs located in
/var/log/aws/codedeploy-agent
on your EC2 instance.
- View logs located in
Ensure EC2 Security Group allows HTTP traffic (port 80).
Confirm CodeDeploy Agent is running on the EC2 instance:
sudo service codedeploy-agent status
What is CodePipeline?
AWS CodePipeline is a fully managed continuous integration and continuous delivery (CI/CD) service that automates the build, test, and deployment phases of your application. It enables you to quickly and reliably release updates with minimal manual intervention.
Key Features of CodePipeline
Automation: Automatically builds, tests, and deploys code whenever a change is detected in the source repository (e.g., CodeCommit, GitHub, S3).
Integrations:
Native integration with AWS services like CodeCommit, CodeBuild, CodeDeploy, and Lambda.
Third-party tools (e.g., Jenkins, GitHub, Bitbucket).
Pipeline Stages: CodePipeline consists of multiple stages, each representing a step in the release process (e.g., Source, Build, Deploy, Approval).
Parallel Execution: Can run multiple stages concurrently to speed up the delivery process.
Manual Approvals: Allows you to add approval steps before proceeding to the next stage.
Artifact Management: Manages and passes build artifacts between different stages in the pipeline.
Version Control Integration: Works with popular version control systems for source code.
How CodePipeline Works
Source Stage:
Monitors change in a source repository (CodeCommit, GitHub, S3).
When changes are detected, they trigger the pipeline.
Build Stage:
- Uses services like CodeBuild or third-party tools to compile the code, run tests, and package the application.
Test (Optional):
- Runs additional integration or unit tests to verify the application.
Deploy Stage:
- Deploys the built and tested code to environments like EC2, Lambda, ECS, or S3 using CodeDeploy or other deployment services.
Approval Stage (Optional):
- Allows for manual approvals before moving to the next stage, ensuring compliance and oversight.
Example Use Case
For a web application:
Source: Code changes are pushed to AWS CodeCommit.
Build: CodeBuild compiles the application and runs tests.
Deploy: CodeDeploy deploys the application to EC2 instances.
Approval: A manual approval stage before production deployment.
Benefits of CodePipeline
Faster Releases: Automates the entire release process.
Reliability: Ensures consistent deployment processes across environments.
Scalability: Easily adapts to larger applications and teams.
Flexibility: Supports multiple third-party tools and services.
Reduced Manual Effort: Lessens the chance of human errors during the deployment process.
Task-07 :
Create a Deployment group of Ec2 Instance.
Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild, and deploys it to a Deployment Group.
Step 1: Create a Deployment Group for EC2 Instances
Go to AWS CodeDeploy Console:
- Navigate to CodeDeploy in the AWS Management Console.
Create a New Application:
Application Name: Choose a meaningful name (e.g., "MyWebApp").
Compute Platform: Select EC2/On-Premises.
Create a Deployment Group:
Deployment Group Name: Provide a name (e.g., "MyWebApp-Deployment-Group").
Service Role: Select the IAM role with the AWSCodeDeployRole policy.
Environment Configuration:
Choose Amazon EC2 Instances.
Tag the EC2 instances with a key-value pair (e.g.,
Environment=Production
).
Deployment Settings: Leave the defaults or choose your preferred settings.
Click Create Deployment Group.
Step 2: Create the CodePipeline
Go to AWS CodePipeline Console:
- Navigate to CodePipeline and click Create Pipeline.
Pipeline Settings:
Pipeline Name: Choose a meaningful name (e.g., "MyWebApp-Pipeline").
Service Role: Create or select an existing role with permissions for CodePipeline, CodeCommit, CodeBuild, and CodeDeploy.
Step 3: Add Source Stage (CodeCommit)
Source Provider: Select AWS CodeCommit.
Repository Name: Choose the repository where your code is stored.
Branch: Select the branch to track (e.g., "main").
Click Next.
Step 4: Add Build Stage (CodeBuild)
Build Provider: Select AWS CodeBuild.
Project: Create a new CodeBuild project:
Project Name: Provide a name (e.g., "MyWebApp-Build").
Environment: Use Managed Image and select the appropriate OS and runtime (e.g., Amazon Linux 2, Standard Image).
Build spec: Ensure you have an
buildspec.yml
in the root of your repository or specify it manually in the project.Click Create Build Project.
Back in the CodePipeline console, select the newly created build project.
Step 5: Add Deploy Stage (CodeDeploy)
Deploy Provider: Select AWS CodeDeploy.
Application Name: Choose the application you created earlier.
Deployment Group: Select the deployment group you created.
Click Next.
Step 6: Review and Create a Pipeline
Review all stages and settings.
Click Create Pipeline.
The pipeline will automatically run, triggering the build and deployment process when changes are pushed to the CodeCommit repository.
Step 7: Verify the Deployment
Check CodePipeline:
- Monitor the progress of each stage (Source, Build, Deploy).
Check CodeDeploy:
- Ensure that the deployment is successful.
Access the Application:
- Open the EC2 instance’s public IP in a browser to verify the deployed
index.html
.
- Open the EC2 instance’s public IP in a browser to verify the deployed