Google Cloud (GCP) Classic

Pulumi Official
Package maintained by Pulumi
v6.32.0 published on Wednesday, Jul 20, 2022 by Pulumi

getBillingAccount

Use this data source to get information about a Google Billing Account.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const acct = gcp.organizations.getBillingAccount({
    displayName: "My Billing Account",
    open: true,
});
const myProject = new gcp.organizations.Project("myProject", {
    projectId: "your-project-id",
    orgId: "1234567",
    billingAccount: acct.then(acct => acct.id),
});
import pulumi
import pulumi_gcp as gcp

acct = gcp.organizations.get_billing_account(display_name="My Billing Account",
    open=True)
my_project = gcp.organizations.Project("myProject",
    project_id="your-project-id",
    org_id="1234567",
    billing_account=acct.id)
using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
    public MyStack()
    {
        var acct = Output.Create(Gcp.Organizations.GetBillingAccount.InvokeAsync(new Gcp.Organizations.GetBillingAccountArgs
        {
            DisplayName = "My Billing Account",
            Open = true,
        }));
        var myProject = new Gcp.Organizations.Project("myProject", new Gcp.Organizations.ProjectArgs
        {
            ProjectId = "your-project-id",
            OrgId = "1234567",
            BillingAccount = acct.Apply(acct => acct.Id),
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		acct, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{
			DisplayName: pulumi.StringRef("My Billing Account"),
			Open:        pulumi.BoolRef(true),
		}, nil)
		if err != nil {
			return err
		}
		_, err = organizations.NewProject(ctx, "myProject", &organizations.ProjectArgs{
			ProjectId:      pulumi.String("your-project-id"),
			OrgId:          pulumi.String("1234567"),
			BillingAccount: pulumi.String(acct.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var acct = Output.of(OrganizationsFunctions.getBillingAccount(GetBillingAccountArgs.builder()
            .displayName("My Billing Account")
            .open(true)
            .build()));

        var myProject = new Project("myProject", ProjectArgs.builder()        
            .projectId("your-project-id")
            .orgId("1234567")
            .billingAccount(acct.apply(getBillingAccountResult -> getBillingAccountResult.id()))
            .build());

    }
}
resources:
  myProject:
    type: gcp:organizations:Project
    properties:
      projectId: your-project-id
      orgId: 1234567
      billingAccount: ${acct.id}
variables:
  acct:
    Fn::Invoke:
      Function: gcp:organizations:getBillingAccount
      Arguments:
        displayName: My Billing Account
        open: true

Using getBillingAccount

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getBillingAccount(args: GetBillingAccountArgs, opts?: InvokeOptions): Promise<GetBillingAccountResult>
function getBillingAccountOutput(args: GetBillingAccountOutputArgs, opts?: InvokeOptions): Output<GetBillingAccountResult>
def get_billing_account(billing_account: Optional[str] = None,
                        display_name: Optional[str] = None,
                        open: Optional[bool] = None,
                        opts: Optional[InvokeOptions] = None) -> GetBillingAccountResult
def get_billing_account_output(billing_account: Optional[pulumi.Input[str]] = None,
                        display_name: Optional[pulumi.Input[str]] = None,
                        open: Optional[pulumi.Input[bool]] = None,
                        opts: Optional[InvokeOptions] = None) -> Output[GetBillingAccountResult]
func GetBillingAccount(ctx *Context, args *GetBillingAccountArgs, opts ...InvokeOption) (*GetBillingAccountResult, error)
func GetBillingAccountOutput(ctx *Context, args *GetBillingAccountOutputArgs, opts ...InvokeOption) GetBillingAccountResultOutput

> Note: This function is named GetBillingAccount in the Go SDK.

public static class GetBillingAccount 
{
    public static Task<GetBillingAccountResult> InvokeAsync(GetBillingAccountArgs args, InvokeOptions? opts = null)
    public static Output<GetBillingAccountResult> Invoke(GetBillingAccountInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetBillingAccountResult> getBillingAccount(GetBillingAccountArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: gcp:organizations/getBillingAccount:getBillingAccount
  Arguments:
    # Arguments dictionary

The following arguments are supported:

BillingAccount string

The name of the billing account in the form {billing_account_id} or billingAccounts/{billing_account_id}.

DisplayName string

The display name of the billing account.

Open bool

true if the billing account is open, false if the billing account is closed.

BillingAccount string

The name of the billing account in the form {billing_account_id} or billingAccounts/{billing_account_id}.

DisplayName string

The display name of the billing account.

Open bool

true if the billing account is open, false if the billing account is closed.

billingAccount String

The name of the billing account in the form {billing_account_id} or billingAccounts/{billing_account_id}.

displayName String

The display name of the billing account.

open Boolean

true if the billing account is open, false if the billing account is closed.

billingAccount string

The name of the billing account in the form {billing_account_id} or billingAccounts/{billing_account_id}.

displayName string

The display name of the billing account.

open boolean

true if the billing account is open, false if the billing account is closed.

billing_account str

The name of the billing account in the form {billing_account_id} or billingAccounts/{billing_account_id}.

display_name str

The display name of the billing account.

open bool

true if the billing account is open, false if the billing account is closed.

billingAccount String

The name of the billing account in the form {billing_account_id} or billingAccounts/{billing_account_id}.

displayName String

The display name of the billing account.

open Boolean

true if the billing account is open, false if the billing account is closed.

getBillingAccount Result

The following output properties are available:

DisplayName string
Id string

The provider-assigned unique ID for this managed resource.

Name string

The resource name of the billing account in the form billingAccounts/{billing_account_id}.

Open bool
ProjectIds List<string>

The IDs of any projects associated with the billing account.

BillingAccount string
DisplayName string
Id string

The provider-assigned unique ID for this managed resource.

Name string

The resource name of the billing account in the form billingAccounts/{billing_account_id}.

Open bool
ProjectIds []string

The IDs of any projects associated with the billing account.

BillingAccount string
displayName String
id String

The provider-assigned unique ID for this managed resource.

name String

The resource name of the billing account in the form billingAccounts/{billing_account_id}.

open Boolean
projectIds List<String>

The IDs of any projects associated with the billing account.

billingAccount String
displayName string
id string

The provider-assigned unique ID for this managed resource.

name string

The resource name of the billing account in the form billingAccounts/{billing_account_id}.

open boolean
projectIds string[]

The IDs of any projects associated with the billing account.

billingAccount string
display_name str
id str

The provider-assigned unique ID for this managed resource.

name str

The resource name of the billing account in the form billingAccounts/{billing_account_id}.

open bool
project_ids Sequence[str]

The IDs of any projects associated with the billing account.

billing_account str
displayName String
id String

The provider-assigned unique ID for this managed resource.

name String

The resource name of the billing account in the form billingAccounts/{billing_account_id}.

open Boolean
projectIds List<String>

The IDs of any projects associated with the billing account.

billingAccount String

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.