Your CI/CD pipeline on AWS - Part 3
3 min read
What is CodeDeploy?
- AWS CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services.
CodeDeploy can deploy application content that runs on a server and is stored in Amazon S3 buckets, GitHub repositories, or Bitbucket repositories. CodeDeploy can also deploy a serverless Lambda function. You do not need to make changes to your existing code before you can use CodeDeploy.
Task-01 :
Read about Appspec.yaml file for CodeDeploy.
Deploy index.html file on EC2 machine using nginx
you have to set up a CodeDeploy agent in order to deploy code on EC2
Prepare Your Application: Before using AWS CodeDeploy, ensure that your application is ready for deployment. This includes packaging your code, scripts, and any necessary artifacts into a deployable format.
Create an Application: Sign in to the AWS Management Console, navigate to the CodeDeploy service, and create an application. The application represents the name of your software or service that you want to deploy.
Create a Deployment Group: Within the created application, you need to create a deployment group. A deployment group defines the set of instances or Lambda functions that you want to deploy your application to. You can group instances based on tags, Auto Scaling groups, or manually choose them.
Configure Deployment Settings: Within the deployment group, you can configure various deployment settings, such as the deployment type (in-place or blue/green), deployment configuration, load balancer settings, etc., depending on the compute service you are deploying to.
Choose a Deployment Method: AWS CodeDeploy supports two deployment methods: in-place and blue/green.
In-Place Deployment: This method deploys the new version of your application directly on the existing instances, updating the application in the same place.
Blue/Green Deployment: This method provisions a new set of instances (green environment) running the new version of your application. Once the new environment is healthy, the traffic is shifted from the old environment (blue) to the new one (green).
Deploy Your Application: After configuring the deployment settings and choosing the deployment method, you can initiate the deployment. AWS CodeDeploy will handle the deployment process and update the instances or Lambda functions based on your specified settings.
Monitor the Deployment: During the deployment, you can monitor the progress through the AWS CodeDeploy console or the AWS CLI. CodeDeploy provides detailed logs and metrics to track the deployment process and ensure its success.
Task-02 :
Add appspec.yaml file to CodeCommit Repository and complete the deployment process.
version: 0.0 os: linux files: - source: / destination: /var/www/html/ hooks: AfterInstall: - location: scripts/install_nginx.sh timeout: 300 runas: root ApplicationStart: - location: scripts/start_nginx.sh timeout: 300 runas: root