On your journey of making a CI/CD pipeline on AWS with these tools, We have completed AWS CodeCommit & CodeBuild.
Next we'll learn below tools/services:
CodeDeploy
CodePipeline
S3
What is CodeDeploy ?
AWS CodeDeploy streamlines application deployments to various environments, including Amazon EC2 instances, on-premises setups, serverless Lambda functions, and Amazon ECS services. It facilitates deploying application content from Amazon S3 buckets, GitHub repositories, or Bitbucket repositories onto servers. Additionally, it can manage the deployment of serverless Lambda functions without requiring modifications to your current codebase prior to use.
Lets understand concept with help of task.
Task-01 :
Read about Appspec.yaml file for CodeDeploy.
Deploy index.html file on EC2 machine using nginx
you have to setup a CodeDeploy agent in order to deploy code on EC2
Solution
Step 1:
The appspec.yaml file is a crucial component in the AWS CodeDeploy deployment process. It provides a set of instructions for CodeDeploy on how to deploy the application. This file is typically included in the root directory of the application's deployment package.
Step 2:
Go to codeDeploy service in AWS console and create new application.
We also need to create deployment group so select create new deployment group.
Now we need service -role in above steps so i have created separate role in IAM and mention same here below policies attached to role just for reference.
We explicitly need to connect EC2 instance on which. we are going deploy our code. so i have create new ec2 instance and mention name of instance in next step.
Step 2: Lets install nginx on ec2 instance.
Verrify the installation using public-ip:80 of ec2instance and we could see nginx index page.
Step 3: Setup code agent deployment.
to setup code agent will create below install.sh file.
Added execute rights to file and run it.
Task-02 :
- Add appspec.yaml file to CodeCommit Repository and complete the deployment process.
Solution
We are crafting appspec.yaml file with below syntax.
For supporting I have created another 2 files 1 for installation of nginx and another one for start service and mention same path in appspec.yaml file.
Let's push code to the codecommit repository.
Freshly build the code using codeBuild and check Artifacts in S3 bucket
Build were successfully completed. Lets check S3 bucket.
As we progress in constructing our CI/CD pipeline on AWS using these tools, we've successfully implemented AWS CodeCommit, CodeBuild, and CodeDeploy. Now, wrap it up elegantly by incorporating AWS CodePipeline.
What is CodePipeline ?
CodePipeline builds, tests, and deploys your code every time there is a code change, based on the release process models you define. Think of it as a CI/CD Pipeline service
Task-01 :
- Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild and deploys it to a Deployment Group.
Solution
Step 1: navigate to awscodepipeline and select create pipeline
Review the details and hit create pipeline button.
Our pipeline has been created and started executing.
The pipeline ran successfully, allowing us to view the updated webpage via the instance's public IP on port 80.
I belive this article proves valuable in understanding AWS pipelines.
Thanks,
Kishor Chavan