DEV Community

Cover image for AWS Budget with CloudFormation
Jorge Tovar
Jorge Tovar

Posted on

AWS Budget with CloudFormation

Creating an AWS budget is a crucial step when starting a new AWS account or project in the cloud. It helps to ensure that your AWS spending aligns with your current business goals and prevents unexpected costs from affecting your budget.

While many tutorials focus on manual budget creation, there's an even better solution for those who prioritize automation. By utilizing an AWS budget, you can set custom cost thresholds for your AWS accounts, and receive notifications when actual costs exceed the budgeted amount. This allows for efficient cost management and ensures that your AWS usage stays within your desired budget

Go to CloudFormation:

Image description

Save & Load the template from the PC

AWSTemplateFormatVersion: "2010-09-09"
Description: "Minimal-Spend Budget"
Parameters:
  Email:
    Type: String
    Description: Please enter the email address to which budget notifications should be addressed.
Resources:
  BasicBudget:
    Type: "AWS::Budgets::Budget"
    Properties:
      Budget:
        BudgetLimit:
          Amount: 10
          Unit: USD
        TimeUnit: MONTHLY
        BudgetType: COST
      NotificationsWithSubscribers:
        - Notification:
            NotificationType: ACTUAL
            ComparisonOperator: GREATER_THAN
            Threshold: 99
          Subscribers:
            - SubscriptionType: EMAIL
              Address: !Ref Email
        - Notification:
            NotificationType: ACTUAL
            ComparisonOperator: GREATER_THAN
            Threshold: 50
          Subscribers:
          - SubscriptionType: EMAIL
            Address: !Ref Email
        - Notification:
            NotificationType: ACTUAL
            ComparisonOperator: GREATER_THAN
            Threshold: 10
          Subscribers:
          - SubscriptionType: EMAIL
            Address: !Ref Email
Outputs:
  BudgetId:
    Value: !Ref BasicBudget

Enter fullscreen mode Exit fullscreen mode

Validate Creation

Image description

Budget result ๐Ÿš€

Image description

Conclusion

Overall, having an AWS budget can help you better understand and control your AWS costs, and can help you make informed decisions about how to use AWS resources

Top comments (0)