Manage GCP Billing Account IAM Policies

The gcp:billing/accountIamPolicy:AccountIamPolicy resource, part of the Pulumi GCP provider, manages IAM policies on billing accounts. Three related resources serve different use cases: AccountIamPolicy replaces entire policies, AccountIamBinding manages all members for a role, and AccountIamMember adds individual members. This guide focuses on three capabilities: role-based member grants, single-member additions, and complete policy replacement.

These resources reference existing billing accounts and cannot be used together without conflicts. AccountIamPolicy is authoritative and replaces the entire policy, potentially unsetting ownership if administrators aren’t included. AccountIamBinding and AccountIamMember can coexist if they manage different roles. The examples are intentionally small. Choose the resource that matches your access control model.

Grant a role to multiple members

When you need to grant the same role to multiple users or service accounts, AccountIamBinding manages all members for that role together.

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

const editor = new gcp.billing.AccountIamBinding("editor", {
    billingAccountId: "00AA00-000AAA-00AA0A",
    role: "roles/billing.viewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

editor = gcp.billing.AccountIamBinding("editor",
    billing_account_id="00AA00-000AAA-00AA0A",
    role="roles/billing.viewer",
    members=["user:jane@example.com"])
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/billing"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := billing.NewAccountIamBinding(ctx, "editor", &billing.AccountIamBindingArgs{
			BillingAccountId: pulumi.String("00AA00-000AAA-00AA0A"),
			Role:             pulumi.String("roles/billing.viewer"),
			Members: pulumi.StringArray{
				pulumi.String("user:jane@example.com"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var editor = new Gcp.Billing.AccountIamBinding("editor", new()
    {
        BillingAccountId = "00AA00-000AAA-00AA0A",
        Role = "roles/billing.viewer",
        Members = new[]
        {
            "user:jane@example.com",
        },
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.billing.AccountIamBinding;
import com.pulumi.gcp.billing.AccountIamBindingArgs;
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) {
        var editor = new AccountIamBinding("editor", AccountIamBindingArgs.builder()
            .billingAccountId("00AA00-000AAA-00AA0A")
            .role("roles/billing.viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  editor:
    type: gcp:billing:AccountIamBinding
    properties:
      billingAccountId: 00AA00-000AAA-00AA0A
      role: roles/billing.viewer
      members:
        - user:jane@example.com

The members property lists all identities that receive the role. AccountIamBinding is authoritative for this role: it replaces any existing members for billing.viewer but preserves other roles in the policy. The billingAccountId identifies which billing account to configure.

Add a single member to a role

To grant access to one user without affecting other members of the role, AccountIamMember adds a single member non-authoritatively.

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

const editor = new gcp.billing.AccountIamMember("editor", {
    billingAccountId: "00AA00-000AAA-00AA0A",
    role: "roles/billing.viewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

editor = gcp.billing.AccountIamMember("editor",
    billing_account_id="00AA00-000AAA-00AA0A",
    role="roles/billing.viewer",
    member="user:jane@example.com")
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/billing"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := billing.NewAccountIamMember(ctx, "editor", &billing.AccountIamMemberArgs{
			BillingAccountId: pulumi.String("00AA00-000AAA-00AA0A"),
			Role:             pulumi.String("roles/billing.viewer"),
			Member:           pulumi.String("user:jane@example.com"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var editor = new Gcp.Billing.AccountIamMember("editor", new()
    {
        BillingAccountId = "00AA00-000AAA-00AA0A",
        Role = "roles/billing.viewer",
        Member = "user:jane@example.com",
    });

});
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.billing.AccountIamMember;
import com.pulumi.gcp.billing.AccountIamMemberArgs;
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) {
        var editor = new AccountIamMember("editor", AccountIamMemberArgs.builder()
            .billingAccountId("00AA00-000AAA-00AA0A")
            .role("roles/billing.viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  editor:
    type: gcp:billing:AccountIamMember
    properties:
      billingAccountId: 00AA00-000AAA-00AA0A
      role: roles/billing.viewer
      member: user:jane@example.com

The member property specifies one identity to add. Unlike AccountIamBinding, this resource doesn’t replace existing members for the role. Multiple AccountIamMember resources can grant the same role to different users without conflicts.

Replace the entire IAM policy

Some organizations manage billing access through centralized policy definitions that must be applied atomically.

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

const admin = gcp.organizations.getIAMPolicy({
    bindings: [{
        role: "roles/billing.viewer",
        members: ["user:jane@example.com"],
    }],
});
const editor = new gcp.billing.AccountIamPolicy("editor", {
    billingAccountId: "00AA00-000AAA-00AA0A",
    policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp

admin = gcp.organizations.get_iam_policy(bindings=[{
    "role": "roles/billing.viewer",
    "members": ["user:jane@example.com"],
}])
editor = gcp.billing.AccountIamPolicy("editor",
    billing_account_id="00AA00-000AAA-00AA0A",
    policy_data=admin.policy_data)
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		admin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
			Bindings: []organizations.GetIAMPolicyBinding{
				{
					Role: "roles/billing.viewer",
					Members: []string{
						"user:jane@example.com",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = billing.NewAccountIamPolicy(ctx, "editor", &billing.AccountIamPolicyArgs{
			BillingAccountId: pulumi.String("00AA00-000AAA-00AA0A"),
			PolicyData:       pulumi.String(admin.PolicyData),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var admin = Gcp.Organizations.GetIAMPolicy.Invoke(new()
    {
        Bindings = new[]
        {
            new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
            {
                Role = "roles/billing.viewer",
                Members = new[]
                {
                    "user:jane@example.com",
                },
            },
        },
    });

    var editor = new Gcp.Billing.AccountIamPolicy("editor", new()
    {
        BillingAccountId = "00AA00-000AAA-00AA0A",
        PolicyData = admin.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
    });

});
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.GetIAMPolicyArgs;
import com.pulumi.gcp.billing.AccountIamPolicy;
import com.pulumi.gcp.billing.AccountIamPolicyArgs;
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 admin = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
            .bindings(GetIAMPolicyBindingArgs.builder()
                .role("roles/billing.viewer")
                .members("user:jane@example.com")
                .build())
            .build());

        var editor = new AccountIamPolicy("editor", AccountIamPolicyArgs.builder()
            .billingAccountId("00AA00-000AAA-00AA0A")
            .policyData(admin.policyData())
            .build());

    }
}
resources:
  editor:
    type: gcp:billing:AccountIamPolicy
    properties:
      billingAccountId: 00AA00-000AAA-00AA0A
      policyData: ${admin.policyData}
variables:
  admin:
    fn::invoke:
      function: gcp:organizations:getIAMPolicy
      arguments:
        bindings:
          - role: roles/billing.viewer
            members:
              - user:jane@example.com

The policyData property accepts a complete IAM policy document from getIAMPolicy. AccountIamPolicy replaces the entire policy, removing any bindings not included in the policy data. This is useful for centralized policy management but can unset ownership if administrators aren’t included in the bindings.

Beyond these examples

These snippets focus on specific IAM management features: role-based access control, single-member and multi-member grants, and complete policy replacement. They’re intentionally minimal rather than full access control systems.

The examples reference pre-existing infrastructure such as billing accounts with valid IDs. They focus on configuring IAM policies rather than provisioning billing accounts.

To keep things focused, common IAM patterns are omitted, including:

  • Conditional IAM bindings (condition property)
  • Service account impersonation
  • Custom role definitions
  • Policy conflict resolution between resource types

These omissions are intentional: the goal is to illustrate how each IAM resource is wired, not provide drop-in access control modules. See the Billing Account IAM Policy resource reference for all available configuration options.

Let's manage GCP Billing Account IAM Policies

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Resource Selection & Conflicts
What's the difference between AccountIamPolicy, AccountIamBinding, and AccountIamMember?
AccountIamPolicy is authoritative and replaces the entire IAM policy. AccountIamBinding is authoritative for a specific role but preserves other roles. AccountIamMember is non-authoritative and preserves other members for the same role.
Can I use AccountIamPolicy with AccountIamBinding or AccountIamMember?
No, AccountIamPolicy cannot be used with AccountIamBinding or AccountIamMember because they will conflict over the policy configuration.
Can I use AccountIamBinding and AccountIamMember together?
Yes, but only if they don’t grant privileges to the same role. Using both for the same role causes conflicts.
What should I be careful about when using AccountIamPolicy?
AccountIamPolicy replaces the entire IAM policy, so you can accidentally remove existing ownership of the billing account. Review the complete policy before applying.
Configuration & Usage
How do I set up an IAM policy with AccountIamPolicy?
Use gcp.organizations.getIAMPolicy to generate policy data, then pass it to the policyData property of AccountIamPolicy.
Can I change the billing account ID after creating the resource?
No, billingAccountId is immutable and cannot be changed after creation.

Using a different cloud?

Explore security guides for other cloud providers: