Skip to content
GitHubXDiscord

Budget

The Budget resource lets you manage AWS Budgets for tracking your AWS spending and usage. You can set thresholds and get notified when your costs or usage exceed your budgeted amounts.

Create a basic budget with notifications for when your costs exceed a specified limit.

import AWS from "alchemy/aws/control";
const budget = await AWS.Budgets.Budget("monthlyBudget", {
Budget: {
BudgetName: "Monthly Cost Budget",
BudgetLimit: {
Amount: 1000,
Unit: "USD"
},
TimeUnit: "MONTHLY",
BudgetType: "COST"
},
NotificationsWithSubscribers: [
{
Notification: {
NotificationType: "ACTUAL",
ComparisonOperator: "GREATER_THAN",
Threshold: 90
},
Subscribers: [
{
SubscriptionType: "EMAIL",
Address: "notify@example.com"
}
]
}
],
ResourceTags: [
{
Key: "Environment",
Value: "Production"
}
]
});

Configure a budget with both cost and usage notifications along with resource tags for better management.

const advancedBudget = await AWS.Budgets.Budget("advancedBudget", {
Budget: {
BudgetName: "Advanced Budget",
BudgetLimit: {
Amount: 500,
Unit: "USD"
},
TimeUnit: "MONTHLY",
BudgetType: "COST"
},
NotificationsWithSubscribers: [
{
Notification: {
NotificationType: "FORECASTED",
ComparisonOperator: "GREATER_THAN",
Threshold: 80
},
Subscribers: [
{
SubscriptionType: "SNS",
Address: "arn:aws:sns:us-east-1:123456789012:BudgetAlerts"
}
]
},
{
Notification: {
NotificationType: "ACTUAL",
ComparisonOperator: "GREATER_THAN",
Threshold: 100
},
Subscribers: [
{
SubscriptionType: "EMAIL",
Address: "alerts@example.com"
}
]
}
],
ResourceTags: [
{
Key: "Project",
Value: "NewApp"
}
]
});

Create a usage budget to track resource consumption.

const usageBudget = await AWS.Budgets.Budget("usageBudget", {
Budget: {
BudgetName: "Usage Budget",
BudgetLimit: {
Amount: 1000,
Unit: "GB"
},
TimeUnit: "MONTHLY",
BudgetType: "USAGE"
},
NotificationsWithSubscribers: [
{
Notification: {
NotificationType: "ACTUAL",
ComparisonOperator: "GREATER_THAN",
Threshold: 75
},
Subscribers: [
{
SubscriptionType: "EMAIL",
Address: "usage-alerts@example.com"
}
]
}
]
});

Set up a budget with specific resource tags to help track spending across different projects.

const projectBudget = await AWS.Budgets.Budget("projectBudget", {
Budget: {
BudgetName: "Project A Budget",
BudgetLimit: {
Amount: 1500,
Unit: "USD"
},
TimeUnit: "MONTHLY",
BudgetType: "COST"
},
ResourceTags: [
{
Key: "Project",
Value: "ProjectA"
}
],
NotificationsWithSubscribers: [
{
Notification: {
NotificationType: "ACTUAL",
ComparisonOperator: "GREATER_THAN",
Threshold: 60
},
Subscribers: [
{
SubscriptionType: "EMAIL",
Address: "project-a-alerts@example.com"
}
]
}
]
});