- Setup the VPC peering between
VPC-80-Port
andVPC-9080-Port
- Setup the Security group allow 80 and 9080 port
- Create EC2 with c4.large in
VPC-80-Port
and EC2 with t2.medium inVPC-9080-Port
-
Create ALB in
VPC-9080-Port
-
Target group for ALB which point to IP address in peered VPC
VPC-80-Port
and Port is 80 -
Target group for ALB which point to IP address in local VPC
VPC-9080-Port
and Port is 9080 -
Verify access ALB 80 and 9080 can get success response
-
Create NLB in
VPC-9080-Port
-
Target group for NLB which point to IP address in peered VPC
VPC-80-Port
and Port is 80 -
Target group for NLB which point to IP address in local VPC
VPC-9080-Port
and Port is 9080 -
Verify access NLB 80 and 9080 can get success response
When you use Elastic Load Balancing with your Auto Scaling group, it's not necessary to register individual EC2 instances with the load balancer. Instances that are launched by your Auto Scaling group are automatically registered with the load balancer. Likewise, instances that are terminated by your Auto Scaling group are automatically deregistered from the load balancer.
There is a key difference in how the load balancer types are configured. With Application Load Balancers, Network Load Balancers, instances are registered as targets with a target group, and you route traffic to the target group. With Classic Load Balancers, instances are registered directly with the load balancer.
Right now, Application or Network Load Balancer target groups are only support instance target groups that belong to the same VPC as your Auto Scaling group are available for selection. Classic Load Balancers can only attach the instance in the same VPC.
I would suggest below approaches:
-
(1) Adjust your network design to avoid cross VPC Load Balancer and Keep Autoscaling group and Load Balancer within same VPC (Recommanded)
-
(2) Internet facing ALB in public VPC and Intranet NLB with auto-scaling group in private VPC, setup the AWS PrivateLink to integrate Internet facing ALB with Intranet NLB
Now let's work on PrivateLink
Note: When you use the PrivateLink, there is no need setup the VPC peering between two VPC.
You can also use the PrivateLink to do blue-green deloyment
-
Create the Endpoint in Public VPC and Record the subnet ENI IP
-
Create the Internet facing ALB in Public VPC and the Target group point to VPC Endpoint subnet ENI IP
You can see the Internet facing ALB in Public VPC and Intranet NLB with auto-scaling group in private VPC
-
Verify the ALB response and running load testing with apache ab to verify the auto-scaling
curl http://<public-alb>