The gcp:billing/accountIamPolicy:AccountIamPolicy resource, part of the Pulumi GCP provider, manages IAM policies for GCP billing accounts, controlling who can view or modify billing data and settings. This guide focuses on three capabilities: authoritative policy replacement (AccountIamPolicy), role-level grants (AccountIamBinding), and member-level grants (AccountIamMember).
These resources reference existing billing account IDs and use the getIAMPolicy data source to construct policy documents. The examples are intentionally small. Combine them with your own billing account references and organizational structure.
Replace the entire IAM policy authoritatively
When you need complete control over a billing account’s IAM policy, you can replace the entire policy in one operation, ensuring it matches exactly what you define.
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 AccountIamPolicy resource sets the complete IAM policy by consuming policyData from the getIAMPolicy data source. This approach is authoritative: any grants not explicitly listed in the policy are removed. The getIAMPolicy data source constructs the policy document from bindings that specify roles and members.
Grant a role to multiple members at once
When multiple users or service accounts need the same role, you can grant it to all of them in a single binding.
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 AccountIamBinding resource is authoritative for one specific role. The members property lists all principals who should have this role; any previous grants of this role are replaced. Other roles on the billing account remain unchanged.
Add a single member to a role incrementally
When you need to grant access to one user without affecting other members of the same role, you can add them individually.
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 AccountIamMember resource is non-authoritative. It adds one member to one role without removing other members who already have that role. This approach is useful when multiple teams manage access independently.
Beyond these examples
These snippets focus on specific IAM management features: authoritative vs non-authoritative IAM management, and policy-level, role-level, and member-level grants. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as billing account IDs. They focus on configuring IAM grants rather than provisioning billing accounts themselves.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition blocks)
- Multiple roles in a single resource
- Service account impersonation
- Custom role definitions
These omissions are intentional: the goal is to illustrate how each IAM resource type 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 FREEFrequently Asked Questions
Resource Selection & Compatibility
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 adds a single member to a role while preserving other members.AccountIamPolicy cannot be used with AccountIamBinding or AccountIamMember because they will conflict over the policy configuration.Common Pitfalls & Configuration
AccountIamPolicy replaces the entire policy, which can accidentally remove existing ownership bindings. Always include all necessary bindings, including ownership roles, in your policy.gcp.organizations.getIAMPolicy data source to generate the policyData value.billingAccountId is immutable and cannot be changed after resource creation.