Manage GCP GKEHub Scope IAM Policies

The gcp:gkehub/scopeIamPolicy:ScopeIamPolicy resource, part of the Pulumi GCP provider, manages IAM policies for GKE Hub scopes. GKE Hub scopes organize clusters and workloads; IAM policies control who can view, manage, or operate those resources. This guide focuses on three approaches: authoritative policy replacement, role-level binding management, and individual member grants.

These resources reference an existing GKE Hub scope by scopeId and project. The examples are intentionally small. Combine them with your own scope infrastructure and identity management.

Replace the entire IAM policy for a scope

When you need complete control over all IAM bindings, set the entire policy at once using ScopeIamPolicy.

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.gkehub.ScopeIamPolicy("policy", {
    project: scope.project,
    scopeId: scope.scopeId,
    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.gkehub.ScopeIamPolicy("policy",
    project=scope["project"],
    scope_id=scope["scopeId"],
    policy_data=admin.policy_data)
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/gkehub"
	"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 = gkehub.NewScopeIamPolicy(ctx, "policy", &gkehub.ScopeIamPolicyArgs{
			Project:    pulumi.Any(scope.Project),
			ScopeId:    pulumi.Any(scope.ScopeId),
			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.GkeHub.ScopeIamPolicy("policy", new()
    {
        Project = scope.Project,
        ScopeId = scope.ScopeId,
        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.gkehub.ScopeIamPolicy;
import com.pulumi.gcp.gkehub.ScopeIamPolicyArgs;
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 ScopeIamPolicy("policy", ScopeIamPolicyArgs.builder()
            .project(scope.project())
            .scopeId(scope.scopeId())
            .policyData(admin.policyData())
            .build());

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

The getIAMPolicy data source constructs a policy document from bindings. The ScopeIamPolicy resource applies that policy to the scope, replacing any existing bindings. This is authoritative: any role not declared in the policy is removed. Use this when you want to define all access in one place.

Grant a role to multiple members

When multiple users or service accounts need the same role, bind them together using ScopeIamBinding.

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

const binding = new gcp.gkehub.ScopeIamBinding("binding", {
    project: scope.project,
    scopeId: scope.scopeId,
    role: "roles/viewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.gkehub.ScopeIamBinding("binding",
    project=scope["project"],
    scope_id=scope["scopeId"],
    role="roles/viewer",
    members=["user:jane@example.com"])
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := gkehub.NewScopeIamBinding(ctx, "binding", &gkehub.ScopeIamBindingArgs{
			Project: pulumi.Any(scope.Project),
			ScopeId: pulumi.Any(scope.ScopeId),
			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.GkeHub.ScopeIamBinding("binding", new()
    {
        Project = scope.Project,
        ScopeId = scope.ScopeId,
        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.gkehub.ScopeIamBinding;
import com.pulumi.gcp.gkehub.ScopeIamBindingArgs;
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 ScopeIamBinding("binding", ScopeIamBindingArgs.builder()
            .project(scope.project())
            .scopeId(scope.scopeId())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:gkehub:ScopeIamBinding
    properties:
      project: ${scope.project}
      scopeId: ${scope.scopeId}
      role: roles/viewer
      members:
        - user:jane@example.com

The members array lists all identities that receive the role. This resource is authoritative for the specified role: it replaces all members for roles/viewer but preserves other roles in the policy. ScopeIamBinding cannot be used with ScopeIamPolicy (they conflict), but it can coexist with ScopeIamMember as long as they don’t manage the same role.

Add a single member to a role

To grant access to one user without affecting others, use the non-authoritative ScopeIamMember resource.

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

const member = new gcp.gkehub.ScopeIamMember("member", {
    project: scope.project,
    scopeId: scope.scopeId,
    role: "roles/viewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.gkehub.ScopeIamMember("member",
    project=scope["project"],
    scope_id=scope["scopeId"],
    role="roles/viewer",
    member="user:jane@example.com")
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := gkehub.NewScopeIamMember(ctx, "member", &gkehub.ScopeIamMemberArgs{
			Project: pulumi.Any(scope.Project),
			ScopeId: pulumi.Any(scope.ScopeId),
			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.GkeHub.ScopeIamMember("member", new()
    {
        Project = scope.Project,
        ScopeId = scope.ScopeId,
        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.gkehub.ScopeIamMember;
import com.pulumi.gcp.gkehub.ScopeIamMemberArgs;
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 ScopeIamMember("member", ScopeIamMemberArgs.builder()
            .project(scope.project())
            .scopeId(scope.scopeId())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:gkehub:ScopeIamMember
    properties:
      project: ${scope.project}
      scopeId: ${scope.scopeId}
      role: roles/viewer
      member: user:jane@example.com

The member property specifies a single identity. This resource adds the member to the role without removing existing members. Multiple ScopeIamMember resources can manage the same role safely. Use this when you need incremental access grants or when different teams manage different members of the same role.

Beyond these examples

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

The examples reference pre-existing infrastructure such as GKE Hub scopes and GCP projects. They focus on IAM policy configuration rather than provisioning the underlying scope resources.

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

  • Conditional IAM bindings (condition blocks)
  • Custom roles (examples use predefined roles/viewer)
  • Service account impersonation
  • Audit logging configuration

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 GKE Hub Scope IAM Policy resource reference for all available configuration options.

Let's manage GCP GKEHub Scope 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 ScopeIamPolicy, ScopeIamBinding, and ScopeIamMember?
gcp.gkehub.ScopeIamPolicy is authoritative and replaces the entire IAM policy. gcp.gkehub.ScopeIamBinding is authoritative for a specific role, preserving other roles. gcp.gkehub.ScopeIamMember is non-authoritative, adding a single member while preserving other members for that role.
Can I use ScopeIamPolicy together with ScopeIamBinding or ScopeIamMember?
No, gcp.gkehub.ScopeIamPolicy cannot be used with gcp.gkehub.ScopeIamBinding or gcp.gkehub.ScopeIamMember because they will conflict over the policy configuration.
Can I use ScopeIamBinding and ScopeIamMember together?
Yes, but only if they manage different roles. Using both resources for the same role will cause conflicts.
Configuration & Setup
How do I generate the policyData for ScopeIamPolicy?
Use the gcp.organizations.getIAMPolicy data source to generate policyData, then pass it to the ScopeIamPolicy resource as shown in the examples.
What properties can't be changed after creation?
Both project and scopeId are immutable and cannot be modified after the resource is created.

Using a different cloud?

Explore security guides for other cloud providers: