How to setup a Billing Alarm in an AWS Account
Unfortunately, there is no direct way to set AWS limit on billing because there may be some service or production servers running and that needs uptime all the time.
So, if there is a mechanism to limit the billing, that means once the limit is reached, the server should be terminated along with the EBS volume to maintain the Billing limit. But as the server is not up and running that is costing a fortune to the business, so there is no way to limit AWS billing.
There are multiple ways, you can restrict the elevation of price on billing by following some standard method which includes.
Shutting down the servers which are not in use.
Use the Storage lifecycle to store the data to different storage type based on its usability.
Using Lambda function to trigger a backup or stopping servers at night when they are not in use.
Try to leverage the spot instance where it is applicable.
Try to leverage the Reserved instance if the time horizon is longer. It saves a fortune, trusts me.
Create a script to delete the EBS volume which is in the available state for a period of 2/3 days or as per your company standard.
Use IAM policy to restrict users to launch bigger instances type for testing purpose.
There are many other ways, you can do apart from that.
But, there is a way you can setup an email alert when the price crosses a certain amount.
To do that, you can follow the below process. I am sure that will help you to get notified and take necessary steps to control the cost.
Log in to your AWS account as a root user.
Find your name and click on the dropdown, select “My Billing Dashboard”
That will redirect to a new page, select “Billing Preferences” & check the option “Receive Billing Alerts”
Then to save the settings, click on “Save preferences”
Then, expand the service “CloudWatch”
On the left pane, select “Billing” & then click on “Create Alarm”
Set your amount that you think is feasible as per the project and use your email address where you would like to get the email notification and then click on “Create Alarm” on bottom right corner.
Note: You will receive an email from AWS to confirm your subscription. Follow the email and you are all set.
Once the amount reaches the threshold amount, you will receive an email.
I hope this is informative and I thank you for investing your time to learn something new.