The gcp:gkehub/scopeIamBinding:ScopeIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for GKE Hub scopes by granting a specific role to a list of members. This guide focuses on two capabilities: authoritative role assignment to multiple members and non-authoritative single-member additions.
GKE Hub scopes are organizational containers for Kubernetes clusters. This resource controls who can access them. The examples are intentionally small. Combine them with your own scope infrastructure and identity management.
Grant a role to multiple members
Teams managing GKE Hub scopes often need to grant the same role to multiple users or service accounts at once, such as giving viewer access to an operations team.
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 ScopeIamBinding resource is authoritative for the specified role: it replaces all members for that role with the list you provide. The members array accepts user accounts, service accounts, groups, and other identity formats. The scopeId references an existing scope, and the role determines what permissions those members receive.
Add a single member to a role
When onboarding individual users or granting access to specific service accounts, teams add members one at a time without affecting other role assignments.
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 ScopeIamMember resource is non-authoritative: it adds one member to a role without removing existing members. This is useful when multiple teams manage access independently. You can use ScopeIamMember alongside ScopeIamBinding as long as they don’t grant the same role (otherwise they’ll conflict over who should have access).
Beyond these examples
These snippets focus on specific IAM binding features: role-based access control and authoritative vs non-authoritative member management. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as GKE Hub scopes. They focus on configuring IAM bindings rather than provisioning the scopes themselves.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Full policy replacement (ScopeIamPolicy resource)
- Custom role definitions
- Federated identity configuration
These omissions are intentional: the goal is to illustrate how IAM bindings are wired, not provide drop-in access control modules. See the GKE Hub ScopeIamBinding resource reference for all available configuration options.
Let's manage GCP GKEHub Scope IAM Bindings
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
gcp.gkehub.ScopeIamPolicy is authoritative and replaces the entire IAM policy. gcp.gkehub.ScopeIamBinding is authoritative for a specific role, managing all members for that role while preserving other roles. gcp.gkehub.ScopeIamMember is non-authoritative, adding individual members without affecting other members or roles.gcp.gkehub.ScopeIamPolicy cannot be used with gcp.gkehub.ScopeIamBinding or gcp.gkehub.ScopeIamMember because they will conflict over policy management.IAM Configuration
members property supports multiple formats: allUsers, allAuthenticatedUsers, user:{email}, serviceAccount:{email}, group:{email}, domain:{domain}, projectOwner/Editor/Viewer:{projectid}, and federated identities like principal://iam.googleapis.com/....[projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role.pulumi import gcp:gkehub/scopeIamBinding:ScopeIamBinding editor "projects/{{project}}/locations/global/scopes/{{scope_id}} roles/viewer". The resource identifier and role are space-delimited.Resource Properties
role, scopeId, project, and condition properties are immutable and cannot be changed after the resource is created.project isn’t provided, it’s parsed from the parent resource identifier. If no project is found there, the provider’s default project is used.