@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
316 lines • 11 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Budget = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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}}
* ```
*/
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, id, state, opts) {
return new Budget(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Budget.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["allUpdatesRule"] = state ? state.allUpdatesRule : undefined;
resourceInputs["amount"] = state ? state.amount : undefined;
resourceInputs["billingAccount"] = state ? state.billingAccount : undefined;
resourceInputs["budgetFilter"] = state ? state.budgetFilter : undefined;
resourceInputs["displayName"] = state ? state.displayName : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["ownershipScope"] = state ? state.ownershipScope : undefined;
resourceInputs["thresholdRules"] = state ? state.thresholdRules : undefined;
}
else {
const args = argsOrState;
if ((!args || args.amount === undefined) && !opts.urn) {
throw new Error("Missing required property 'amount'");
}
if ((!args || args.billingAccount === undefined) && !opts.urn) {
throw new Error("Missing required property 'billingAccount'");
}
resourceInputs["allUpdatesRule"] = args ? args.allUpdatesRule : undefined;
resourceInputs["amount"] = args ? args.amount : undefined;
resourceInputs["billingAccount"] = args ? args.billingAccount : undefined;
resourceInputs["budgetFilter"] = args ? args.budgetFilter : undefined;
resourceInputs["displayName"] = args ? args.displayName : undefined;
resourceInputs["ownershipScope"] = args ? args.ownershipScope : undefined;
resourceInputs["thresholdRules"] = args ? args.thresholdRules : undefined;
resourceInputs["name"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Budget.__pulumiType, name, resourceInputs, opts);
}
}
exports.Budget = Budget;
/** @internal */
Budget.__pulumiType = 'gcp:billing/budget:Budget';
//# sourceMappingURL=budget.js.map