The gcp:billing/accountIamBinding:AccountIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for GCP billing accounts by granting a specific role to a list of members. This guide focuses on two capabilities: granting roles to multiple members and adding individual members non-authoritatively.
IAM bindings reference existing billing accounts and grant access to user accounts, service accounts, or groups. The examples are intentionally small. Combine them with your own billing account IDs and identity management.
Grant a role to multiple members
Teams managing billing access typically grant the same role to multiple users, service accounts, or groups as a unit.
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 billingAccountId identifies which billing account to configure. The role property specifies which permission set to grant (e.g., roles/billing.viewer for read-only access). The members array lists all identities that receive this role; AccountIamBinding is authoritative for this role, meaning it replaces any existing members for billing.viewer.
Add a single member to a role
When you need to grant access to one additional user without affecting other members, use AccountIamMember to add a single identity 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 (singular) specifies one identity to add to the role. Unlike AccountIamBinding, this resource doesn’t replace existing members; it adds to them. You can use multiple AccountIamMember resources for the same role without conflict, as long as each grants to a different member.
Beyond these examples
These snippets focus on specific billing IAM features: role-based access control and member identity formats. They’re intentionally minimal rather than full access management solutions.
The examples reference pre-existing infrastructure such as GCP billing accounts and user accounts, service accounts, or groups to grant access to. They focus on configuring IAM bindings rather than provisioning billing accounts or identities.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Full policy replacement (AccountIamPolicy)
- Custom role definitions
- Multiple role grants in a single resource
These omissions are intentional: the goal is to illustrate how each IAM binding approach is wired, not provide drop-in access control modules. See the Billing Account IAM Binding resource reference for all available configuration options.
Let's manage GCP Billing Account IAM Bindings
Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.
Try Pulumi Cloud for FREEFrequently Asked Questions
Resource Selection & Conflicts
AccountIamPolicy is authoritative and replaces the entire IAM policy. AccountIamBinding is authoritative for a specific role, preserving other roles in the policy. AccountIamMember is non-authoritative, adding a single member to a role without affecting other members.AccountIamPolicy cannot be used with AccountIamBinding or AccountIamMember because they’ll conflict over policy state. Additionally, AccountIamPolicy replaces the entire policy, which can accidentally remove billing account ownership if not carefully configured.Configuration & Roles
[projects|organizations]/{parent-name}/roles/{role-name}.billingAccountId, role, and condition properties are immutable and cannot be changed after resource creation.Member Identity Formats
You can use four formats:
user:{emailid}for specific Google accounts (e.g.,alice@gmail.com)serviceAccount:{emailid}for service accounts (e.g.,my-app@appspot.gserviceaccount.com)group:{emailid}for Google groups (e.g.,admins@example.com)domain:{domain}for all users in a G Suite domain (e.g.,example.com)