The gcp:gkehub/scopeIamMember:ScopeIamMember resource, part of the Pulumi GCP provider, manages IAM permissions for GKE Hub scopes by adding individual members to roles without affecting other permissions. This guide focuses on three capabilities: single-member grants (ScopeIamMember), role-level member lists (ScopeIamBinding), and complete policy replacement (ScopeIamPolicy).
GKE Hub scope IAM resources reference existing scopes and operate on their IAM policies with different levels of authority. ScopeIamPolicy is authoritative and replaces the entire policy; ScopeIamBinding is authoritative for a single role; ScopeIamMember is non-authoritative and adds one member to one role. The examples are intentionally small. Combine them with your own scope references and member identities.
Grant a single user access to a scope
Most IAM configurations add individual users or service accounts to specific roles without disrupting existing permissions.
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:jane@example.com or serviceAccount:app@project.iam.gserviceaccount.com. The role property defines the permission level. ScopeIamMember is non-authoritative: it adds this member to the role while preserving other members and roles on the scope.
Grant a role to multiple members at once
When several users need identical permissions, ScopeIamBinding manages the complete member list for a single role.
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 all members for that role but leaves other roles unchanged. You can use ScopeIamBinding alongside ScopeIamMember as long as they target different roles.
Replace the entire IAM policy for a scope
Organizations managing IAM centrally use ScopeIamPolicy to define the complete policy document.
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 a complete IAM policy document, typically retrieved from gcp.organizations.getIAMPolicy. ScopeIamPolicy is fully authoritative: it replaces the entire IAM policy for the scope. You cannot use ScopeIamPolicy with ScopeIamBinding or ScopeIamMember; they will conflict over policy ownership.
Beyond these examples
These snippets focus on specific IAM management features: single-member grants (ScopeIamMember), role-level member lists (ScopeIamBinding), and complete policy replacement (ScopeIamPolicy). They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as GKE Hub scopes (referenced by scopeId) and GCP projects. They focus on configuring IAM permissions rather than provisioning the underlying resources.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Custom role definitions
- Service account creation
- Scope provisioning
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
gcp.gkehub.ScopeIamPolicy is authoritative and replaces the entire IAM policy. gcp.gkehub.ScopeIamBinding is authoritative for a specific role but preserves other roles. 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. Use gcp.gkehub.ScopeIamPolicy alone or use gcp.gkehub.ScopeIamBinding/gcp.gkehub.ScopeIamMember together.Configuration & Identity Formats
You can use:
allUsersorallAuthenticatedUsersfor public/authenticated accessuser:{email},serviceAccount:{email},group:{email}for specific identitiesdomain:{domain}for G Suite domainsprojectOwner:{projectid},projectEditor:{projectid},projectViewer:{projectid}for project roles- Federated identities like
principal://iam.googleapis.com/locations/global/workforcePools/...
[projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.Import & Advanced Usage
[projects/my-project|organizations/my-org]/roles/my-custom-role. Don’t use shortened role names.