I am trying to use AWS CodeDeploy to deploy a Java war file to an EC2 instance.
I already added a appspec.yml in the root of this war with this content:
version: 0.0
os: linux
files:
- source: /
destination: /var/scwcd/scwcd
I also created an EC2 instance and codeDeploy application can see this Ec2 instance. I manually upload this war file to my S3 bucket and set codeDeploy source to the S3 file. I also added enough permission for CodeDeploy to access S3 and EC2 instance.
But the deployment always failed with this message:
The overall deployment failed because too many individual instances failed deployment,
too few healthy instances are available for deployment,
or some instances in your deployment group are experiencing problems
I checked the deployment event list and found every actions are skipped without error code:
I also checked the EC2 instance and found the destination folder /var/scwcd is not there.
Does anybody know what I missed?
Thanks!
Have you installed the CodeDeploy agent [1] on EC2 Instance? All events skipped usually means the agent is not calling CodeDeploy service endpoint [2].
You can use the following in EC2 UserData to install the agent when the instance first boots up:
#!/bin/bash
sudo yum update -y
sudo yum install -y ruby wget
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent start
#!/bin/bash
apt-get -y update
apt-get -y install ruby
apt-get -y install wget
cd /home/ubuntu
wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
chmod +x ./install
./install auto
[1] https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html