23

I have set the 'Application Healthcheck URL' (aws:elasticbeanstalk:application) for my elasticbeanstalk application, and during the night the two servers started failing this check.

It seems that the autoscaling group set up by elasticbeanstalk has a health check type of ec2 which means that the servers did not get terminated and replaced, leaving 2 out of service servers attached to the load balancer.

How can I change the autoscaling group's health check type to be elb using the elasticbeanstalk's configuration settings? I cannot find any documented way of changing this value, but it must be a fairly common requirement.

Thanks

user1207727
  • 1,543
  • 1
  • 15
  • 18
  • 4
    "I cannot find any documented way of changing this value...". I didn't explicitly state that I'd spent hours scouring the AWS EB documentation and google, but I wasn't aware that kind of detail of expended effort was required. – user1207727 Jan 27 '14 at 14:59

2 Answers2

27

It turns out the answer lies in adding a config file to the .ebextensions directory.

The AWS documentation doesn't appear to be correct, or at least not up to date.

Here it tells you that you can configure EB resources using a config file: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html

But it doesn't tell you where to put that config file. To find that out you need to follow a link to: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html

The first link helpfully tells you the name of various resources you can configure. In my case I needed 'AWSEBAutoScalingGroup'. But then it doesn't tell you what the resource type identifier (Type) or the available properties are. It has a link to the 'resource type identifiers' (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/aws-template-resource-type-ref-aeb.html), but there's no mention of autoscaling or elastic beanstalk there.

Luckily a kind soul on the AWS forums sent me a link to some helpful documentation: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-group.html

So finally I was able to create my config file which looks like this:

Resources:
    AWSEBAutoScalingGroup:
        Type: "AWS::AutoScaling::AutoScalingGroup"
        Properties:
            HealthCheckType: ELB
            HealthCheckGracePeriod: 600

This now works like a charm!

user1207727
  • 1,543
  • 1
  • 15
  • 18
1

You can create your own AutoScaling group and use it for launch configuration.

You can also configure AutoScaling with Elastic Beanstalk configuration file:

AWS Elastic Beanstalk: Customizing Environment Resources

UPDATE:

I did realise you can configure the ASG with the EB config file but there's no option to change the health check type

Look at Configure the Health State of An Instance guide, it says you can use Elastic Load Balancer health check with AutoScaling.

By default, your Auto Scaling group determines the health state of each instance by periodically checking the results of Amazon EC2 instance status checks. If you have associated your Auto Scaling group with an Elastic Load Balancing load balancer and have chosen to use the Elastic Load Balancing health check, Auto Scaling will determine the health status of the instances by checking the results of both the Amazon EC2 instance status checks and the Elastic Load Balancing instance health checks.

There's an option to pick ELB as health check type when you create AutoScaling Group:

enter image description here

Or if you use CreateAutoScalingGroup API call:

HealthCheckType
The service you want the health checks from, Amazon EC2 or Elastic Load Balancer. Valid values are EC2 or ELB.

By default, the Auto Scaling health check uses the results of Amazon EC2 instance status checks to determine the health of an instance. For more information, see Health Check.

kukido
  • 10,431
  • 1
  • 45
  • 52
  • Thanks. I'll take a look at using a custom ASG. I did realise you can configure the ASG with the EB config file but there's no option to change the health check type – user1207727 Jan 22 '14 at 17:11
  • Updated the answer with two available options to change health check type. – kukido Jan 24 '14 at 18:45
  • 1
    Thank you. Whilst these are two valid methods of updating the ASG settings, I was asking for a way to do it via Elastic Beanstalk. I didn't want to have to manually alter the ASG or run another script after deploying a new version of the application each time. – user1207727 Jan 27 '14 at 17:12
  • Well, if you are not using custom ASG and ELB, when autoscaling and load balancing are enabled in Elastic Beanstalk, ASG will use ELB health check by default. So there's no need to update any settings. – kukido Jan 27 '14 at 18:43
  • 1
    That hasn't been the case in my experience. To test the theory I just created a basic Autoscaled EB test application from scratch, and the ASG it has created indeed has health check type EC2. Maybe they changed the default behaviour recently. – user1207727 Jan 28 '14 at 19:55