CI/CD pipeline on AWS - Part 4 🚀 ☁

CI/CD pipeline on AWS - Part 4 🚀 ☁

Day 53

¡

2 min read

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 Deployment group of Ec2 Instance.

    Create a CodeDeploy application:

    1. In CodeDeploy, go to Applications and click on 'Create application'.

    2. Select compute platform ‘EC2/on premises’ and click on ‘Create application’.

    3. The application is successfully created.

    4. Create a 'service role' for enabling communication between code deployment and other AWS services. Create 'code-deploy-service-role' with the below permissions.

    5. Create an Ubuntu EC2 instance:

    6. Create a deployment group:

    7. Add a deployment group name and choose 'Service role'

    8. Add instance name.

    9. A deployment group is created

    10. Install the CodeDeploy agent in the ec2 instance:

    11. You can install the CodeDeploy agent by running the following script on your EC2 instance:

      #!/bin/bash
      # This installs the CodeDeploy agent and its prerequisites on Ubuntu 22.04.
      sudo apt-get update
      sudo apt-get install ruby-full ruby-webrick wget -y
      cd /tmp
      wget https://aws-codedeploy-ap-south-1.s3.ap-south-1.amazonaws.com/releases/codedeploy-agent_1.3.2-1902_all.deb
      mkdir codedeploy-agent_1.3.2-1902_ubuntu22
      dpkg-deb -R codedeploy-agent_1.3.2-1902_all.deb codedeploy-agent_1.3.2-1902_ubuntu22
      sed 's/Depends:.*/Depends:ruby3.0/' -i ./codedeploy-agent_1.3.2-1902_ubuntu22/DEBIAN/control
      dpkg-deb -b codedeploy-agent_1.3.2-1902_ubuntu22/
      sudo dpkg -i codedeploy-agent_1.3.2-1902_ubuntu22.deb
      systemctl list-units --type=service | grep codedeploy
      sudo service codedeploy-agent status
      
    12. The code agent is running.

  • Create a CodePipeline that gets the code from CodeCommit, Builds the code using CodeBuild and deploys it to a Deployment Group.

    1. Go to the CodePipeline console. Click "Create pipeline."

    2. Enter a name for your pipeline.

    3. Under "Source provider," choose "AWS CodeCommit."

      Select the repository and branch you want to deploy.

      Click "Next."

    4. Under "Build provider," choose "AWS CodeBuild."

      Select "build project name."

      Click "Next.

    5. Under "Deploy provider," choose "AWS CodeDeploy."

      Select the deployment group you created earlier.

      Click "Next."

    6. Review the pipeline settings and click "Create pipeline."

    7. The pipeline will automatically trigger a build and deploy the new code to the EC2 instance.

    8. Successfully created a CodePipeline that automates the deployment process.

Thankyou...

Â