The gcp:gkehub/scopeIamMember:ScopeIamMember resource, part of the Pulumi GCP provider, manages IAM access grants for GKE Hub scopes. This guide focuses on three approaches: single-member grants with ScopeIamMember, role-level member management with ScopeIamBinding, and complete policy replacement with ScopeIamPolicy.
These three resources reference existing GKE Hub scopes and differ in how they handle existing IAM grants. ScopeIamMember is non-authoritative (preserves other members), ScopeIamBinding is authoritative for a single role (replaces members for that role), and ScopeIamPolicy is fully authoritative (replaces the entire policy). The examples are intentionally small. Combine them with your own scope references and identity management.
Grant a single user access to a scope
Most IAM configurations add individual users or service accounts to specific roles without affecting other access grants.
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 the identity to grant access, using formats like “user:email@example.com” or “serviceAccount:name@project.iam.gserviceaccount.com”. The role property defines the permission level. ScopeIamMember is non-authoritative: it adds this member to the role without removing other members or affecting other roles on the scope.
Grant a role to multiple members at once
When several identities need the same access level, ScopeIamBinding manages all members for a role as a single unit.
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 property lists all identities that should have this role. ScopeIamBinding is authoritative for the specified role: it replaces the member list for that role but preserves other roles on the scope. If you later remove a member from the list, that member loses access.
Replace the entire IAM policy for a scope
Some workflows require complete control over all IAM bindings, replacing any existing policy.
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 policyData property accepts output from getIAMPolicy, which defines all role bindings in a single structure. ScopeIamPolicy is fully authoritative: it replaces the entire IAM policy for the scope, removing any grants not defined in the policy data. This approach cannot be combined with ScopeIamBinding or ScopeIamMember, as they would conflict over policy ownership.
Beyond these examples
These snippets focus on specific IAM management patterns: single-member grants, role-level member lists, and complete policy replacement. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as GKE Hub scopes and a GCP project with appropriate permissions. They focus on IAM grant configuration rather than provisioning the underlying scope resources.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Custom role definitions
- Service account creation and management
- Scope creation and 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 ScopeIamMember resource reference for all available configuration options.
Let's manage GCP GKEHub Scope IAM Members
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
ScopeIamPolicy is authoritative and replaces the entire IAM policy. ScopeIamBinding is authoritative for a specific role, updating all members for that role while preserving other roles. ScopeIamMember is non-authoritative, adding a single member to a role without affecting other members.ScopeIamPolicy cannot be used with ScopeIamBinding or ScopeIamMember because they will conflict over the policy configuration.Identity & Role Configuration
allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner:{projectid}, projectEditor:{projectid}, projectViewer:{projectid}, or federated identities like principal://iam.googleapis.com/....[projects|organizations]/{parent-name}/roles/{role-name}, for example projects/my-project/roles/my-custom-role.Immutability & Updates
member, role, scopeId, project, condition) are immutable. Changing any of them forces resource replacement.