01 Run create-security-group command (OSX/Linux/UNIX) to create the security group that will be used by the internal Classic Load Balancer. The following command example creates a security group named "cc-elb-security-group" inside a VPC identified with the ID vpc-abcd1234abcd1234, available within the US East (N. Virginia) region:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws ec2 create-security-group
--region us-east-1
--group-name cc-elb-security-group
--description "Classic Load Balancer Security Group"
--vpc-id vpc-abcd1234abcd234
02 The command output should return the ID of the new security group:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"GroupId": "sg-01234abcd1234abcd"
}
03 Run authorize-security-group-ingress command (OSX/Linux/UNIX) using the group ID returned at the previous step as the identifier parameter, to set up the inbound rules based on your application requirements (the command does not produce an output):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws ec2 authorize-security-group-ingress
--region us-east-1
--group-id sg-01234abcd1234abcd
--protocol tcp
--port 8080
--cidr 0.0.0.0/0
04 Run authorize-security-group-egress command (OSX/Linux/UNIX) using the ID of the newly created security group as the identifier parameter to configure the outbound rules based on your application needs (the command does not return an output):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws ec2 authorize-security-group-egress
--region us-east-1
--group-id sg-01234abcd1234abcd
--ip-permissions '[{"IpProtocol": "tcp", "FromPort": 8080, "ToPort": 8080, "IpRanges": [{"CidrIp": "0.0.0.0/0"}]}]'
05 Run create-load-balancer command (OSX/Linux/UNIX) to create a new, internal Classic Load Balancer in the selected AWS region:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws elb create-load-balancer
--region us-east-1
--load-balancer-name cc-internal-prod-load-balancer
--listeners "Protocol=HTTP,LoadBalancerPort=8080,InstanceProtocol=HTTP,InstancePort=8080"
--subnets "subnet-01234abcd1234abcd" "subnet-0abcd1234abcd1234"
--security-groups sg-01234abcd1234abcd
--scheme internal
06 The command output should return the DNS name for the new load balancer:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"DNSName": "cc-internal-prod-load-balancer-123456789012.us-east-1.elb.amazonaws.com"
}
07 Run register-instances-with-load-balancer command (OSX/Linux/UNIX) to register the necessary EC2 instances with the internal Classic Load Balancer created at the previous steps:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws elb register-instances-with-load-balancer
--region us-east-1
--load-balancer-name cc-internal-prod-load-balancer
--instances i-0abcd1234abcd1234 i-01234abcd1234abcd
08 The command output should return the IDs of the backend instances registered with the new load balancer:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"Instances": [
{
"InstanceId": "i-0abcd1234abcd1234"
},
{
"InstanceId": "i-01234abcd1234abcd"
}
]
}
09 If required, repeat steps no. 5 – 8 to deploy more internal Classic Load Balancer in the selected AWS region.
10 Change the AWS cloud region by updating the --region command parameter value and repeat the Remediation process for other regions.