01 Run describe-load-balancers command (OSX/Linux/UNIX) to describe the configuration information available for the selected AWS Classic Load Balancer (see Audit section part I to identify the right ELB resource):
aws elb describe-load-balancers
--region us-east-1
--load-balancer-name MyWebAppLoadBalancer
02 The command output should return the requested configuration metadata which will be useful later when the new load balancer will be created:
{
"LoadBalancerDescriptions": [
{
"Subnets": [
"subnet-19e7cc6f",
"subnet-2b394201"
],
"CanonicalHostedZoneNameID": "Z35SXDOTRQ7X7K",
"CanonicalHostedZoneName": "MyWebAppLoadBalancer-387005122.
us-east-1.elb.amazonaws.com",
"ListenerDescriptions": [
{
"Listener": {
"InstancePort": 80,
"LoadBalancerPort": 80,
"Protocol": "HTTP",
"InstanceProtocol": "HTTP"
},
"PolicyNames": []
}
],
"HealthCheck": {
"HealthyThreshold": 10,
"Interval": 30,
"Target": "HTTP:80/index.html",
"Timeout": 5,
"UnhealthyThreshold": 2
},
"VPCId": "vpc-2fb56548",
"BackendServerDescriptions": [],
"Instances": [
{
"InstanceId": "i-045ce6fda405da1b3"
},
{
"InstanceId": "i-0f1a7517a463e674a"
}
],
"DNSName": "MyWebAppLoadBalancer-387005122.
us-east-1.elb.amazonaws.com",
"SecurityGroups": [
"sg-e454519e"
],
"Policies": {
"LBCookieStickinessPolicies": [],
"AppCookieStickinessPolicies": [],
"OtherPolicies": []
},
"LoadBalancerName": "MyWebAppLoadBalancer",
"CreatedTime": "2015-11-12T09:29:41.140Z",
"AvailabilityZones": [
"us-east-1d",
"us-east-1a"
],
"Scheme": "internet-facing",
"SourceSecurityGroup": {
"OwnerAlias": "123456789012",
"GroupName": "web-app-sg-production"
}
}
]
}
03 Run create-load-balancer command (OSX/Linux/UNIX) using the existing load balancer (ELB) configuration details returned at the previous step to launch a new AWS Application Load Balancer (ALB):
aws elbv2 create-load-balancer
--region us-east-1
--name MyWebAppALB
--scheme internet-facing
--subnets subnet-19e7cc6f subnet-2b394201
--security-groups sg-e454519e
--tags Key=Environment,Value=production
04 The command output should return the new ALB metadata:
{
"LoadBalancers": [
{
"VpcId": "vpc-2fb56548",
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-east-1:
123456789012:loadbalancer/app/
MyWebAppALB/4cbe232aa162303a",
"State": {
"Code": "provisioning"
},
"DNSName": "MyWebAppALB-1554377808.
us-east-1.elb.amazonaws.com",
"SecurityGroups": [
"sg-e454519e"
],
"LoadBalancerName": "MyWebAppALB",
"CreatedTime": "2016-10-14T15:48:32.940Z",
"Scheme": "internet-facing",
"Type": "application",
"CanonicalHostedZoneId": "Z35SXDOTRQ7X7K",
"AvailabilityZones": [
{
"SubnetId": "subnet-19e7cc6f",
"ZoneName": "us-east-1a"
},
{
"SubnetId": "subnet-2b394201",
"ZoneName": "us-east-1d"
}
]
}
]
}
05 Run create-target-group command (OSX/Linux/UNIX) using the existing ELB configuration details returned at step no. 2 to build the required target group for the newly created ALB:
aws elbv2 create-target-group
--region us-east-1
--name MyWebAppTargetGroup
--protocol HTTP
--port 80
--vpc-id vpc-2fb56548
--health-check-protocol HTTP
--health-check-port traffic-port
--health-check-path /index.html
--health-check-interval-seconds 30
--health-check-timeout-seconds 5
--healthy-threshold-count 10
--unhealthy-threshold-count 2
06 The command output should return the new target group metadata:
[
"TargetGroups": [
{
"HealthCheckPath": "/index.html",
"HealthCheckIntervalSeconds": 30,
"VpcId": "vpc-2fb56548",
"Protocol": "HTTP",
"HealthCheckTimeoutSeconds": 5,
"HealthCheckProtocol": "HTTP",
"UnhealthyThresholdCount": 2,
"HealthyThresholdCount": 10,
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:
123456789012:targetgroup/
MyWebAppTargetGroup/1400a30941f6df98",
"Matcher": {
"HttpCode": "200"
},
"HealthCheckPort": "traffic-port",
"Port": 80,
"TargetGroupName": "MyWebAppTargetGroup"
}
]
}
07 Now run register-targets command (OSX/Linux/UNIX) to add the necessary targets, i.e. the EC2 instances running behind the existing Classic Load Balancer, to the new target group created at the previous step (the command does not produce an output):
aws elbv2 register-targets
--region us-east-1
--target-group-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/MyWebAppTargetGroup/1400a30941f6df98
--targets Id=i-045ce6fda405da1b3 Id=i-0f1a7517a463e674a
08 Run create-listener command (OSX/Linux/UNIX) to create, configure and attach the necessary HTTP/HTTPS listener to the newly created AWS ALB:
aws elbv2 create-listener
--region us-east-1
--load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyWebAppALB/4cbe232aa162303a
--protocol HTTP
--port 80
--default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/MyWebAppTargetGroup/1400a30941f6df98
09 The command output should return the target group metadata:
{
"Listeners": [
{
"Protocol": "HTTP",
"DefaultActions": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:
us-east-1:123456789012:targetgroup/
MyWebAppTargetGroup/1400a30941f6df98",
"Type": "forward"
}
],
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-east-1:
123456789012:loadbalancer/app/MyWebAppALB/
4cbe232aa162303a",
"Port": 80,
"ListenerArn": "arn:aws:elasticloadbalancing:us-east-1:
123456789012:listener/app/MyWebAppALB/
4cbe232aa162303a/5f7261424793c94a"
}
]
}
10 Lastly, run describe-load-balancers command (OSX/Linux/UNIX) using the Amazon Resource Name (ARN) of the resource as identifier and custom query filters to describe the DNS name of your new AWS Application Load Balancer, information that will be useful later to update your web application domain name A record:
aws elbv2 describe-load-balancers
--region us-east-1
--load-balancer-arns arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyWebAppALB/4cbe232aa162303a
--query 'LoadBalancers[*].DNSName'
11 The command output should return the requested DNS name:
[
"MyWebAppALB-1554377808.us-east-1.elb.amazonaws.com"
]
12 Now test your Application Load Balancer by using the DNS name returned at the previous step to make sure that the HTTP/HTTPS traffic is distributed properly between the registered instances within the ALB target group.
13 As soon as the testing phase is complete, update the DNS record that associates your domain name with the load balancer by replacing the ELB DNS name with the ALB DNS name in order to redirect the traffic to your new AWS Application Load Balancer.
14 Once the traffic is redirected entirely to the new ALB run delete-load-balancer command (OSX/Linux/UNIX) to delete your Classic Load Balancer (the command does not produce an output):
aws elb delete-load-balancer
--region us-east-1
--load-balancer-name MyWebAppLoadBalancer
15 Repeat steps no. 1 - 14 to migrate other HTTP/HTTPS web application running behind ELBs to new AWS ALBs within the current region.
16 Change the AWS region by updating the --region command parameter value and repeat steps no. 1 - 15 for other regions.