I have a CloudFormation template that starts an Elastic Beanstalk service. I want to set the health-check URL to /health
in the template.
What is the convention for this in JSON?
You need to set the OptionSettings
property of the AWS::ElasticBeanstalk::Environment
:
For example:
{
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "sampleApplication" },
"Description" : "AWS Elastic Beanstalk Environment running PHP Sample Application",
"VersionLabel" : "Initial Version",
"OptionSettings" : [
{
"Namespace" : "elasticbeanstalk:application",
"OptionName" : "Application Healthcheck URL",
"Value" : "/health"
}
],
"TemplateName" : "DefaultConfiguration",
}
}
In this example, the option Application Healthcheck URL
is set to /health
For more information see:
Rodrigo's answer is good but incomplete.
You also need to modify the health_check_type to ELB, otherwise, when your web application process crash, but your EC2 instead remains healthy, the node won't get replaced.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environmentconfig-autoscaling-healthchecktype.html
this is the format I am using
$ cat .ebextensions/0090_healthcheckurl.config
Resources:
AWSEBAutoScalingGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
Properties:
HealthCheckType: "ELB"
HealthCheckGracePeriod: "600"
option_settings:
- namespace: aws:elasticbeanstalk:application
option_name: Application Healthcheck URL
value: /_status
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With