ELB
Elastic Load Balancing v2 (ALB/NLB) for distributing traffic across targets with listener rules.
Configuration
| Property | Value |
|---|---|
| Protocol | AwsQuery |
| Signing Name | elasticloadbalancing |
| Persistence | No |
ELB uses the AwsQuery protocol: POST requests with Content-Type: application/x-www-form-urlencoded and an Action= parameter. The CLI command is elbv2.
Quick Start
Create a load balancer, target group, and listener:
# Create an Application Load Balancer
aws --endpoint-url http://localhost:4566 \
elbv2 create-load-balancer \
--name my-alb \
--type application \
--scheme internet-facing \
--subnets subnet-abc12345 subnet-def67890
# Create a target group
aws --endpoint-url http://localhost:4566 \
elbv2 create-target-group \
--name my-targets \
--protocol HTTP \
--port 8080 \
--vpc-id vpc-abc12345 \
--target-type ip \
--health-check-path /health
# Create an HTTP listener
aws --endpoint-url http://localhost:4566 \
elbv2 create-listener \
--load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:000000000000:loadbalancer/app/my-alb/abc123 \
--protocol HTTP \
--port 80 \
--default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:000000000000:targetgroup/my-targets/abc123Operations
Load Balancers
CreateLoadBalancer— create an Application or Network Load Balancer- Input:
Names.member.1(required),Type(applicationornetwork),Scheme(internet-facingorinternal),Subnets.member.N(list of subnet IDs),SecurityGroups.member.N(list of SG IDs),IpAddressType(ipv4ordualstack),Tags - Returns:
LoadBalancers.memberlist withLoadBalancerArn,DNSName,State.Code(active)
- Input:
DeleteLoadBalancer— delete a load balancer- Input:
LoadBalancerArn
- Input:
DescribeLoadBalancers— list load balancers with optional ARN filter- Input: optional
LoadBalancerArns.member.N,Names.member.N,Marker,PageSize
- Input: optional
DescribeLoadBalancerAttributes— return current attributes for a load balancer- Input:
LoadBalancerArn - Returns:
Attributes.memberlist of{Key, Value}pairs; defaults includeaccess_logs.s3.enabled,deletion_protection.enabled,idle_timeout.timeout_seconds
- Input:
ModifyLoadBalancerAttributes— update and store attributes (deletion protection, idle timeout, access logs, etc.)- Input:
LoadBalancerArn,Attributes.member.N(list of{Key, Value}) - Returns: the updated attribute list
- Input:
SetSecurityGroups— replace the security groups on a load balancer- Input:
LoadBalancerArn,SecurityGroups.member.N - Returns:
SecurityGroupIdslist
- Input:
SetSubnets— replace the subnets on a load balancer- Input:
LoadBalancerArn,Subnets.member.N - Returns:
AvailabilityZoneslist
- Input:
Target Groups
CreateTargetGroup— create a target group for load balancer routing- Input:
Name(required),Protocol(HTTP,HTTPS,TCP,TLS,UDP),Port,VpcId,TargetType(instance,ip,lambda),HealthCheckPath,HealthCheckProtocol,HealthCheckIntervalSeconds,HealthyThresholdCount - Returns:
TargetGroups.memberlist withTargetGroupArn
- Input:
DeleteTargetGroup— delete a target groupDescribeTargetGroups— list target groups with optional filtersDescribeTargetGroupAttributes— return current attributes for a target group- Input:
TargetGroupArn - Returns:
Attributes.memberlist; defaults includederegistration_delay.timeout_seconds,stickiness.enabled,stickiness.type,load_balancing.algorithm.type
- Input:
ModifyTargetGroupAttributes— update and store target group attributes- Input:
TargetGroupArn,Attributes.member.N(list of{Key, Value})
- Input:
RegisterTargets— register EC2 instances or IP addresses as targets- Input:
TargetGroupArn,Targets.member.N(list of{Id, Port}whereIdis an instance ID or IP)
- Input:
DeregisterTargets— remove targets from a target group- Input:
TargetGroupArn,Targets.member.N
- Input:
DescribeTargetHealth— check the health status of targets in a group- Input:
TargetGroupArn, optionalTargets.member.N - Returns:
TargetHealthDescriptions.memberwithTarget.Id,TargetHealth.State(alwayshealthyin AWSim)
- Input:
Listeners
CreateListener— create a listener on a load balancer- Input:
LoadBalancerArn,Protocol,Port,DefaultActions.member.1(e.g.,Type=forward,TargetGroupArn=...) - Returns:
Listeners.memberwithListenerArn
- Input:
DeleteListener— delete a listenerDescribeListeners— list listeners for a load balancerModifyListener— update listener configuration (port, protocol, default actions)- Input:
ListenerArn, optionalPort,Protocol,DefaultActions.member.N - Returns: updated
Listeners.memberlist
- Input:
DescribeListenerCertificates— list certificates attached to an HTTPS/TLS listener- Input:
ListenerArn - Returns:
Certificates.memberlist withCertificateArn,IsDefault
- Input:
AddListenerCertificates— attach additional certificates to a listener- Input:
ListenerArn,Certificates.member.N(list of{CertificateArn})
- Input:
RemoveListenerCertificates— detach certificates from a listener- Input:
ListenerArn,Certificates.member.N
- Input:
Rules
CreateRule— create a routing rule with conditions and actions- Input:
ListenerArn,Conditions.member.N(path patterns, host headers, etc.),Actions.member.N,Priority(integer) - Returns:
Rules.memberwithRuleArn,Priority
- Input:
DeleteRule— delete a routing ruleDescribeRules— list rules for a listenerModifyRule— update rule conditions and actions- Input:
RuleArn, optionalConditions.member.N,Actions.member.N - Returns: updated
Rules.memberlist
- Input:
Tags
AddTags— add tags to a load balancer, target group, or listener- Input:
ResourceArns.member.N,Tags.member.N
- Input:
RemoveTags— remove tags from ELB resourcesDescribeTags— list tags for ELB resources
Curl Examples
# 1. Create a load balancer via curl
curl -s -X POST http://localhost:4566 \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/elasticloadbalancing/aws4_request, SignedHeaders=host, Signature=fake" \
--data-urlencode 'Action=CreateLoadBalancer' \
--data-urlencode 'Name=my-alb' \
--data-urlencode 'Type=application' \
--data-urlencode 'Subnets.member.1=subnet-abc12345' \
--data-urlencode 'Subnets.member.2=subnet-def67890'
# 2. Describe load balancers
curl -s -X POST http://localhost:4566 \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/elasticloadbalancing/aws4_request, SignedHeaders=host, Signature=fake" \
--data-urlencode 'Action=DescribeLoadBalancers'
# 3. Register targets in a target group
curl -s -X POST http://localhost:4566 \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/elasticloadbalancing/aws4_request, SignedHeaders=host, Signature=fake" \
--data-urlencode 'Action=RegisterTargets' \
--data-urlencode 'TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:000000000000:targetgroup/my-targets/abc123' \
--data-urlencode 'Targets.member.1.Id=10.0.1.100' \
--data-urlencode 'Targets.member.1.Port=8080'SDK Example
import {
ElasticLoadBalancingV2Client,
CreateLoadBalancerCommand,
CreateTargetGroupCommand,
CreateListenerCommand,
DescribeTargetHealthCommand,
} from '@aws-sdk/client-elastic-load-balancing-v2';
const elb = new ElasticLoadBalancingV2Client({
region: 'us-east-1',
endpoint: 'http://localhost:4566',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
// Create load balancer
const { LoadBalancers } = await elb.send(new CreateLoadBalancerCommand({
Name: 'my-alb',
Type: 'application',
Scheme: 'internet-facing',
Subnets: ['subnet-abc12345', 'subnet-def67890'],
}));
const lbArn = LoadBalancers?.[0]?.LoadBalancerArn!;
console.log('LB ARN:', lbArn);
console.log('DNS:', LoadBalancers?.[0]?.DNSName);
// Create target group
const { TargetGroups } = await elb.send(new CreateTargetGroupCommand({
Name: 'my-targets',
Protocol: 'HTTP',
Port: 8080,
VpcId: 'vpc-abc12345',
TargetType: 'ip',
HealthCheckPath: '/health',
}));
const tgArn = TargetGroups?.[0]?.TargetGroupArn!;
// Create listener
await elb.send(new CreateListenerCommand({
LoadBalancerArn: lbArn,
Protocol: 'HTTP',
Port: 80,
DefaultActions: [{ Type: 'forward', TargetGroupArn: tgArn }],
}));
// Check target health
const { TargetHealthDescriptions } = await elb.send(new DescribeTargetHealthCommand({
TargetGroupArn: tgArn,
}));
console.log('Targets:', TargetHealthDescriptions?.map(t => ({
id: t.Target?.Id,
state: t.TargetHealth?.State,
})));Behavior Notes
- ELB uses the
AwsQueryprotocol — the AWS CLI useselbv2(notelb) for ALB/NLB resources. - Load balancers are registered in AWSim but no actual traffic routing or health checking occurs.
DescribeTargetHealthalways returnshealthyfor all registered targets.DNSNamefor load balancers follows the pattern{name}-{id}.{region}.elb.amazonaws.com.- State is in-memory only and lost on restart.