Skip to content

Resource: awsBudgetsBudget

Provides a budgets budget resource. Budgets use the cost visualisation provided by Cost Explorer to show you the status of your budgets, to provide forecasts of your estimated costs, and to track your AWS usage, including your free tier usage.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "ec2", {
  budgetType: "COST",
  costFilter: [
    {
      name: "Service",
      values: ["Amazon Elastic Compute Cloud - Compute"],
    },
  ],
  limitAmount: "1200",
  limitUnit: "USD",
  name: "budget-ec2-monthly",
  notification: [
    {
      comparisonOperator: "GREATER_THAN",
      notificationType: "FORECASTED",
      subscriberEmailAddresses: ["test@example.com"],
      threshold: 100,
      thresholdType: "PERCENTAGE",
    },
  ],
  timePeriodEnd: "2087-06-15_00:00",
  timePeriodStart: "2017-07-01_00:00",
  timeUnit: "MONTHLY",
});

Create a budget for $100.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "cost", {
  budgetType: "COST",
  limitAmount: "100",
  limitUnit: "USD",
});

Create a budget with planned budget limits.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "cost", {
  plannedLimit: [
    {
      amount: "100",
      startTime: "2017-07-01_00:00",
      unit: "USD",
    },
    {
      amount: "200",
      startTime: "2017-08-01_00:00",
      unit: "USD",
    },
  ],
});

Create a budget for s3 with a limit of 3 GB of storage.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "s3", {
  budgetType: "USAGE",
  limitAmount: "3",
  limitUnit: "GB",
});

Create a Savings Plan Utilization Budget

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "savings_plan_utilization", {
  budgetType: "SAVINGS_PLANS_UTILIZATION",
  costTypes: {
    includeCredit: false,
    includeDiscount: false,
    includeOtherSubscription: false,
    includeRecurring: false,
    includeRefund: false,
    includeSubscription: true,
    includeSupport: false,
    includeTax: false,
    includeUpfront: false,
    useBlended: false,
  },
  limitAmount: "100.0",
  limitUnit: "PERCENTAGE",
});

Create a RI Utilization Budget

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "ri_utilization", {
  budgetType: "RI_UTILIZATION",
  costFilter: [
    {
      name: "Service",
      values: ["Amazon Relational Database Service"],
    },
  ],
  costTypes: {
    includeCredit: false,
    includeDiscount: false,
    includeOtherSubscription: false,
    includeRecurring: false,
    includeRefund: false,
    includeSubscription: true,
    includeSupport: false,
    includeTax: false,
    includeUpfront: false,
    useBlended: false,
  },
  limitAmount: "100.0",
  limitUnit: "PERCENTAGE",
});

Create a Cost Filter using Resource Tags

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "cost", {
  costFilter: [
    {
      name: "TagKeyValue",
      values: ["TagKey$TagValue"],
    },
  ],
});

Create a cost_filter using resource tags, obtaining the tag value from a terraform variable

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.budgetsBudget.BudgetsBudget(this, "cost", {
  costFilter: [
    {
      name: "TagKeyValue",
      values: ["TagKey$${var.TagValue}"],
    },
  ],
});

Argument Reference

For more detailed documentation about each argument, refer to the AWS official documentation.

The following arguments are supported:

  • accountId - (Optional) The ID of the target account for budget. Will use current user's account_id by default if omitted.
  • autoAdjustData - (Optional) Object containing [AutoAdjustData] which determines the budget amount for an auto-adjusting budget.
  • name - (Optional) The name of a budget. Unique within accounts.
  • namePrefix - (Optional) The prefix of the name of a budget. Unique within accounts.
  • budgetType - (Required) Whether this budget tracks monetary cost or usage.
  • costFilter - (Optional) A list of CostFilter name/values pair to apply to budget.
  • costFilters - (Optional, Deprecated) Map of CostFilters key/value pairs to apply to the budget.
  • costTypes - (Optional) Object containing CostTypes The types of cost included in a budget, such as tax and subscriptions.
  • limitAmount - (Required) The amount of cost or usage being measured for a budget.
  • limitUnit - (Required) The unit of measurement used for the budget forecast, actual spend, or budget threshold, such as dollars or GB. See Spend documentation.
  • timePeriodEnd - (Optional) The end of the time period covered by the budget. There are no restrictions on the end date. Format: 2017-01-01_12:00.
  • timePeriodStart - (Optional) The start of the time period covered by the budget. If you don't specify a start date, AWS defaults to the start of your chosen time period. The start date must come before the end date. Format: 2017-01-01_12:00.
  • timeUnit - (Required) The length of time until a budget resets the actual and forecasted spend. Valid values: monthly, quarterly, annually, and daily.
  • notification - (Optional) Object containing Budget Notifications. Can be used multiple times to define more than one budget notification.
  • plannedLimit - (Optional) Object containing Planned Budget Limits. Can be used multiple times to plan more than one budget limit. See PlannedBudgetLimits documentation.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - id of resource.
  • arn - The ARN of the budget.

Auto Adjust Data

The parameters that determine the budget amount for an auto-adjusting budget.

autoAdjustType (Required) - The string that defines whether your budget auto-adjusts based on historical or forecasted data. Valid values: forecast,historical historicalOptions (Optional) - Configuration block of Historical Options. Required for autoAdjustType of historical Configuration block that defines the historical data that your auto-adjusting budget is based on. lastAutoAdjustTime (Optional) - The last time that your budget was auto-adjusted.

Historical Options

budgetAdjustmentPeriod (Required) - The number of budget periods included in the moving-average calculation that determines your auto-adjusted budget amount. lookbackAvailablePeriods (Optional) - The integer that describes how many budget periods in your BudgetAdjustmentPeriod are included in the calculation of your current budget limit. If the first budget period in your BudgetAdjustmentPeriod has no cost data, then that budget period isn’t included in the average that determines your budget limit. You can’t set your own LookBackAvailablePeriods. The value is automatically calculated from the budgetAdjustmentPeriod and your historical cost data.

Cost Types

Valid keys for costTypes parameter.

  • includeCredit - A boolean value whether to include credits in the cost budget. Defaults to true
  • includeDiscount - Whether a budget includes discounts. Defaults to true
  • includeOtherSubscription - A boolean value whether to include other subscription costs in the cost budget. Defaults to true
  • includeRecurring - A boolean value whether to include recurring costs in the cost budget. Defaults to true
  • includeRefund - A boolean value whether to include refunds in the cost budget. Defaults to true
  • includeSubscription - A boolean value whether to include subscriptions in the cost budget. Defaults to true
  • includeSupport - A boolean value whether to include support costs in the cost budget. Defaults to true
  • includeTax - A boolean value whether to include tax in the cost budget. Defaults to true
  • includeUpfront - A boolean value whether to include upfront costs in the cost budget. Defaults to true
  • useAmortized - Whether a budget uses the amortized rate. Defaults to false
  • useBlended - A boolean value whether to use blended costs in the cost budget. Defaults to false

Refer to AWS CostTypes documentation for further detail.

Cost Filter

Based on your choice of budget type, you can choose one or more of the available budget filters.

  • purchaseType
  • usageTypeGroup
  • service
  • operation
  • usageType
  • billingEntity
  • costCategory
  • linkedAccount
  • tagKeyValue
  • legalEntityName
  • invoicingEntity
  • az
  • region
  • instanceType

Refer to AWS CostFilter documentation for further detail.

Cost Filters

Note: Attribute costFilters is deprecated. Use costFilter instead.

Valid key for costFilters is same as costFilter. Please refer to Cost Filter.

Budget Notification

Valid keys for notification parameter.

  • comparisonOperator - (Required) Comparison operator to use to evaluate the condition. Can be LESS_THAN, EQUAL_TO or GREATER_THAN.
  • threshold - (Required) Threshold when the notification should be sent.
  • thresholdType - (Required) What kind of threshold is defined. Can be percentage OR ABSOLUTE_VALUE.
  • notificationType - (Required) What kind of budget value to notify on. Can be actual or forecasted
  • subscriberEmailAddresses - (Optional) E-Mail addresses to notify. Either this or subscriberSnsTopicArns is required.
  • subscriberSnsTopicArns - (Optional) SNS topics to notify. Either this or subscriberEmailAddresses is required.

Planned Budget Limits

Valid keys for plannedLimit parameter.

  • startTime - (Required) The start time of the budget limit. Format: 2017-01-01_12:00. See PlannedBudgetLimits documentation.
  • amount - (Required) The amount of cost or usage being measured for a budget.
  • unit - (Required) The unit of measurement used for the budget forecast, actual spend, or budget threshold, such as dollars or GB. See Spend documentation.

Import

Budgets can be imported using accountId:budgetName, e.g.,

$TerraformImportAwsBudgetsBudgetMyBudget123456789012:myBudget