The gcp:gkehub/scopeIamBinding:ScopeIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for GKE Hub scopes. It controls which identities can access scope resources by granting roles to lists of members. This guide focuses on two capabilities: granting roles to multiple members and adding individual members to roles.
IAM bindings reference existing GKE Hub scopes and grant access to Google Cloud identities. The examples are intentionally small. Combine them with your own scope resources and identity management strategy.
Grant a role to multiple members
When managing GKE Hub scopes, you often need to grant the same role to multiple users, service accounts, or groups at once.
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 various identity formats including user emails, service accounts, groups, and special identifiers like allAuthenticatedUsers. The scopeId and project properties identify which scope receives the binding.
Add a single member to a role
To grant access to one additional user without affecting other members of the role, use ScopeIamMember.
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
Unlike ScopeIamBinding, ScopeIamMember is non-authoritative: it adds one member to a role without replacing existing grants. The member property takes a single identity string. You can use multiple ScopeIamMember resources to incrementally build up role membership, or combine them with ScopeIamBinding resources as long as they target different roles.
Beyond these examples
These snippets focus on specific IAM binding features: role-based access control and member management (binding vs member). They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as GKE Hub scopes and Google Cloud projects. They focus on configuring IAM bindings rather than provisioning the underlying scope resources.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Full policy management (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 but preserves other roles in the policy. gcp.gkehub.ScopeIamMember is non-authoritative and preserves other members for the same role.gcp.gkehub.ScopeIamPolicy cannot be used with gcp.gkehub.ScopeIamBinding or gcp.gkehub.ScopeIamMember because they will conflict over the policy configuration.IAM Configuration
The members property supports multiple formats:
allUsersandallAuthenticatedUsersfor public/authenticated accessuser:{email},serviceAccount:{email},group:{email}for specific identitiesdomain:{domain}for G Suite domainsprojectOwner:,projectEditor:,projectViewer:with project ID- Federated identities using
principal://format
[projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.Resource Properties
role, scopeId, and project properties are immutable and cannot be changed after resource creation.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.