3

I'm trying to automate the configuration of my Elastic Beanstalk application using Saved Configs.

Does anyone have an example of how to get the application load balancer created from Elastic Beanstalk to use a different health check port?

If not, is there a way to access the underlying resource so that I can apply a custom HealthCheckPort: 8081 to the Target Group?


Details and Attempts To-Date:

The application is a simple DropWizard based Java application, which provides HTTP APIs on port 8080, and a health check API on port 8081.

I've had success configuring the environment using a Classic ELB via the following OptionSettings:

OptionSettings:
  aws:elasticbeanstalk:environment:
    EnvironmentType: LoadBalanced
    LoadBalancerType: classic
  aws:elasticbeanstalk:application:
    Application Healthcheck URL: HTTP:8081/healthcheck
  aws:elasticbeanstalk:environment:process:default:
    MatcherHTTPCode: '200'
    Port: '8080'
    Protocol: HTTP
  aws:elb:healthcheck:
    HealthyThreshold: '3'
    Interval: '10'
    Timeout: '5'
    UnhealthyThreshold: '5'
  aws:elb:listener:80:
    ListenerProtocol: HTTP
    InstancePort: '8080'
    InstanceProtocol: HTTP
    ListenerEnabled: true
  aws:elb:loadbalancer:
    CrossZone: true

However, when I update the config to use an Application ELB, the health check associated with the target group is set to the application port (8080) and not the health check port (8081). This causes the application to start into a failed state, which can only be corrected by manually changing the Target Group health check port.

OptionSettings:
  aws:elasticbeanstalk:environment:
    EnvironmentType: LoadBalanced
    LoadBalancerType: application
  aws:elasticbeanstalk:application:
    Application Healthcheck URL: HTTP:8081/healthcheck
  aws:elasticbeanstalk:environment:process:default:
    MatcherHTTPCode: '200'
    Port: '8080'
    Protocol: HTTP
  aws:elbv2:listener:default:
    DefaultProcess: default
    ListenerEnabled: true
    Protocol: HTTP
  aws:elbv2:loadbalancer:
    AccessLogsS3Enabled: false
    IdleTimeout: '60'

I cannot find any other relevant fields in the AWS Elastic Beanstalk command options documentation.

I've also thought about doing custom resource modifications, but the only ELB referenced is AWSEBLoadBalancer of type AWS::ElasticLoadBalancing::LoadBalancer which is a classic load balancer, but the modification I need to make are in type AWS::ElasticLoadBalancingV2::TargetGroup for application load balancer.

1

Use Terraform or CloudFormation to manage the required Load Balancer, EC2 Instances and other resources. Although it requires more work up-front than ElasticBeanstalk, it is possible to precisely control every aspect of your resources. Software installation and instance configuration from .ebextensions can be replaced with AWS::CloudFormation::Init and AWS's cfn-init helper script.

I'll also recommend troposphere for generating CloudFormation templates. The syntax maps 1-to-1 against the CloudFormation's resource syntax, but will generate errors for misspelled property names or invalid property types. Combined with boto it was possible to fully automate my application deployment lifecycle with simple python command line utilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.