Elephant in the room - use AWS Budgets' Usage Types !!
Tags: aws, nat, cost, vpc
Published: 2023-10-14 04:07:01

Welcome to another AWS Cost optimization blog rather about tracking or being on track for saving costs

In earlier posts, we have seen on creating on budgets to alert us and to keep track of our spend, reservation utilization or savings plans utilizations can be created & alerted when threshold is reached

But when we study AWS Bill, monthly or weekly or daily level, we have a "Dimension" on specific service level and yet again there is another level of granularity that gives "Usage Type" level of filter. This "Usage Type" is reporting the level of hours( in terms of utilization in 'Cost & Unit Graph')

While studying a monthly bill, I noticed majority is utilized against Usage Type "NATGateway Hours". With this in agenda, let us see what can be done or looked into to reduce the usage & track them on monthly basis

Basically, a NAT Gateway is created in a VPC, it is essentially a 'Network Address Translator'. When 'Public' it gives internet access for EC2 instances in private subnet and when 'Private' it allows access between VPC(s), on-premise instances. 

#####Ideally, the consumption of NAT Gateway usage costs needs to be tracked, analyzed & re-worked based on use case scenarios, but that is for another day. Before all that, I am setting a budget for usage type, as my use case is around Nat Gateway#####

Please follow the below steps to track the 'Usage Type' budget alert, so that we are on track for where the most of the utilization goes 

_**Step 1**_

i) Create a budget from AWS Budget service
ii) select 'Custom Template' while creating the budget

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsn7dzljv56rvciinth8.png)

_**Step 2**_

i) Name the budget with description 
ii) select 'Usage Type' as 'USE2-NAT Gateway Hours'
iii) This is being selected, as the use case revolves around tracking this cost from the monthly bill
iii) There are many other 'Usage Types' provided in AWS and use them as according to your requirement

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4qldglghuusf5g3svu4k.png)

_**Step 3**_

i) Next, is about seeing the budget that you plan or budget to spend on this category 
ii) 'Monthly' type budget
iii) 'Recurring' helps to keep track of the same amount/hours every month for this 'USE2-NAT gateway hours' category. This will help in understanding the usage beyond the limit, and steps can be taken to reduce the usage first hand

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kjbdglu3ag0ru0z8ms3g.png)

_**Step 4**_

i) Interestingly, most useful part is that, more than one service could have costed this usage/amount for 'Usage Type' and we can restrict with those, as well
ii) I have selected "AWS All services" but if required services could be limited too. For example, EC2 services etc

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvs6zbi8irfgfdex2qua.png)

_**Step 5**_

i) Now, all that is left out is set the email ids, for which the alert has to be sent out
ii) Alerts can be AWS SNS Topic as well or AWS Chime to inform teams/groups
iii) Here, I have given simple email id, but officially, this will be your official group which has to be alerted on the threshold
iv) my alert threshold is '90%' and this could be defined as needed

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rx4wa00184ehua61z52p.png)

_**Step 6**_

i) Below is the budget post the creation
ii) Budget already is in alert state with 120% breach as I have set 'Oct 2023' as start month. Ideally if set for future date the alert would be on time any day while the 90% usage has been met with 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ez4ofjoaaixs178r43x.png)

_**Step 7**_

i) Yet, got the email alert from AWS Budgets, regarding the threshold breach for 500 Hours usage of NAT Gateway for month of Oct, 2023

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj29xtyq4d21gfti8og4.png)

Please note that this 'Usage Type' I created targeting 'Nat Gateway' usage to track based on by requirement but go ahead and create one for your business or personal requirement as per your services usage or usage types. There are lot of other Usage Types available for tracking

Thanks again !!