1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. organizations
  5. getBillingAccount
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

gcp.organizations.getBillingAccount

Explore with Pulumi AI

gcp logo
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

    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 System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var acct = Gcp.Organizations.GetBillingAccount.Invoke(new()
        {
            DisplayName = "My Billing Account",
            Open = true,
        });
    
        var myProject = new Gcp.Organizations.Project("myProject", new()
        {
            ProjectId = "your-project-id",
            OrgId = "1234567",
            BillingAccount = acct.Apply(getBillingAccountResult => getBillingAccountResult.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 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.Project;
    import com.pulumi.gcp.organizations.ProjectArgs;
    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 acct = 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.applyValue(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,
                            lookup_projects: Optional[bool] = 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,
                            lookup_projects: Optional[pulumi.Input[bool]] = 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.

    LookupProjects bool

    true if projects associated with the billing account should be read, false if this step should be skipped. Setting false may be useful if the user permissions do not allow listing projects. Defaults to true.

    NOTE: One of billing_account or display_name must be specified.

    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.

    LookupProjects bool

    true if projects associated with the billing account should be read, false if this step should be skipped. Setting false may be useful if the user permissions do not allow listing projects. Defaults to true.

    NOTE: One of billing_account or display_name must be specified.

    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.

    lookupProjects Boolean

    true if projects associated with the billing account should be read, false if this step should be skipped. Setting false may be useful if the user permissions do not allow listing projects. Defaults to true.

    NOTE: One of billing_account or display_name must be specified.

    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.

    lookupProjects boolean

    true if projects associated with the billing account should be read, false if this step should be skipped. Setting false may be useful if the user permissions do not allow listing projects. Defaults to true.

    NOTE: One of billing_account or display_name must be specified.

    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.

    lookup_projects bool

    true if projects associated with the billing account should be read, false if this step should be skipped. Setting false may be useful if the user permissions do not allow listing projects. Defaults to true.

    NOTE: One of billing_account or display_name must be specified.

    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.

    lookupProjects Boolean

    true if projects associated with the billing account should be read, false if this step should be skipped. Setting false may be useful if the user permissions do not allow listing projects. Defaults to true.

    NOTE: One of billing_account or display_name must be specified.

    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. lookup_projects must not be false for this to be populated.

    BillingAccount string
    LookupProjects bool
    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. lookup_projects must not be false for this to be populated.

    BillingAccount string
    LookupProjects bool
    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. lookup_projects must not be false for this to be populated.

    billingAccount String
    lookupProjects Boolean
    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. lookup_projects must not be false for this to be populated.

    billingAccount string
    lookupProjects boolean
    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. lookup_projects must not be false for this to be populated.

    billing_account str
    lookup_projects bool
    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. lookup_projects must not be false for this to be populated.

    billingAccount String
    lookupProjects Boolean

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes

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

    gcp logo
    Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi