In this 2nd part, we’re building a CI/CD pipeline using the 'Pipeline as Code' approach, with our sights set on Lambda-based applications.
5 min read
May 26, 2023
Are you a new AWS user who has experienced bill shock while being in a free-tier plan or a professional cloud practitioner struggling to understand your team's cloud expenses? If so, you're not alone. Many AWS users are surprised by unexpected charges on their monthly bills, which can significantly increase the overall cost of using AWS services. As companies' cloud environments become more complex, lack of visibility can lead to unpredictable cloud bills and budget overruns. In this blog post, we will cover the most common unexpected charges on your AWS bill and provide tips on how to avoid them, so you can optimize your cloud costs and avoid unpleasant surprises.
It's worth mentioning that the list is not exhaustive and covers only the most common ways in which money is wasted on AWS.
One of the main common unexpected charges is related to idle resources. AWS charges for resources that are not actively used, such as idle EC2 instances, RDS databases, and Elastic Load Balancers. These charges can accumulate over time and result in significant bills. To avoid this, you can use AWS Auto Scaling to automatically adjust the number of resources based on demand. You can also use AWS Reserved Instances or Savings Plans to reduce costs by committing to a one-year or three-year term or use Spot Instances for non-critical jobs or workloads.
Another common source of idle resources is unattached EBS volumes and unused Elastic IPs. To avoid these charges appearing on your bill, create a policy that automatically deletes any unused EBS volumes or EIPs.
One major cause of infrastructure drift is the creation of resources outside of the established IaC tools such as Terraform, CloudFormation, and Pulumi, or without proper approval. When this happens, the infrastructure state is not adequately described or persisted, and the changes made to the infrastructure go unnoticed (aka shadow IT activity).
Until you have total visibility across your environment and have implemented measures to prevent the use of cloud consoles, infrastructure drift is likely to contribute to your AWS bill.
Another unexpected item that can pop up on your AWS bill is related to data transfer. AWS charges for data transfer within the platform, as well as data transfer to and from the internet. Many users are unaware of this charge and end up with significant increases. To avoid this, you can use AWS services in the same region or availability zone, which is usually free of charge. You can also use AWS Direct Connect for data transfer between your data center and AWS, which can significantly reduce data transfer charges.
CloudWatch is the primary source of truth for monitoring the overall health and storing logs of active AWS cloud services. However, it is also notorious for surprise bill spikes due to the complexity of its pricing model.
The pricing is determined by various factors, such as the number of custom metrics, alarms, and dashboards, logs ingested, stored, and analyzed, and the use of contributor insights rules and synthetics canary runs.
The most common way of rapidly driving up costs is by leaving the default retention period. This is especially true for AWS Lambda, which creates an automatic log group with an indefinite retention setting. It's also important to use alarms and dashboards for key metrics only that way avoiding unnecessary alerts and visualizations.
AWS is pretty generous with free-tier plans but without proper monitoring, you can exceed the free usage limits in a breeze. The good news is you can monitor usage through the AWS Management Console and track free tier usage. Any usage beyond the free tier limit or after a free trial has ended is charged at standard rates. To avoid charges, set up alerts to notify you before the free tier expires or usage exceeds the limit.
AWS Free Tier usage alerts automatically notify you over email when you exceed 85 percent of your Free Tier limit for each service.
When it comes to AWS EC2 costs, there are several recommendations that you can use to save money. One popular approach is to purchase Reserved Instances and Savings Plans. By doing so, companies can potentially save a lot of money on their monthly bills. However, it's important to note that simply purchasing these plans isn't enough. In order to fully reap the benefits of Reserved Instances and Savings Plans, you need to make sure that they are being used, monitored, and optimized effectively. Failure to do so can result in unexpected charges and higher costs.
Elastic Beanstalk is designed to ensure that all necessary resources are running. As a result, it will automatically relaunch any services that you stop. To prevent this, you must terminate your Elastic Beanstalk environment before terminating any resources that Elastic Beanstalk has created.
Similarly, auto-scaling groups are designed to maintain a minimum number of EC2 instances running. Ensure that you terminate your ASG or update the scaling policies to avoid unexpected charges.
AWS has many services to help monitor billing. Setting an account-wide budget alert is a relatively easy first line of defense. Secondly, regularly review and tag your resources to identify any unused or idle resources that you can terminate or downsize to reduce costs. Thirdly, use AWS Cost Explorer to analyze and visualize your costs, identify cost trends, and optimize your spending. Finally, take advantage of AWS tools such as CloudWatch and AWS Config to monitor and optimize your resources continuously.
If you’re looking for an all-in-one platform, you can also leverage open-source tools like Komiser to build your cloud asset inventory, tag resources, set up budget alerts, and bring accountability to cloud spend.
Unexpected charges on AWS bills can put businesses out of the market. However, with the right practices and tools in place, companies can detect and troubleshoot overspending issues before they ever occur.
Whether you're just starting out with AWS or you’re a seasoned DevOps engineer, Komiser can help you catch potential cost optimization opportunities early, before they become a larger problem.
Regardless if you are a Developer, DevOps, or Cloud engineer. Dealing with the cloud can be tough at times, especially on your own. If you are using Tailwarden or Komiser and want to share your thoughts doubts and insights with other cloud practitioners feel free to join our Tailwarden discord server. Where you will find tips, community calls, and much more.