3
votes

I have one repository in bitbucket, for deploying to elasticbeanstalk i am using codedeploy(i couldn't find any better solution). I have created elsticbeanServceRole in IAM and the policies, i have attached to that roles are

  1. AmazonEC2FullAccess
  2. AdministratorAccess
  3. AmazonAPIGatewayAdministrator
  4. codedeployServiceRolePolicy (Custom Policy)

This is the content of codedeployServiceRolePolicy

{
"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 i copied Role ARN and paste in codedeploy application settings

I have successfully configured the bitbucket codedeploy settings, for that i created one role called bitbucketRole with custom policy. Policy content is

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
            "autoscaling:*",
            "codedeploy:*",
            "ec2:*",
            "elasticloadbalancing:*",
            "iam:AddRoleToInstanceProfile",
            "iam:CreateInstanceProfile",
            "iam:CreateRole",
            "iam:DeleteInstanceProfile",
            "iam:DeleteRole",
            "iam:DeleteRolePolicy",
            "iam:GetInstanceProfile",
            "iam:GetRole",
            "iam:GetRolePolicy",
            "iam:ListInstanceProfilesForRole",
            "iam:ListRolePolicies",
            "iam:ListRoles",
            "iam:PassRole",
            "iam:PutRolePolicy",
            "iam:RemoveRoleFromInstanceProfile",
            "s3:*"
        ],
        "Resource": "*"
    }
]

}

Problem

Now when i click on "Deploy to AWS" in bitbucket, deployment from bitbucket to codedeploy is triggering but i am getting error at codedeploy console

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. (Error code: HEALTH_CONSTRAINTS).

Please Help me

1
I got same error in same situation and it turned out that CodeDeploy agent was not installed in my Elasticbeanstalk's EC2 instance. - Igor Bljahhin

1 Answers

1
votes

Is CodeDeploy agent running on your instances? Also, can you paste the Error Info from one of the failed instances?

HEALTH_CONSTRAINTS usually means CodeDeploy was unable to continue the deployment due to the health constraints set in the deployment config. Too many instances already failed and CodeDeploy can't take down any more instances.