Member-only story
Reduce your application cost, by using a single Application Load Balancer with a multi-domain name with Route53 A Record alias using AWS CDK as Infrastructure as Code
So why convert multi Application Load Balancer into a single Application Load Balancer? Every application load balancer you have will cost you $0.0225 hourly or $16.2 monthly just to have an Application Load Balancer, then you will pay for min. 1 LCU to $0.008 hourly or $5.76$ a month so every Application Load Balancer you create will have a minimum cost of $21.92 each month on your total bill cost.
So if you can accept to share your application load balancer with multi-services you can save a lot of dollars in this way I will teach you in this article.
I will create a network with a single NAT gateway, and 2 Availability Zone else our application load balancer won't work, then I will create 2 ECS clusters running a Fargate instance then I will add the application load balancer target groups to our ECS service so the binding on port 80 will go based on the domain down to our ECS cluster domains.
At the end of this article, I will create our AWS Route53 Hosted Zone so it will have an alias for pointing to our application load balancer to point the traffic from the internet down to the right ECS Cluster.
AWS VPC Network — AWS CDK
The first thing we need to be sure are created and ready to use is our VPC Network, if your settings inside your VPC Network are not correct you will not be available to create your application load balancer.
We have added a single NAT Gateway and support to the availability zone, if you change it to one available zone you will not get the application load balancer up and running, so be sure you always use at least two availability zones.