- Launch EC2 instance with IAM policy to read S3
- Installing the CodeDeploy agent on EC2. SSH to instance and run:
```
sudo yum update -y
sudo yum install -y ruby wget
wget https://aws-codedeploy-eu-west-1.s3.eu-west-1/amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent status
```
- Add 2 tags to instance (Name=webserver and Environment=development)
- In CodeDeploy, create a new Application with
- Application name: CodeDeployDemo
- Compute platform: EC2/On-premises (or Lambda or ECS)
- To create a deployment, you need to create a Deployment group (set of ec2 instances) first
- Create a Service Role in IAM/Roles/CodeDeploy/AWSCodeDeployRole
- Choose Deployment type: In-place (or Blue/green)
- Chooose EC2 instances with the tag | Environment=Development
- Now click “Create deployment“
- Choose the Deployment group created before
- Set the Revision type, My application is stored:
- in S3
- In GitHub
Create Bucket and enable versioning with CLI
Profile
aws configure --profile aws-devops
```
aws s3 mb s3://aws-devops-cicddemo --region us-east-1 --profile aws-devops
aws s3api put-bucket-versioning --bucket aws-devops-cicddemo --versioning-configuration Status=Enabled --region us-east-1 --profile aws-devops
```
Deploy the files ionto S3
```
aws deploy push --application-name CodeDeployDemo --s3-location s3://aws-devops-cicddemo/codedeploy-demo/app.zip --ignore-hidden-files --region us-east-1 --profile aws-devops
```
Check if code deploy success and complete
cd /var/www/html