@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
415 lines (414 loc) • 14.1 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
import * as outputs from "../types/output";
/**
* Budget configuration for a billing account.
*
* To get more information about Budget, see:
*
* * [API documentation](https://cloud.google.com/billing/docs/reference/budget/rest/v1/billingAccounts.budgets)
* * How-to Guides
* * [Creating a budget](https://cloud.google.com/billing/docs/how-to/budgets)
*
* > **Warning:** If you are using User ADCs (Application Default Credentials) with this resource,
* you must specify a `billingProject` and set `userProjectOverride` to true
* in the provider configuration. Otherwise the Billing Budgets API will return a 403 error.
* Your account must have the `serviceusage.services.use` permission on the
* `billingProject` you defined.
*
* ## Example Usage
*
* ### Billing Budget Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const account = gcp.organizations.getBillingAccount({
* billingAccount: "000000-0000000-0000000-000000",
* });
* const budget = new gcp.billing.Budget("budget", {
* billingAccount: account.then(account => account.id),
* displayName: "Example Billing Budget",
* amount: {
* specifiedAmount: {
* currencyCode: "USD",
* units: "100000",
* },
* },
* thresholdRules: [{
* thresholdPercent: 0.5,
* }],
* });
* ```
* ### Billing Budget Lastperiod
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const account = gcp.organizations.getBillingAccount({
* billingAccount: "000000-0000000-0000000-000000",
* });
* const project = gcp.organizations.getProject({});
* const budget = new gcp.billing.Budget("budget", {
* billingAccount: account.then(account => account.id),
* displayName: "Example Billing Budget",
* budgetFilter: {
* projects: [project.then(project => `projects/${project.number}`)],
* },
* amount: {
* lastPeriodAmount: true,
* },
* thresholdRules: [{
* thresholdPercent: 10,
* }],
* });
* ```
* ### Billing Budget Filter
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const account = gcp.organizations.getBillingAccount({
* billingAccount: "000000-0000000-0000000-000000",
* });
* const project = gcp.organizations.getProject({});
* const budget = new gcp.billing.Budget("budget", {
* billingAccount: account.then(account => account.id),
* displayName: "Example Billing Budget",
* budgetFilter: {
* projects: [project.then(project => `projects/${project.number}`)],
* creditTypesTreatment: "INCLUDE_SPECIFIED_CREDITS",
* services: ["services/24E6-581D-38E5"],
* creditTypes: [
* "PROMOTION",
* "FREE_TIER",
* ],
* resourceAncestors: ["organizations/123456789"],
* },
* amount: {
* specifiedAmount: {
* currencyCode: "USD",
* units: "100000",
* },
* },
* thresholdRules: [
* {
* thresholdPercent: 0.5,
* },
* {
* thresholdPercent: 0.9,
* spendBasis: "FORECASTED_SPEND",
* },
* ],
* });
* ```
* ### Billing Budget Notify
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const account = gcp.organizations.getBillingAccount({
* billingAccount: "000000-0000000-0000000-000000",
* });
* const project = gcp.organizations.getProject({});
* const notificationChannel = new gcp.monitoring.NotificationChannel("notification_channel", {
* displayName: "Example Notification Channel",
* type: "email",
* labels: {
* email_address: "address@example.com",
* },
* });
* const budget = new gcp.billing.Budget("budget", {
* billingAccount: account.then(account => account.id),
* displayName: "Example Billing Budget",
* budgetFilter: {
* projects: [project.then(project => `projects/${project.number}`)],
* },
* amount: {
* specifiedAmount: {
* currencyCode: "USD",
* units: "100000",
* },
* },
* thresholdRules: [
* {
* thresholdPercent: 1,
* },
* {
* thresholdPercent: 1,
* spendBasis: "FORECASTED_SPEND",
* },
* ],
* allUpdatesRule: {
* monitoringNotificationChannels: [notificationChannel.id],
* disableDefaultIamRecipients: true,
* },
* });
* ```
* ### Billing Budget Notify Project Recipient
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const account = gcp.organizations.getBillingAccount({
* billingAccount: "000000-0000000-0000000-000000",
* });
* const project = gcp.organizations.getProject({});
* const budget = new gcp.billing.Budget("budget", {
* billingAccount: account.then(account => account.id),
* displayName: "Example Billing Budget",
* budgetFilter: {
* projects: [project.then(project => `projects/${project.number}`)],
* },
* amount: {
* specifiedAmount: {
* currencyCode: "USD",
* units: "100000",
* },
* },
* allUpdatesRule: {
* monitoringNotificationChannels: [],
* enableProjectLevelRecipients: true,
* },
* });
* ```
* ### Billing Budget Customperiod
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const account = gcp.organizations.getBillingAccount({
* billingAccount: "000000-0000000-0000000-000000",
* });
* const project = gcp.organizations.getProject({});
* const budget = new gcp.billing.Budget("budget", {
* billingAccount: account.then(account => account.id),
* displayName: "Example Billing Budget",
* budgetFilter: {
* projects: [project.then(project => `projects/${project.number}`)],
* creditTypesTreatment: "EXCLUDE_ALL_CREDITS",
* services: ["services/24E6-581D-38E5"],
* customPeriod: {
* startDate: {
* year: 2022,
* month: 1,
* day: 1,
* },
* endDate: {
* year: 2023,
* month: 12,
* day: 31,
* },
* },
* },
* amount: {
* specifiedAmount: {
* currencyCode: "USD",
* units: "100000",
* },
* },
* thresholdRules: [
* {
* thresholdPercent: 0.5,
* },
* {
* thresholdPercent: 0.9,
* },
* ],
* });
* ```
*
* ## Import
*
* Budget can be imported using any of these accepted formats:
*
* * `billingAccounts/{{billing_account}}/budgets/{{name}}`
*
* * `{{billing_account}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, Budget can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:billing/budget:Budget default billingAccounts/{{billing_account}}/budgets/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:billing/budget:Budget default {{billing_account}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:billing/budget:Budget default {{name}}
* ```
*/
export declare class Budget extends pulumi.CustomResource {
/**
* Get an existing Budget resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: BudgetState, opts?: pulumi.CustomResourceOptions): Budget;
/**
* Returns true if the given object is an instance of Budget. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is Budget;
/**
* Defines notifications that are sent on every update to the
* billing account's spend, regardless of the thresholds defined
* using threshold rules.
* Structure is documented below.
*/
readonly allUpdatesRule: pulumi.Output<outputs.billing.BudgetAllUpdatesRule | undefined>;
/**
* The budgeted amount for each usage period.
* Structure is documented below.
*/
readonly amount: pulumi.Output<outputs.billing.BudgetAmount>;
/**
* ID of the billing account to set a budget on.
*/
readonly billingAccount: pulumi.Output<string>;
/**
* Filters that define which resources are used to compute the actual
* spend against the budget.
* Structure is documented below.
*/
readonly budgetFilter: pulumi.Output<outputs.billing.BudgetBudgetFilter>;
/**
* User data for display name in UI. Must be <= 60 chars.
*/
readonly displayName: pulumi.Output<string | undefined>;
/**
* Resource name of the budget. The resource name
* implies the scope of a budget. Values are of the form
* billingAccounts/{billingAccountId}/budgets/{budgetId}.
*/
readonly name: pulumi.Output<string>;
/**
* The ownership scope of the budget. The ownership scope and users'
* IAM permissions determine who has full access to the budget's data.
* Possible values are: `OWNERSHIP_SCOPE_UNSPECIFIED`, `ALL_USERS`, `BILLING_ACCOUNT`.
*/
readonly ownershipScope: pulumi.Output<string | undefined>;
/**
* Rules that trigger alerts (notifications of thresholds being
* crossed) when spend exceeds the specified percentages of the
* budget.
* Structure is documented below.
*/
readonly thresholdRules: pulumi.Output<outputs.billing.BudgetThresholdRule[] | undefined>;
/**
* Create a Budget resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: BudgetArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Budget resources.
*/
export interface BudgetState {
/**
* Defines notifications that are sent on every update to the
* billing account's spend, regardless of the thresholds defined
* using threshold rules.
* Structure is documented below.
*/
allUpdatesRule?: pulumi.Input<inputs.billing.BudgetAllUpdatesRule>;
/**
* The budgeted amount for each usage period.
* Structure is documented below.
*/
amount?: pulumi.Input<inputs.billing.BudgetAmount>;
/**
* ID of the billing account to set a budget on.
*/
billingAccount?: pulumi.Input<string>;
/**
* Filters that define which resources are used to compute the actual
* spend against the budget.
* Structure is documented below.
*/
budgetFilter?: pulumi.Input<inputs.billing.BudgetBudgetFilter>;
/**
* User data for display name in UI. Must be <= 60 chars.
*/
displayName?: pulumi.Input<string>;
/**
* Resource name of the budget. The resource name
* implies the scope of a budget. Values are of the form
* billingAccounts/{billingAccountId}/budgets/{budgetId}.
*/
name?: pulumi.Input<string>;
/**
* The ownership scope of the budget. The ownership scope and users'
* IAM permissions determine who has full access to the budget's data.
* Possible values are: `OWNERSHIP_SCOPE_UNSPECIFIED`, `ALL_USERS`, `BILLING_ACCOUNT`.
*/
ownershipScope?: pulumi.Input<string>;
/**
* Rules that trigger alerts (notifications of thresholds being
* crossed) when spend exceeds the specified percentages of the
* budget.
* Structure is documented below.
*/
thresholdRules?: pulumi.Input<pulumi.Input<inputs.billing.BudgetThresholdRule>[]>;
}
/**
* The set of arguments for constructing a Budget resource.
*/
export interface BudgetArgs {
/**
* Defines notifications that are sent on every update to the
* billing account's spend, regardless of the thresholds defined
* using threshold rules.
* Structure is documented below.
*/
allUpdatesRule?: pulumi.Input<inputs.billing.BudgetAllUpdatesRule>;
/**
* The budgeted amount for each usage period.
* Structure is documented below.
*/
amount: pulumi.Input<inputs.billing.BudgetAmount>;
/**
* ID of the billing account to set a budget on.
*/
billingAccount: pulumi.Input<string>;
/**
* Filters that define which resources are used to compute the actual
* spend against the budget.
* Structure is documented below.
*/
budgetFilter?: pulumi.Input<inputs.billing.BudgetBudgetFilter>;
/**
* User data for display name in UI. Must be <= 60 chars.
*/
displayName?: pulumi.Input<string>;
/**
* The ownership scope of the budget. The ownership scope and users'
* IAM permissions determine who has full access to the budget's data.
* Possible values are: `OWNERSHIP_SCOPE_UNSPECIFIED`, `ALL_USERS`, `BILLING_ACCOUNT`.
*/
ownershipScope?: pulumi.Input<string>;
/**
* Rules that trigger alerts (notifications of thresholds being
* crossed) when spend exceeds the specified percentages of the
* budget.
* Structure is documented below.
*/
thresholdRules?: pulumi.Input<pulumi.Input<inputs.billing.BudgetThresholdRule>[]>;
}