Creating a load balancer
AWS offers two kinds of load balancers:
- Classic load balancer
- Application load balancer
We're going to focus on the application load balancer. It's effectively an upgraded, second generation of the ELB service, and it offers a lot more functionality than the classic load balancer. HTTP/2 and WebSockets are supported natively, for example. The hourly rate also happens to be cheaper.
Note
Application load balancers do not support layer-4 load balancing. For this kind of functionality, you'll need to use a classic load balancer.
How to do it...
- Open up your text editor and create a new CloudFormation template. We're going to require a VPC ID and some subnet IDs as
Parameters
. Add them to your template like this:
AWSTemplateFormatVersion: '2010-09-09' Parameters: VPCID: Type: AWS::EC2::VPC::Id Description: VPC where load balancer and instance will launch SubnetIDs: Type: List<AWS::EC2::Subnet::Id> ...