Deploying a Web App with AWS CodeDeploy: My Hands-On DevOps Journey

Listen to this Post

AWS CodeBuild, CodePipeline, and CodeDeploy provide a powerful CI/CD pipeline for deploying applications within the AWS ecosystem. These services are tightly integrated with other AWS tools, making them ideal for cloud-native workflows. Below is a step-by-step guide to setting up a CI/CD pipeline using AWS services.

You Should Know:

1. Setting Up AWS CodeBuild

CodeBuild compiles source code, runs tests, and produces deployable artifacts. Use the following AWS CLI command to create a build project:

aws codebuild create-project --cli-input-json file://build-project.json

Example `build-project.json`:

{
"name": "my-web-app-build",
"source": {
"type": "GITHUB",
"location": "https://github.com/username/repo.git"
},
"artifacts": {
"type": "S3",
"location": "my-artifact-bucket"
},
"environment": {
"type": "LINUX_CONTAINER",
"image": "aws/codebuild/standard:5.0"
}
}

2. Configuring AWS CodePipeline

CodePipeline orchestrates the workflow from source to deployment. Create a pipeline using:

aws codepipeline create-pipeline --cli-input-json file://pipeline.json

Example `pipeline.json`:

{
"pipeline": {
"name": "my-web-app-pipeline",
"stages": [
{
"name": "Source",
"actions": [
{
"name": "SourceAction",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "CodeCommit",
"version": "1"
},
"configuration": {
"RepositoryName": "my-repo",
"BranchName": "main"
}
}
]
},
{
"name": "Build",
"actions": [
{
"name": "BuildAction",
"actionTypeId": {
"category": "Build",
"owner": "AWS",
"provider": "CodeBuild",
"version": "1"
},
"configuration": {
"ProjectName": "my-web-app-build"
}
}
]
},
{
"name": "Deploy",
"actions": [
{
"name": "DeployAction",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CodeDeploy",
"version": "1"
},
"configuration": {
"ApplicationName": "my-web-app",
"DeploymentGroupName": "prod"
}
}
]
}
]
}
}

3. Deploying with AWS CodeDeploy

CodeDeploy automates application deployment to EC2, Lambda, or ECS. Configure `appspec.yml` for deployment rules:

version: 0.0
resources:
- TargetService:
Type: "AWS::ECS::Service"
Properties:
TaskDefinition: "arn:aws:ecs:us-east-1:123456789012:task-definition/my-task:1"
LoadBalancerInfo:
ContainerName: "web-app"
ContainerPort: 80

4. Monitoring Deployments

Check deployment status using:

aws deploy get-deployment --deployment-id d-1234567890

What Undercode Say:

AWS CI/CD tools like CodeBuild, CodePipeline, and CodeDeploy streamline DevOps workflows by integrating tightly with AWS services. For hybrid environments, consider combining GitHub Actions with AWS for flexibility. Key Linux commands for debugging AWS deployments include:

 Check EC2 instance status 
aws ec2 describe-instances --filters "Name=tag:Name,Values=my-web-app"

View CloudWatch logs 
aws logs tail /aws/codebuild/my-web-app-build --follow

Rollback a failed deployment 
aws deploy stop-deployment --deployment-id d-1234567890 

For more details, refer to the original article:

Deploying a Web App with AWS CodeDeploy: My Hands-On DevOps Journey

Expected Output:

A fully automated AWS CI/CD pipeline deploying a web application with CodeBuild, CodePipeline, and CodeDeploy.

References:

Reported By: Darryl Ruggles – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image