Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.billing.kotlin.Budget.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.billing.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.billing.kotlin.outputs.BudgetAllUpdatesRule
import com.pulumi.gcp.billing.kotlin.outputs.BudgetAmount
import com.pulumi.gcp.billing.kotlin.outputs.BudgetBudgetFilter
import com.pulumi.gcp.billing.kotlin.outputs.BudgetThresholdRule
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.gcp.billing.kotlin.outputs.BudgetAllUpdatesRule.Companion.toKotlin as budgetAllUpdatesRuleToKotlin
import com.pulumi.gcp.billing.kotlin.outputs.BudgetAmount.Companion.toKotlin as budgetAmountToKotlin
import com.pulumi.gcp.billing.kotlin.outputs.BudgetBudgetFilter.Companion.toKotlin as budgetBudgetFilterToKotlin
import com.pulumi.gcp.billing.kotlin.outputs.BudgetThresholdRule.Companion.toKotlin as budgetThresholdRuleToKotlin
/**
* Builder for [Budget].
*/
@PulumiTagMarker
public class BudgetResourceBuilder internal constructor() {
public var name: String? = null
public var args: BudgetArgs = BudgetArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend BudgetArgsBuilder.() -> Unit) {
val builder = BudgetArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): Budget {
val builtJavaResource = com.pulumi.gcp.billing.Budget(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Budget(builtJavaResource)
}
}
/**
* 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 `billing_project` and set `user_project_override` 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
* `billing_project` 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,
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* account = gcp.organizations.get_billing_account(billing_account="000000-0000000-0000000-000000")
* budget = gcp.billing.Budget("budget",
* billing_account=account.id,
* display_name="Example Billing Budget",
* amount={
* "specified_amount": {
* "currency_code": "USD",
* "units": "100000",
* },
* },
* threshold_rules=[{
* "threshold_percent": 0.5,
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var account = Gcp.Organizations.GetBillingAccount.Invoke(new()
* {
* BillingAccount = "000000-0000000-0000000-000000",
* });
* var budget = new Gcp.Billing.Budget("budget", new()
* {
* BillingAccount = account.Apply(getBillingAccountResult => getBillingAccountResult.Id),
* DisplayName = "Example Billing Budget",
* Amount = new Gcp.Billing.Inputs.BudgetAmountArgs
* {
* SpecifiedAmount = new Gcp.Billing.Inputs.BudgetAmountSpecifiedAmountArgs
* {
* CurrencyCode = "USD",
* Units = "100000",
* },
* },
* ThresholdRules = new[]
* {
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 0.5,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/billing"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* account, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
* BillingAccount: pulumi.StringRef("000000-0000000-0000000-000000"),
* }, nil)
* if err != nil {
* return err
* }
* _, err = billing.NewBudget(ctx, "budget", &billing.BudgetArgs{
* BillingAccount: pulumi.String(account.Id),
* DisplayName: pulumi.String("Example Billing Budget"),
* Amount: &billing.BudgetAmountArgs{
* SpecifiedAmount: &billing.BudgetAmountSpecifiedAmountArgs{
* CurrencyCode: pulumi.String("USD"),
* Units: pulumi.String("100000"),
* },
* },
* ThresholdRules: billing.BudgetThresholdRuleArray{
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(0.5),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetBillingAccountArgs;
* import com.pulumi.gcp.billing.Budget;
* import com.pulumi.gcp.billing.BudgetArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountSpecifiedAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetThresholdRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* final var account = OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
* .billingAccount("000000-0000000-0000000-000000")
* .build());
* var budget = new Budget("budget", BudgetArgs.builder()
* .billingAccount(account.applyValue(getBillingAccountResult -> getBillingAccountResult.id()))
* .displayName("Example Billing Budget")
* .amount(BudgetAmountArgs.builder()
* .specifiedAmount(BudgetAmountSpecifiedAmountArgs.builder()
* .currencyCode("USD")
* .units("100000")
* .build())
* .build())
* .thresholdRules(BudgetThresholdRuleArgs.builder()
* .thresholdPercent(0.5)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* budget:
* type: gcp:billing:Budget
* properties:
* billingAccount: ${account.id}
* displayName: Example Billing Budget
* amount:
* specifiedAmount:
* currencyCode: USD
* units: '100000'
* thresholdRules:
* - thresholdPercent: 0.5
* variables:
* account:
* fn::invoke:
* Function: gcp:organizations:getBillingAccount
* Arguments:
* billingAccount: 000000-0000000-0000000-000000
* ```
*
* ### 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,
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* account = gcp.organizations.get_billing_account(billing_account="000000-0000000-0000000-000000")
* project = gcp.organizations.get_project()
* budget = gcp.billing.Budget("budget",
* billing_account=account.id,
* display_name="Example Billing Budget",
* budget_filter={
* "projects": [f"projects/{project.number}"],
* },
* amount={
* "last_period_amount": True,
* },
* threshold_rules=[{
* "threshold_percent": 10,
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var account = Gcp.Organizations.GetBillingAccount.Invoke(new()
* {
* BillingAccount = "000000-0000000-0000000-000000",
* });
* var project = Gcp.Organizations.GetProject.Invoke();
* var budget = new Gcp.Billing.Budget("budget", new()
* {
* BillingAccount = account.Apply(getBillingAccountResult => getBillingAccountResult.Id),
* DisplayName = "Example Billing Budget",
* BudgetFilter = new Gcp.Billing.Inputs.BudgetBudgetFilterArgs
* {
* Projects = new[]
* {
* $"projects/{project.Apply(getProjectResult => getProjectResult.Number)}",
* },
* },
* Amount = new Gcp.Billing.Inputs.BudgetAmountArgs
* {
* LastPeriodAmount = true,
* },
* ThresholdRules = new[]
* {
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 10,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/billing"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* account, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
* BillingAccount: pulumi.StringRef("000000-0000000-0000000-000000"),
* }, nil)
* if err != nil {
* return err
* }
* project, err := organizations.LookupProject(ctx, nil, nil)
* if err != nil {
* return err
* }
* _, err = billing.NewBudget(ctx, "budget", &billing.BudgetArgs{
* BillingAccount: pulumi.String(account.Id),
* DisplayName: pulumi.String("Example Billing Budget"),
* BudgetFilter: &billing.BudgetBudgetFilterArgs{
* Projects: pulumi.StringArray{
* pulumi.Sprintf("projects/%v", project.Number),
* },
* },
* Amount: &billing.BudgetAmountArgs{
* LastPeriodAmount: pulumi.Bool(true),
* },
* ThresholdRules: billing.BudgetThresholdRuleArray{
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(10),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetBillingAccountArgs;
* import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
* import com.pulumi.gcp.billing.Budget;
* import com.pulumi.gcp.billing.BudgetArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetThresholdRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* final var account = OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
* .billingAccount("000000-0000000-0000000-000000")
* .build());
* final var project = OrganizationsFunctions.getProject();
* var budget = new Budget("budget", BudgetArgs.builder()
* .billingAccount(account.applyValue(getBillingAccountResult -> getBillingAccountResult.id()))
* .displayName("Example Billing Budget")
* .budgetFilter(BudgetBudgetFilterArgs.builder()
* .projects(String.format("projects/%s", project.applyValue(getProjectResult -> getProjectResult.number())))
* .build())
* .amount(BudgetAmountArgs.builder()
* .lastPeriodAmount(true)
* .build())
* .thresholdRules(BudgetThresholdRuleArgs.builder()
* .thresholdPercent(10)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* budget:
* type: gcp:billing:Budget
* properties:
* billingAccount: ${account.id}
* displayName: Example Billing Budget
* budgetFilter:
* projects:
* - projects/${project.number}
* amount:
* lastPeriodAmount: true
* thresholdRules:
* - thresholdPercent: 10
* variables:
* account:
* fn::invoke:
* Function: gcp:organizations:getBillingAccount
* Arguments:
* billingAccount: 000000-0000000-0000000-000000
* project:
* fn::invoke:
* Function: gcp:organizations:getProject
* Arguments: {}
* ```
*
* ### 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",
* },
* ],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* account = gcp.organizations.get_billing_account(billing_account="000000-0000000-0000000-000000")
* project = gcp.organizations.get_project()
* budget = gcp.billing.Budget("budget",
* billing_account=account.id,
* display_name="Example Billing Budget",
* budget_filter={
* "projects": [f"projects/{project.number}"],
* "credit_types_treatment": "INCLUDE_SPECIFIED_CREDITS",
* "services": ["services/24E6-581D-38E5"],
* "credit_types": [
* "PROMOTION",
* "FREE_TIER",
* ],
* "resource_ancestors": ["organizations/123456789"],
* },
* amount={
* "specified_amount": {
* "currency_code": "USD",
* "units": "100000",
* },
* },
* threshold_rules=[
* {
* "threshold_percent": 0.5,
* },
* {
* "threshold_percent": 0.9,
* "spend_basis": "FORECASTED_SPEND",
* },
* ])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var account = Gcp.Organizations.GetBillingAccount.Invoke(new()
* {
* BillingAccount = "000000-0000000-0000000-000000",
* });
* var project = Gcp.Organizations.GetProject.Invoke();
* var budget = new Gcp.Billing.Budget("budget", new()
* {
* BillingAccount = account.Apply(getBillingAccountResult => getBillingAccountResult.Id),
* DisplayName = "Example Billing Budget",
* BudgetFilter = new Gcp.Billing.Inputs.BudgetBudgetFilterArgs
* {
* Projects = new[]
* {
* $"projects/{project.Apply(getProjectResult => getProjectResult.Number)}",
* },
* CreditTypesTreatment = "INCLUDE_SPECIFIED_CREDITS",
* Services = new[]
* {
* "services/24E6-581D-38E5",
* },
* CreditTypes = new[]
* {
* "PROMOTION",
* "FREE_TIER",
* },
* ResourceAncestors = new[]
* {
* "organizations/123456789",
* },
* },
* Amount = new Gcp.Billing.Inputs.BudgetAmountArgs
* {
* SpecifiedAmount = new Gcp.Billing.Inputs.BudgetAmountSpecifiedAmountArgs
* {
* CurrencyCode = "USD",
* Units = "100000",
* },
* },
* ThresholdRules = new[]
* {
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 0.5,
* },
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 0.9,
* SpendBasis = "FORECASTED_SPEND",
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/billing"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* account, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
* BillingAccount: pulumi.StringRef("000000-0000000-0000000-000000"),
* }, nil)
* if err != nil {
* return err
* }
* project, err := organizations.LookupProject(ctx, nil, nil)
* if err != nil {
* return err
* }
* _, err = billing.NewBudget(ctx, "budget", &billing.BudgetArgs{
* BillingAccount: pulumi.String(account.Id),
* DisplayName: pulumi.String("Example Billing Budget"),
* BudgetFilter: &billing.BudgetBudgetFilterArgs{
* Projects: pulumi.StringArray{
* pulumi.Sprintf("projects/%v", project.Number),
* },
* CreditTypesTreatment: pulumi.String("INCLUDE_SPECIFIED_CREDITS"),
* Services: pulumi.StringArray{
* pulumi.String("services/24E6-581D-38E5"),
* },
* CreditTypes: pulumi.StringArray{
* pulumi.String("PROMOTION"),
* pulumi.String("FREE_TIER"),
* },
* ResourceAncestors: pulumi.StringArray{
* pulumi.String("organizations/123456789"),
* },
* },
* Amount: &billing.BudgetAmountArgs{
* SpecifiedAmount: &billing.BudgetAmountSpecifiedAmountArgs{
* CurrencyCode: pulumi.String("USD"),
* Units: pulumi.String("100000"),
* },
* },
* ThresholdRules: billing.BudgetThresholdRuleArray{
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(0.5),
* },
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(0.9),
* SpendBasis: pulumi.String("FORECASTED_SPEND"),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetBillingAccountArgs;
* import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
* import com.pulumi.gcp.billing.Budget;
* import com.pulumi.gcp.billing.BudgetArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountSpecifiedAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetThresholdRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* final var account = OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
* .billingAccount("000000-0000000-0000000-000000")
* .build());
* final var project = OrganizationsFunctions.getProject();
* var budget = new Budget("budget", BudgetArgs.builder()
* .billingAccount(account.applyValue(getBillingAccountResult -> getBillingAccountResult.id()))
* .displayName("Example Billing Budget")
* .budgetFilter(BudgetBudgetFilterArgs.builder()
* .projects(String.format("projects/%s", project.applyValue(getProjectResult -> getProjectResult.number())))
* .creditTypesTreatment("INCLUDE_SPECIFIED_CREDITS")
* .services("services/24E6-581D-38E5")
* .creditTypes(
* "PROMOTION",
* "FREE_TIER")
* .resourceAncestors("organizations/123456789")
* .build())
* .amount(BudgetAmountArgs.builder()
* .specifiedAmount(BudgetAmountSpecifiedAmountArgs.builder()
* .currencyCode("USD")
* .units("100000")
* .build())
* .build())
* .thresholdRules(
* BudgetThresholdRuleArgs.builder()
* .thresholdPercent(0.5)
* .build(),
* BudgetThresholdRuleArgs.builder()
* .thresholdPercent(0.9)
* .spendBasis("FORECASTED_SPEND")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* budget:
* type: gcp:billing:Budget
* properties:
* billingAccount: ${account.id}
* displayName: Example Billing Budget
* budgetFilter:
* projects:
* - 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
* variables:
* account:
* fn::invoke:
* Function: gcp:organizations:getBillingAccount
* Arguments:
* billingAccount: 000000-0000000-0000000-000000
* project:
* fn::invoke:
* Function: gcp:organizations:getProject
* Arguments: {}
* ```
*
* ### 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: "[email protected] ",
* },
* });
* 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,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* account = gcp.organizations.get_billing_account(billing_account="000000-0000000-0000000-000000")
* project = gcp.organizations.get_project()
* notification_channel = gcp.monitoring.NotificationChannel("notification_channel",
* display_name="Example Notification Channel",
* type="email",
* labels={
* "email_address": "[email protected] ",
* })
* budget = gcp.billing.Budget("budget",
* billing_account=account.id,
* display_name="Example Billing Budget",
* budget_filter={
* "projects": [f"projects/{project.number}"],
* },
* amount={
* "specified_amount": {
* "currency_code": "USD",
* "units": "100000",
* },
* },
* threshold_rules=[
* {
* "threshold_percent": 1,
* },
* {
* "threshold_percent": 1,
* "spend_basis": "FORECASTED_SPEND",
* },
* ],
* all_updates_rule={
* "monitoring_notification_channels": [notification_channel.id],
* "disable_default_iam_recipients": True,
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var account = Gcp.Organizations.GetBillingAccount.Invoke(new()
* {
* BillingAccount = "000000-0000000-0000000-000000",
* });
* var project = Gcp.Organizations.GetProject.Invoke();
* var notificationChannel = new Gcp.Monitoring.NotificationChannel("notification_channel", new()
* {
* DisplayName = "Example Notification Channel",
* Type = "email",
* Labels =
* {
* { "email_address", "[email protected] " },
* },
* });
* var budget = new Gcp.Billing.Budget("budget", new()
* {
* BillingAccount = account.Apply(getBillingAccountResult => getBillingAccountResult.Id),
* DisplayName = "Example Billing Budget",
* BudgetFilter = new Gcp.Billing.Inputs.BudgetBudgetFilterArgs
* {
* Projects = new[]
* {
* $"projects/{project.Apply(getProjectResult => getProjectResult.Number)}",
* },
* },
* Amount = new Gcp.Billing.Inputs.BudgetAmountArgs
* {
* SpecifiedAmount = new Gcp.Billing.Inputs.BudgetAmountSpecifiedAmountArgs
* {
* CurrencyCode = "USD",
* Units = "100000",
* },
* },
* ThresholdRules = new[]
* {
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 1,
* },
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 1,
* SpendBasis = "FORECASTED_SPEND",
* },
* },
* AllUpdatesRule = new Gcp.Billing.Inputs.BudgetAllUpdatesRuleArgs
* {
* MonitoringNotificationChannels = new[]
* {
* notificationChannel.Id,
* },
* DisableDefaultIamRecipients = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/billing"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/monitoring"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* account, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
* BillingAccount: pulumi.StringRef("000000-0000000-0000000-000000"),
* }, nil)
* if err != nil {
* return err
* }
* project, err := organizations.LookupProject(ctx, nil, nil)
* if err != nil {
* return err
* }
* notificationChannel, err := monitoring.NewNotificationChannel(ctx, "notification_channel", &monitoring.NotificationChannelArgs{
* DisplayName: pulumi.String("Example Notification Channel"),
* Type: pulumi.String("email"),
* Labels: pulumi.StringMap{
* "email_address": pulumi.String("[email protected] "),
* },
* })
* if err != nil {
* return err
* }
* _, err = billing.NewBudget(ctx, "budget", &billing.BudgetArgs{
* BillingAccount: pulumi.String(account.Id),
* DisplayName: pulumi.String("Example Billing Budget"),
* BudgetFilter: &billing.BudgetBudgetFilterArgs{
* Projects: pulumi.StringArray{
* pulumi.Sprintf("projects/%v", project.Number),
* },
* },
* Amount: &billing.BudgetAmountArgs{
* SpecifiedAmount: &billing.BudgetAmountSpecifiedAmountArgs{
* CurrencyCode: pulumi.String("USD"),
* Units: pulumi.String("100000"),
* },
* },
* ThresholdRules: billing.BudgetThresholdRuleArray{
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(1),
* },
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(1),
* SpendBasis: pulumi.String("FORECASTED_SPEND"),
* },
* },
* AllUpdatesRule: &billing.BudgetAllUpdatesRuleArgs{
* MonitoringNotificationChannels: pulumi.StringArray{
* notificationChannel.ID(),
* },
* DisableDefaultIamRecipients: pulumi.Bool(true),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetBillingAccountArgs;
* import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
* import com.pulumi.gcp.monitoring.NotificationChannel;
* import com.pulumi.gcp.monitoring.NotificationChannelArgs;
* import com.pulumi.gcp.billing.Budget;
* import com.pulumi.gcp.billing.BudgetArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountSpecifiedAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetThresholdRuleArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAllUpdatesRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* final var account = OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
* .billingAccount("000000-0000000-0000000-000000")
* .build());
* final var project = OrganizationsFunctions.getProject();
* var notificationChannel = new NotificationChannel("notificationChannel", NotificationChannelArgs.builder()
* .displayName("Example Notification Channel")
* .type("email")
* .labels(Map.of("email_address", "[email protected] "))
* .build());
* var budget = new Budget("budget", BudgetArgs.builder()
* .billingAccount(account.applyValue(getBillingAccountResult -> getBillingAccountResult.id()))
* .displayName("Example Billing Budget")
* .budgetFilter(BudgetBudgetFilterArgs.builder()
* .projects(String.format("projects/%s", project.applyValue(getProjectResult -> getProjectResult.number())))
* .build())
* .amount(BudgetAmountArgs.builder()
* .specifiedAmount(BudgetAmountSpecifiedAmountArgs.builder()
* .currencyCode("USD")
* .units("100000")
* .build())
* .build())
* .thresholdRules(
* BudgetThresholdRuleArgs.builder()
* .thresholdPercent(1)
* .build(),
* BudgetThresholdRuleArgs.builder()
* .thresholdPercent(1)
* .spendBasis("FORECASTED_SPEND")
* .build())
* .allUpdatesRule(BudgetAllUpdatesRuleArgs.builder()
* .monitoringNotificationChannels(notificationChannel.id())
* .disableDefaultIamRecipients(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* budget:
* type: gcp:billing:Budget
* properties:
* billingAccount: ${account.id}
* displayName: Example Billing Budget
* budgetFilter:
* projects:
* - projects/${project.number}
* amount:
* specifiedAmount:
* currencyCode: USD
* units: '100000'
* thresholdRules:
* - thresholdPercent: 1
* - thresholdPercent: 1
* spendBasis: FORECASTED_SPEND
* allUpdatesRule:
* monitoringNotificationChannels:
* - ${notificationChannel.id}
* disableDefaultIamRecipients: true
* notificationChannel:
* type: gcp:monitoring:NotificationChannel
* name: notification_channel
* properties:
* displayName: Example Notification Channel
* type: email
* labels:
* email_address: [email protected]
* variables:
* account:
* fn::invoke:
* Function: gcp:organizations:getBillingAccount
* Arguments:
* billingAccount: 000000-0000000-0000000-000000
* project:
* fn::invoke:
* Function: gcp:organizations:getProject
* Arguments: {}
* ```
*
* ### 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,
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* account = gcp.organizations.get_billing_account(billing_account="000000-0000000-0000000-000000")
* project = gcp.organizations.get_project()
* budget = gcp.billing.Budget("budget",
* billing_account=account.id,
* display_name="Example Billing Budget",
* budget_filter={
* "projects": [f"projects/{project.number}"],
* },
* amount={
* "specified_amount": {
* "currency_code": "USD",
* "units": "100000",
* },
* },
* all_updates_rule={
* "monitoring_notification_channels": [],
* "enable_project_level_recipients": True,
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var account = Gcp.Organizations.GetBillingAccount.Invoke(new()
* {
* BillingAccount = "000000-0000000-0000000-000000",
* });
* var project = Gcp.Organizations.GetProject.Invoke();
* var budget = new Gcp.Billing.Budget("budget", new()
* {
* BillingAccount = account.Apply(getBillingAccountResult => getBillingAccountResult.Id),
* DisplayName = "Example Billing Budget",
* BudgetFilter = new Gcp.Billing.Inputs.BudgetBudgetFilterArgs
* {
* Projects = new[]
* {
* $"projects/{project.Apply(getProjectResult => getProjectResult.Number)}",
* },
* },
* Amount = new Gcp.Billing.Inputs.BudgetAmountArgs
* {
* SpecifiedAmount = new Gcp.Billing.Inputs.BudgetAmountSpecifiedAmountArgs
* {
* CurrencyCode = "USD",
* Units = "100000",
* },
* },
* AllUpdatesRule = new Gcp.Billing.Inputs.BudgetAllUpdatesRuleArgs
* {
* MonitoringNotificationChannels = new() { },
* EnableProjectLevelRecipients = true,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/billing"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* account, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
* BillingAccount: pulumi.StringRef("000000-0000000-0000000-000000"),
* }, nil)
* if err != nil {
* return err
* }
* project, err := organizations.LookupProject(ctx, nil, nil)
* if err != nil {
* return err
* }
* _, err = billing.NewBudget(ctx, "budget", &billing.BudgetArgs{
* BillingAccount: pulumi.String(account.Id),
* DisplayName: pulumi.String("Example Billing Budget"),
* BudgetFilter: &billing.BudgetBudgetFilterArgs{
* Projects: pulumi.StringArray{
* pulumi.Sprintf("projects/%v", project.Number),
* },
* },
* Amount: &billing.BudgetAmountArgs{
* SpecifiedAmount: &billing.BudgetAmountSpecifiedAmountArgs{
* CurrencyCode: pulumi.String("USD"),
* Units: pulumi.String("100000"),
* },
* },
* AllUpdatesRule: &billing.BudgetAllUpdatesRuleArgs{
* MonitoringNotificationChannels: pulumi.StringArray{},
* EnableProjectLevelRecipients: pulumi.Bool(true),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetBillingAccountArgs;
* import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
* import com.pulumi.gcp.billing.Budget;
* import com.pulumi.gcp.billing.BudgetArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountSpecifiedAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAllUpdatesRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* final var account = OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
* .billingAccount("000000-0000000-0000000-000000")
* .build());
* final var project = OrganizationsFunctions.getProject();
* var budget = new Budget("budget", BudgetArgs.builder()
* .billingAccount(account.applyValue(getBillingAccountResult -> getBillingAccountResult.id()))
* .displayName("Example Billing Budget")
* .budgetFilter(BudgetBudgetFilterArgs.builder()
* .projects(String.format("projects/%s", project.applyValue(getProjectResult -> getProjectResult.number())))
* .build())
* .amount(BudgetAmountArgs.builder()
* .specifiedAmount(BudgetAmountSpecifiedAmountArgs.builder()
* .currencyCode("USD")
* .units("100000")
* .build())
* .build())
* .allUpdatesRule(BudgetAllUpdatesRuleArgs.builder()
* .monitoringNotificationChannels()
* .enableProjectLevelRecipients(true)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* budget:
* type: gcp:billing:Budget
* properties:
* billingAccount: ${account.id}
* displayName: Example Billing Budget
* budgetFilter:
* projects:
* - projects/${project.number}
* amount:
* specifiedAmount:
* currencyCode: USD
* units: '100000'
* allUpdatesRule:
* monitoringNotificationChannels: []
* enableProjectLevelRecipients: true
* variables:
* account:
* fn::invoke:
* Function: gcp:organizations:getBillingAccount
* Arguments:
* billingAccount: 000000-0000000-0000000-000000
* project:
* fn::invoke:
* Function: gcp:organizations:getProject
* Arguments: {}
* ```
*
* ### 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,
* },
* ],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* account = gcp.organizations.get_billing_account(billing_account="000000-0000000-0000000-000000")
* project = gcp.organizations.get_project()
* budget = gcp.billing.Budget("budget",
* billing_account=account.id,
* display_name="Example Billing Budget",
* budget_filter={
* "projects": [f"projects/{project.number}"],
* "credit_types_treatment": "EXCLUDE_ALL_CREDITS",
* "services": ["services/24E6-581D-38E5"],
* "custom_period": {
* "start_date": {
* "year": 2022,
* "month": 1,
* "day": 1,
* },
* "end_date": {
* "year": 2023,
* "month": 12,
* "day": 31,
* },
* },
* },
* amount={
* "specified_amount": {
* "currency_code": "USD",
* "units": "100000",
* },
* },
* threshold_rules=[
* {
* "threshold_percent": 0.5,
* },
* {
* "threshold_percent": 0.9,
* },
* ])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var account = Gcp.Organizations.GetBillingAccount.Invoke(new()
* {
* BillingAccount = "000000-0000000-0000000-000000",
* });
* var project = Gcp.Organizations.GetProject.Invoke();
* var budget = new Gcp.Billing.Budget("budget", new()
* {
* BillingAccount = account.Apply(getBillingAccountResult => getBillingAccountResult.Id),
* DisplayName = "Example Billing Budget",
* BudgetFilter = new Gcp.Billing.Inputs.BudgetBudgetFilterArgs
* {
* Projects = new[]
* {
* $"projects/{project.Apply(getProjectResult => getProjectResult.Number)}",
* },
* CreditTypesTreatment = "EXCLUDE_ALL_CREDITS",
* Services = new[]
* {
* "services/24E6-581D-38E5",
* },
* CustomPeriod = new Gcp.Billing.Inputs.BudgetBudgetFilterCustomPeriodArgs
* {
* StartDate = new Gcp.Billing.Inputs.BudgetBudgetFilterCustomPeriodStartDateArgs
* {
* Year = 2022,
* Month = 1,
* Day = 1,
* },
* EndDate = new Gcp.Billing.Inputs.BudgetBudgetFilterCustomPeriodEndDateArgs
* {
* Year = 2023,
* Month = 12,
* Day = 31,
* },
* },
* },
* Amount = new Gcp.Billing.Inputs.BudgetAmountArgs
* {
* SpecifiedAmount = new Gcp.Billing.Inputs.BudgetAmountSpecifiedAmountArgs
* {
* CurrencyCode = "USD",
* Units = "100000",
* },
* },
* ThresholdRules = new[]
* {
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 0.5,
* },
* new Gcp.Billing.Inputs.BudgetThresholdRuleArgs
* {
* ThresholdPercent = 0.9,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/billing"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* account, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
* BillingAccount: pulumi.StringRef("000000-0000000-0000000-000000"),
* }, nil)
* if err != nil {
* return err
* }
* project, err := organizations.LookupProject(ctx, nil, nil)
* if err != nil {
* return err
* }
* _, err = billing.NewBudget(ctx, "budget", &billing.BudgetArgs{
* BillingAccount: pulumi.String(account.Id),
* DisplayName: pulumi.String("Example Billing Budget"),
* BudgetFilter: &billing.BudgetBudgetFilterArgs{
* Projects: pulumi.StringArray{
* pulumi.Sprintf("projects/%v", project.Number),
* },
* CreditTypesTreatment: pulumi.String("EXCLUDE_ALL_CREDITS"),
* Services: pulumi.StringArray{
* pulumi.String("services/24E6-581D-38E5"),
* },
* CustomPeriod: &billing.BudgetBudgetFilterCustomPeriodArgs{
* StartDate: &billing.BudgetBudgetFilterCustomPeriodStartDateArgs{
* Year: pulumi.Int(2022),
* Month: pulumi.Int(1),
* Day: pulumi.Int(1),
* },
* EndDate: &billing.BudgetBudgetFilterCustomPeriodEndDateArgs{
* Year: pulumi.Int(2023),
* Month: pulumi.Int(12),
* Day: pulumi.Int(31),
* },
* },
* },
* Amount: &billing.BudgetAmountArgs{
* SpecifiedAmount: &billing.BudgetAmountSpecifiedAmountArgs{
* CurrencyCode: pulumi.String("USD"),
* Units: pulumi.String("100000"),
* },
* },
* ThresholdRules: billing.BudgetThresholdRuleArray{
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(0.5),
* },
* &billing.BudgetThresholdRuleArgs{
* ThresholdPercent: pulumi.Float64(0.9),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.organizations.OrganizationsFunctions;
* import com.pulumi.gcp.organizations.inputs.GetBillingAccountArgs;
* import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
* import com.pulumi.gcp.billing.Budget;
* import com.pulumi.gcp.billing.BudgetArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterCustomPeriodArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterCustomPeriodStartDateArgs;
* import com.pulumi.gcp.billing.inputs.BudgetBudgetFilterCustomPeriodEndDateArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetAmountSpecifiedAmountArgs;
* import com.pulumi.gcp.billing.inputs.BudgetThresholdRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* final var account = OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
* .billingAccount("000000-0000000-0000000-000000")
* .build());
* final var project = OrganizationsFunctions.getProject();
* var budget = new Budget("budget", BudgetArgs.builder()
* .billingAccount(account.applyValue(getBillingAccountResult -> getBillingAccountResult.id()))
* .displayName("Example Billing Budget")
* .budgetFilter(BudgetBudgetFilterArgs.builder()
* .projects(String.format("projects/%s", project.applyValue(getProjectResult -> getProjectResult.number())))
* .creditTypesTreatment("EXCLUDE_ALL_CREDITS")
* .services("services/24E6-581D-38E5")
* .customPeriod(BudgetBudgetFilterCustomPeriodArgs.builder()
* .startDate(BudgetBudgetFilterCustomPeriodStartDateArgs.builder()
* .year(2022)
* .month(1)
* .day(1)
* .build())
* .endDate(BudgetBudgetFilterCustomPeriodEndDateArgs.builder()
* .year(2023)
* .month(12)
* .day(31)
* .build())
* .build())
* .build())
* .amount(BudgetAmountArgs.builder()
* .specifiedAmount(BudgetAmountSpecifiedAmountArgs.builder()
* .currencyCode("USD")
* .units("100000")
* .build())
* .build())
* .thresholdRules(
* BudgetThresholdRuleArgs.builder()
* .thresholdPercent(0.5)
* .build(),
* BudgetThresholdRuleArgs.builder()
* .thresholdPercent(0.9)
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* budget:
* type: gcp:billing:Budget
* properties:
* billingAccount: ${account.id}
* displayName: Example Billing Budget
* budgetFilter:
* projects:
* - 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
* variables:
* account:
* fn::invoke:
* Function: gcp:organizations:getBillingAccount
* Arguments:
* billingAccount: 000000-0000000-0000000-000000
* project:
* fn::invoke:
* Function: gcp:organizations:getProject
* Arguments: {}
* ```
*
* ## 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}}
* ```
*/
public class Budget internal constructor(
override val javaResource: com.pulumi.gcp.billing.Budget,
) : KotlinCustomResource(javaResource, BudgetMapper) {
/**
* Defines notifications that are sent on every update to the billing account's spend, regardless of the thresholds defined
* using threshold rules.
*/
public val allUpdatesRule: Output?
get() = javaResource.allUpdatesRule().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> budgetAllUpdatesRuleToKotlin(args0) })
}).orElse(null)
})
/**
* The budgeted amount for each usage period.
* Structure is documented below.
*/
public val amount: Output
get() = javaResource.amount().applyValue({ args0 ->
args0.let({ args0 ->
budgetAmountToKotlin(args0)
})
})
/**
* ID of the billing account to set a budget on.
*/
public val billingAccount: Output
get() = javaResource.billingAccount().applyValue({ args0 -> args0 })
/**
* Filters that define which resources are used to compute the actual spend against the budget.
*/
public val budgetFilter: Output
get() = javaResource.budgetFilter().applyValue({ args0 ->
args0.let({ args0 ->
budgetBudgetFilterToKotlin(args0)
})
})
/**
* User data for display name in UI. Must be <= 60 chars.
*/
public val displayName: Output?
get() = javaResource.displayName().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Resource name of the budget. The resource name
* implies the scope of a budget. Values are of the form
* billingAccounts/{billingAccountId}/budgets/{budgetId}.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* 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: ["OWNERSHIP_SCOPE_UNSPECIFIED", "ALL_USERS", "BILLING_ACCOUNT"]
*/
public val ownershipScope: Output?
get() = javaResource.ownershipScope().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Rules that trigger alerts (notifications of thresholds being crossed) when spend exceeds the specified percentages of
* the budget.
*/
public val thresholdRules: Output>?
get() = javaResource.thresholdRules().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
budgetThresholdRuleToKotlin(args0)
})
})
}).orElse(null)
})
}
public object BudgetMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.billing.Budget::class == javaResource::class
override fun map(javaResource: Resource): Budget = Budget(
javaResource as
com.pulumi.gcp.billing.Budget,
)
}
/**
* @see [Budget].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Budget].
*/
public suspend fun budget(name: String, block: suspend BudgetResourceBuilder.() -> Unit): Budget {
val builder = BudgetResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Budget].
* @param name The _unique_ name of the resulting resource.
*/
public fun budget(name: String): Budget {
val builder = BudgetResourceBuilder()
builder.name(name)
return builder.build()
}