Created
April 2, 2020 05:26
-
-
Save maatthc/a8f1479d3e2804620f9e289f90a62e13 to your computer and use it in GitHub Desktop.
Cloud Formation template for Budget, using tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: Budget alerts for various AWS services | |
Parameters: | |
Environment: | |
Type: String | |
Description: Deployment environment for the budget checks | |
GlueDevEndpointDPUHours: | |
Type: Number | |
Description: Number of Glue dev endpoint DPU hours we budget for in the period | |
S3APIRequestsCost: | |
Type: String | |
Description: Budget in US$ for Number of S3 API requests, for in the period | |
S3AccessLoggingRequestsCost: | |
Type: String | |
Description: Budget in US$ for Number of S3 Access Logging requests, for in the period | |
NotificationsStack: | |
Description: Notifications Stack Name | |
Type: String | |
Default: "" | |
Version: | |
Type: String | |
BudgetTag: | |
Description: Used to create AWS Budget and alerts | |
Type: String | |
Default: s3-access-log | |
Resources: | |
GlueDevEndpointBudget: | |
Type: AWS::Budgets::Budget | |
Properties: | |
Budget: | |
BudgetName: !Sub "${Environment} - Glue dev endpoint DPU hours" | |
BudgetType: "USAGE" | |
CostFilters: | |
UsageType:AWS Glue: | |
- "APS2-DEVED-DPU-Hour" | |
TimeUnit: MONTHLY | |
BudgetLimit: | |
Amount: !Ref GlueDevEndpointDPUHours | |
Unit: "DPU-Hour" | |
NotificationsWithSubscribers: | |
- Notification: | |
NotificationType: "ACTUAL" | |
ComparisonOperator: "GREATER_THAN" | |
Threshold: 100 | |
ThresholdType: "PERCENTAGE" | |
Subscribers: | |
- SubscriptionType: "SNS" | |
Address: | |
Fn::ImportValue: !Sub ${NotificationsStack}::AWSBudgetNotificationsTopic | |
S3APIRequestsCostBudget: | |
Type: AWS::Budgets::Budget | |
Properties: | |
Budget: | |
BudgetName: !Sub "${Environment} - S3 API requests" | |
BudgetType: COST | |
CostFilters: | |
UsageTypeGroup: | |
- "S3: API Requests - Standard" | |
TimeUnit: MONTHLY | |
BudgetLimit: | |
Amount: !Ref S3APIRequestsCost | |
Unit: USD | |
NotificationsWithSubscribers: | |
- Notification: | |
NotificationType: "ACTUAL" | |
ComparisonOperator: "GREATER_THAN" | |
Threshold: 100 | |
ThresholdType: "PERCENTAGE" | |
Subscribers: | |
- SubscriptionType: "SNS" | |
Address: | |
Fn::ImportValue: !Sub ${NotificationsStack}::AWSBudgetNotificationsTopic | |
S3AccessLoggingRequestsCostBudget: | |
Type: AWS::Budgets::Budget | |
Properties: | |
Budget: | |
BudgetName: !Sub "${Environment} - S3 Access Logging requests" | |
BudgetType: COST | |
CostFilters: | |
UsageTypeGroup: | |
- "S3: API Requests - Standard" | |
TagKeyValue: | |
- !Sub "user:Budget$${BudgetTag}" | |
TimeUnit: MONTHLY | |
BudgetLimit: | |
Amount: !Ref S3AccessLoggingRequestsCost | |
Unit: USD | |
NotificationsWithSubscribers: | |
- Notification: | |
NotificationType: "ACTUAL" | |
ComparisonOperator: "GREATER_THAN" | |
Threshold: 100 | |
ThresholdType: "PERCENTAGE" | |
Subscribers: | |
- SubscriptionType: "SNS" | |
Address: | |
Fn::ImportValue: !Sub ${NotificationsStack}::AWSBudgetNotificationsTopic | |
Outputs: | |
Version: | |
Value: !Ref Version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment