Go to you AWS console then select IAM from the services menu then select Create policy Create Your Own Policy and use the following configuration
// Policy Role for Code Deploy
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"autoscaling:PutLifecycleHook",
"autoscaling:DeleteLifecycleHook",
"autoscaling:RecordLifecycleActionHeartbeat",
"autoscaling:CompleteLifecycleAction",
"autoscaling:DescribeAutoscalingGroups",
"autoscaling:PutInstanceInStandby",
"autoscaling:PutInstanceInService",
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
Then you will need to create a new EC2 custom policy
// Policy Trust for Code Deploy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"codedeploy.us-west-2.amazonaws.com",
"codedeploy.us-east-1.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
// Instance Role for EC2 Instance
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:Get*",
"s3:List*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
1.) When server is booted run the following commands as root.
yum -y update
yum install -y aws-cli
cd /home/ec2-user
2.) Here you will setup your AWS access, secret, and region.
aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
chmod +x ./install
3.) This is simply a quick hack to get the agent running faster.
sed -i "s/sleep(.*)/sleep(10)/" install
./install auto
4.) Verify it is running.
service codedeploy-agent status