Manage GCP Backend Bucket IAM Policies

The gcp:compute/backendBucketIamPolicy:BackendBucketIamPolicy resource, part of the Pulumi GCP provider, manages IAM permissions for Compute Engine backend buckets at three levels: complete policy replacement, role-level member lists, or individual member grants. This guide focuses on three capabilities: complete policy replacement (BackendBucketIamPolicy), role-level member management (BackendBucketIamBinding), and individual member grants (BackendBucketIamMember).

These three resources reference an existing backend bucket and have strict compatibility rules. BackendBucketIamPolicy cannot be used with BackendBucketIamBinding or BackendBucketIamMember because they conflict over policy ownership. BackendBucketIamBinding and BackendBucketIamMember can coexist only when managing different roles. The examples are intentionally small. Combine them with your own backend bucket infrastructure and access requirements.

Replace the entire IAM policy with a new definition

When you need complete control over who can access a backend bucket, you can define the entire IAM policy from scratch.

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

const admin = gcp.organizations.getIAMPolicy({
    bindings: [{
        role: "roles/viewer",
        members: ["user:jane@example.com"],
    }],
});
const policy = new gcp.compute.BackendBucketIamPolicy("policy", {
    project: imageBackend.project,
    name: imageBackend.name,
    policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp

admin = gcp.organizations.get_iam_policy(bindings=[{
    "role": "roles/viewer",
    "members": ["user:jane@example.com"],
}])
policy = gcp.compute.BackendBucketIamPolicy("policy",
    project=image_backend["project"],
    name=image_backend["name"],
    policy_data=admin.policy_data)
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"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/viewer",
					Members: []string{
						"user:jane@example.com",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = compute.NewBackendBucketIamPolicy(ctx, "policy", &compute.BackendBucketIamPolicyArgs{
			Project:    pulumi.Any(imageBackend.Project),
			Name:       pulumi.Any(imageBackend.Name),
			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/viewer",
                Members = new[]
                {
                    "user:jane@example.com",
                },
            },
        },
    });

    var policy = new Gcp.Compute.BackendBucketIamPolicy("policy", new()
    {
        Project = imageBackend.Project,
        Name = imageBackend.Name,
        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.compute.BackendBucketIamPolicy;
import com.pulumi.gcp.compute.BackendBucketIamPolicyArgs;
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/viewer")
                .members("user:jane@example.com")
                .build())
            .build());

        var policy = new BackendBucketIamPolicy("policy", BackendBucketIamPolicyArgs.builder()
            .project(imageBackend.project())
            .name(imageBackend.name())
            .policyData(admin.policyData())
            .build());

    }
}
resources:
  policy:
    type: gcp:compute:BackendBucketIamPolicy
    properties:
      project: ${imageBackend.project}
      name: ${imageBackend.name}
      policyData: ${admin.policyData}
variables:
  admin:
    fn::invoke:
      function: gcp:organizations:getIAMPolicy
      arguments:
        bindings:
          - role: roles/viewer
            members:
              - user:jane@example.com

BackendBucketIamPolicy is authoritative: it replaces any existing policy on the backend bucket. The policyData property accepts output from getIAMPolicy, which defines bindings (role-to-members mappings). This approach gives you full control but removes any permissions not explicitly listed.

Grant a role to multiple members at once

Teams often need to assign the same role to several users or service accounts without affecting other role assignments.

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

const binding = new gcp.compute.BackendBucketIamBinding("binding", {
    project: imageBackend.project,
    name: imageBackend.name,
    role: "roles/viewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.compute.BackendBucketIamBinding("binding",
    project=image_backend["project"],
    name=image_backend["name"],
    role="roles/viewer",
    members=["user:jane@example.com"])
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewBackendBucketIamBinding(ctx, "binding", &compute.BackendBucketIamBindingArgs{
			Project: pulumi.Any(imageBackend.Project),
			Name:    pulumi.Any(imageBackend.Name),
			Role:    pulumi.String("roles/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 binding = new Gcp.Compute.BackendBucketIamBinding("binding", new()
    {
        Project = imageBackend.Project,
        Name = imageBackend.Name,
        Role = "roles/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.compute.BackendBucketIamBinding;
import com.pulumi.gcp.compute.BackendBucketIamBindingArgs;
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 binding = new BackendBucketIamBinding("binding", BackendBucketIamBindingArgs.builder()
            .project(imageBackend.project())
            .name(imageBackend.name())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:compute:BackendBucketIamBinding
    properties:
      project: ${imageBackend.project}
      name: ${imageBackend.name}
      role: roles/viewer
      members:
        - user:jane@example.com

BackendBucketIamBinding is authoritative for a single role. It sets the complete member list for roles/viewer while preserving other roles on the backend bucket. The members array lists all identities that should have this role; any members not listed will lose access.

Add a single member to a role incrementally

When granting access to individual users or service accounts, you can add them one at a time without managing the complete member list.

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

const member = new gcp.compute.BackendBucketIamMember("member", {
    project: imageBackend.project,
    name: imageBackend.name,
    role: "roles/viewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.compute.BackendBucketIamMember("member",
    project=image_backend["project"],
    name=image_backend["name"],
    role="roles/viewer",
    member="user:jane@example.com")
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewBackendBucketIamMember(ctx, "member", &compute.BackendBucketIamMemberArgs{
			Project: pulumi.Any(imageBackend.Project),
			Name:    pulumi.Any(imageBackend.Name),
			Role:    pulumi.String("roles/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 member = new Gcp.Compute.BackendBucketIamMember("member", new()
    {
        Project = imageBackend.Project,
        Name = imageBackend.Name,
        Role = "roles/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.compute.BackendBucketIamMember;
import com.pulumi.gcp.compute.BackendBucketIamMemberArgs;
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 member = new BackendBucketIamMember("member", BackendBucketIamMemberArgs.builder()
            .project(imageBackend.project())
            .name(imageBackend.name())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:compute:BackendBucketIamMember
    properties:
      project: ${imageBackend.project}
      name: ${imageBackend.name}
      role: roles/viewer
      member: user:jane@example.com

BackendBucketIamMember is non-authoritative: it adds one member to a role without affecting existing members. Use this when you want to grant access incrementally or when multiple teams manage access to the same backend bucket. The member property specifies a single identity (user, service account, or group).

Beyond these examples

These snippets focus on specific IAM management approaches: authoritative vs non-authoritative IAM management, and policy-level, role-level, and member-level control. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as a backend bucket (imageBackend) with project and name. They focus on IAM binding configuration rather than provisioning the backend bucket itself.

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

  • Conditional IAM bindings (condition blocks)
  • Service account impersonation
  • Custom role definitions
  • IAM policy retrieval (data source usage)

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

Let's manage GCP Backend Bucket 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 BackendBucketIamPolicy, BackendBucketIamBinding, and BackendBucketIamMember?
BackendBucketIamPolicy is authoritative and replaces the entire IAM policy. BackendBucketIamBinding is authoritative for a specific role but preserves other roles. BackendBucketIamMember is non-authoritative and adds a single member while preserving other members for that role.
Why can't I use BackendBucketIamPolicy with BackendBucketIamBinding or BackendBucketIamMember?
These resources conflict because they manage IAM policies differently. BackendBucketIamPolicy authoritatively sets the entire policy, while BackendBucketIamBinding and BackendBucketIamMember make incremental changes. Using them together causes the resources to fight over the policy state.
Can I use BackendBucketIamBinding and BackendBucketIamMember together?
Yes, but only if they don’t grant privileges to the same role. Each role must be managed by only one resource type to avoid conflicts.
Configuration & Setup
How do I generate the policyData for BackendBucketIamPolicy?
Use the gcp.organizations.getIAMPolicy data source to generate policy data, then pass it to the policyData property as shown in the examples.
What properties can't I change after creating the resource?
Both name and project are immutable. You’ll need to recreate the resource if you need to change either of these properties.
Advanced Topics
How do I import a resource with a custom IAM role?
Use the full name of the custom role in the format [projects/my-project|organizations/my-org]/roles/my-custom-role when importing.

Using a different cloud?

Explore security guides for other cloud providers: