@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
316 lines • 10.6 kB
JavaScript
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** 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, { ...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?.allUpdatesRule;
resourceInputs["amount"] = state?.amount;
resourceInputs["billingAccount"] = state?.billingAccount;
resourceInputs["budgetFilter"] = state?.budgetFilter;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["name"] = state?.name;
resourceInputs["ownershipScope"] = state?.ownershipScope;
resourceInputs["thresholdRules"] = state?.thresholdRules;
}
else {
const args = argsOrState;
if (args?.amount === undefined && !opts.urn) {
throw new Error("Missing required property 'amount'");
}
if (args?.billingAccount === undefined && !opts.urn) {
throw new Error("Missing required property 'billingAccount'");
}
resourceInputs["allUpdatesRule"] = args?.allUpdatesRule;
resourceInputs["amount"] = args?.amount;
resourceInputs["billingAccount"] = args?.billingAccount;
resourceInputs["budgetFilter"] = args?.budgetFilter;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["ownershipScope"] = args?.ownershipScope;
resourceInputs["thresholdRules"] = args?.thresholdRules;
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
;