I am new to aws, and I need it for a student project. Unfortunately a lot of the resources online are more than 1 year old, so I was not aware about the costs for IPv4 addresses introduced last year. I managed to use many services while staying in the free tier, but IPv4 got me.
This is the current setup for my project’s backend: I have an ECS service with a single EC2 instance and an application load balancer. I know an application load balancer for a single ec2 instance is kinda pointless but I wanted to be able to talk about the scalability of that approach when presenting my project, plus I don’t think it would be a good practice to directly use an EIP associated with the EC2 instances. Correct me if I am wrong but I think that ECS might terminate the instance at any time and replace it, and I would need to associate the EIP again. I use a proxy HTTP API gateway, mainly to be able to provide HTTPS.
I put the application load balancer in a public VPC, as such I started paying for IPv4 addresses. I don’t think IPv6 is an option as API gateway probably doesn’t support it.
I had the load balancer in 3 availability zones, but I was only paying for 3 IPv4 addresses: 1 for the EC2 instance, and 2 for the load balancer. Then I changed the availability zones of the load balancer from 3 to 2 (2 is the minimum or I would have gone with 1). Surprisingly, I now had 4 IPv4 addresses: 1 for the EC2 and 3 for the load balancer. Changed it back the way it was, but I now keep paying for 4 addresses.
Before this I had tried putting the load balancer and the ec2 in a private VPC. To do this I actually changed the main route table for my default VPC, effectively making it private, and I created a new load balancer, making sure to set it as internal. Unfortunately, when I got to the part of making API gateway be able to reach the load balancer, I found out my region doesn’t support VPC links for HTTP APIs, so I changed everything back the way it was.
I need to present this project in one month, so 4 IPv4 addresses should sum up to a $17+ after taxes in my region. I’d like to avoid it but if that’s the only thing I end up paying in october I might just accept it if the solution requires me to completely rework my setup.
I didn’t create the elastic ips, but I had to set the load balancer as internet facing, otherwise API gateway wouldn’t be able to reach it. Can I have an internet facing load balancer with no IP addresses?
I guess it might also come down to that. Though I am afraid I can’t just stop the load balancer, right? I need to delete it. And then I will have to delete the ecs service too. A little inconvenient but I guess I can manage
This situation illustrates one of the key benefits of using some form of infrastructure as code (CloudFormation, CDK, Terraform…) - you can delete and reprovision your entire infrastructure with essentially a single command, rather than worrying about the individual components. Possibly a bit late to look at introducing it now if you have limited time before your presentation, but absolutely worth learning and using from day 1 in any future projects.
You don’t have a great understanding of VPC and what really needs to have a public IP. But, learning that will take some time. So is learning that more or less expensive to you than just paying for the public IPs for a month?
may be not worth it for this project but going forwards try to architect ipv4 terminating at the LB / RP and use ipv6 behind it. beware AWS is a bit late to the party and still have ipv4 dependencies in their tech stack, eg cloudfront
Put ecs tasks in a private subnet and use internal ip addressing. Put the alb in the public subnet. Alias your application host name to the alb host name.
You only pay for IPs of services that you manage the IPs of yourself, such as EC2 instances, and ECS. But you don’t pay for IPs attached to ALBs or api gateway.
I agree with others that this cost is the price of a hamburger. Just skip burger day.
UNLESS they are judging you in the whole stack. In which case fix it. If this is just a web site class or something I would stay away from aws and just pay $5-10/mo for a normal hosting account and don’t get mixed up in aws if you don’t need to be. Don’t get me wrong, aws is great, but unlike what every ceo thinks it doesn’t mean you no longer need your IT staff and in many, many ways it is significantly harder to architect properly. Again, as a student, if you like that or want to learn it, cool. If your study focus is on graphic design or whatever then spend time getting an A rather than a C because something in aws didn’t work or took too much of your time.
AWS AppRunner could be a better solution for you, as it seems like your use case is “I want a container to be available from the internet”. It’s not covered by free tier, but a simple app will cost you about $5 per month.