Manage GCP Backend Bucket IAM Policies

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

These resources reference an existing backend bucket by name and project. The examples are intentionally small. Combine them with your own backend bucket infrastructure and IAM principals.

Replace the entire IAM policy with a new definition

When you need complete control over who can access a backend bucket, BackendBucketIamPolicy replaces the entire IAM policy in one operation.

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 comes from the getIAMPolicy data source, which constructs a complete policy document from role-member bindings. This approach is useful when migrating access controls or establishing a new security baseline, but it cannot be used alongside BackendBucketIamBinding or BackendBucketIamMember (they will conflict).

Grant a role to multiple members at once

Teams often need to grant the same role to several users or service accounts simultaneously.

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 that role while preserving other roles in the policy. The members array can include users, service accounts, groups, or domains. You can use multiple BackendBucketIamBinding resources for different roles, but only one per role.

Add a single member to a role incrementally

When onboarding individual users or service accounts, BackendBucketIamMember grants access without affecting existing members.

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 modifying other members for that role. This is the safest option when multiple teams manage access independently. You can combine BackendBucketIamMember resources with BackendBucketIamBinding resources as long as they don’t grant the same role.

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 control. They’re intentionally minimal rather than full access control configurations.

The examples reference pre-existing infrastructure such as the backend bucket (by name and project). 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 (conditions)
  • Custom IAM roles
  • Audit logging configuration
  • Cross-project or organization-level policies

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 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
Can I use BackendBucketIamPolicy with BackendBucketIamBinding or BackendBucketIamMember?
No, BackendBucketIamPolicy cannot be used with BackendBucketIamBinding or BackendBucketIamMember because they will conflict over the policy. Use either BackendBucketIamPolicy alone (authoritative) or use BackendBucketIamBinding/BackendBucketIamMember together.
Can I use BackendBucketIamBinding and BackendBucketIamMember together?
Yes, but only if they manage different roles. If both resources grant privileges to the same role, they will conflict.
Which IAM resource should I use for BackendBucket permissions?

Choose based on your needs:

  • BackendBucketIamPolicy - Authoritative control of the entire IAM policy (replaces existing policy)
  • BackendBucketIamBinding - Authoritative for a specific role (manages all members for that role, preserves other roles)
  • BackendBucketIamMember - Non-authoritative (adds individual members without affecting existing members)
Configuration & Setup
What provider do I need to use this resource?
This resource is in beta and requires the terraform-provider-google-beta provider.
How do I import a BackendBucket IAM resource with a custom role?
Use the full custom role name: projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.

Using a different cloud?

Explore security guides for other cloud providers: