Before we begin with the Project, we need to make sure we have the following prerequisites installed And Configured:
AWS Account with Administrator policy. You Can also give Specific permission to the user. Make sure you Generate HTTPS Git credentials for AWS CodeCommit for the user. This can be used to push code from a local source to a CodeCommit repository.
- You can do this by going to IAM \=> Users \=> Security credentials => HTTPS Git credentials for AWS CodeCommit => Generate credentials.
EC2 Instance ( AMI- Ubuntu, Type- t2.micro, Region: us-east-1 )
You can Install CodeDeploy Agent by running the below script while creating an ec2 instance or after that. and these steps are for Ubuntu AMI.
#!/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-us-east-1.s3.us-east-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
Attach a service role to an EC2 instance with the following policy:
(Note: Restart codedeploy-agent service After attaching the service role policy to the EC2 instance)
CodeDeploy Service Role for Code deploy with policy:
Create an S3 Bucket for storing your build artifacts.
Great🎊🎉 You're all set for the project. Your Ec2 Instance is now prepared for deploying the application. For additional information on the full project, please check out this blog.