The gcp:artifactregistry/repositoryIamBinding:RepositoryIamBinding resource, part of the Pulumi GCP provider, grants IAM roles to lists of members for Artifact Registry repositories while preserving other roles in the repository’s policy. This guide focuses on two capabilities: granting roles to multiple members and adding individual members incrementally.
This resource references existing Artifact Registry repositories and requires valid GCP identities. The examples are intentionally small. Combine them with your own repository infrastructure and identity management.
Grant a role to multiple members at once
Teams managing repository access often need to grant the same role to multiple users or service accounts simultaneously, such as giving a development team read access.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.artifactregistry.RepositoryIamBinding("binding", {
project: my_repo.project,
location: my_repo.location,
repository: my_repo.name,
role: "roles/artifactregistry.reader",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.artifactregistry.RepositoryIamBinding("binding",
project=my_repo["project"],
location=my_repo["location"],
repository=my_repo["name"],
role="roles/artifactregistry.reader",
members=["user:jane@example.com"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/artifactregistry"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := artifactregistry.NewRepositoryIamBinding(ctx, "binding", &artifactregistry.RepositoryIamBindingArgs{
Project: pulumi.Any(my_repo.Project),
Location: pulumi.Any(my_repo.Location),
Repository: pulumi.Any(my_repo.Name),
Role: pulumi.String("roles/artifactregistry.reader"),
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.ArtifactRegistry.RepositoryIamBinding("binding", new()
{
Project = my_repo.Project,
Location = my_repo.Location,
Repository = my_repo.Name,
Role = "roles/artifactregistry.reader",
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.artifactregistry.RepositoryIamBinding;
import com.pulumi.gcp.artifactregistry.RepositoryIamBindingArgs;
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 RepositoryIamBinding("binding", RepositoryIamBindingArgs.builder()
.project(my_repo.project())
.location(my_repo.location())
.repository(my_repo.name())
.role("roles/artifactregistry.reader")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:artifactregistry:RepositoryIamBinding
properties:
project: ${["my-repo"].project}
location: ${["my-repo"].location}
repository: ${["my-repo"].name}
role: roles/artifactregistry.reader
members:
- user:jane@example.com
The role property specifies which permission set to grant (here, roles/artifactregistry.reader). The members array lists all identities that receive this role; RepositoryIamBinding is authoritative for this role, meaning it replaces any existing members. The repository, location, and project properties identify which Artifact Registry repository receives the binding.
Add a single member to a role incrementally
When onboarding individual users or service accounts, you can add them one at a time without affecting existing members.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.artifactregistry.RepositoryIamMember("member", {
project: my_repo.project,
location: my_repo.location,
repository: my_repo.name,
role: "roles/artifactregistry.reader",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.artifactregistry.RepositoryIamMember("member",
project=my_repo["project"],
location=my_repo["location"],
repository=my_repo["name"],
role="roles/artifactregistry.reader",
member="user:jane@example.com")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/artifactregistry"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := artifactregistry.NewRepositoryIamMember(ctx, "member", &artifactregistry.RepositoryIamMemberArgs{
Project: pulumi.Any(my_repo.Project),
Location: pulumi.Any(my_repo.Location),
Repository: pulumi.Any(my_repo.Name),
Role: pulumi.String("roles/artifactregistry.reader"),
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.ArtifactRegistry.RepositoryIamMember("member", new()
{
Project = my_repo.Project,
Location = my_repo.Location,
Repository = my_repo.Name,
Role = "roles/artifactregistry.reader",
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.artifactregistry.RepositoryIamMember;
import com.pulumi.gcp.artifactregistry.RepositoryIamMemberArgs;
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 RepositoryIamMember("member", RepositoryIamMemberArgs.builder()
.project(my_repo.project())
.location(my_repo.location())
.repository(my_repo.name())
.role("roles/artifactregistry.reader")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:artifactregistry:RepositoryIamMember
properties:
project: ${["my-repo"].project}
location: ${["my-repo"].location}
repository: ${["my-repo"].name}
role: roles/artifactregistry.reader
member: user:jane@example.com
The member property (singular) specifies one identity to add. Unlike RepositoryIamBinding, RepositoryIamMember is non-authoritative: it adds the specified member without removing others who already have the same role. This approach works well for incremental access grants where you don’t want to manage the complete member list.
Beyond these examples
These snippets focus on specific IAM binding features: role-based access control and batch and incremental member grants. They’re intentionally minimal rather than full access management solutions.
The examples reference pre-existing infrastructure such as Artifact Registry repositories. They focus on configuring IAM bindings rather than provisioning repositories or managing identity providers.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Full policy replacement (RepositoryIamPolicy)
- Custom role definitions
- Federated identity configuration
These omissions are intentional: the goal is to illustrate how each IAM binding feature is wired, not provide drop-in access control modules. See the Artifact Registry RepositoryIamBinding resource reference for all available configuration options.
Let's manage GCP Artifact Registry 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
Three resources manage IAM policies with different behaviors:
RepositoryIamPolicy: Authoritative, replaces the entire IAM policyRepositoryIamBinding: Authoritative for a specific role, preserves other rolesRepositoryIamMember: Non-authoritative, adds a single member to a role without affecting other members
RepositoryIamPolicy cannot be used with RepositoryIamBinding or RepositoryIamMember because they will conflict over the policy state.RepositoryIamBinding can be used per role. For multiple members on the same role, use a single RepositoryIamBinding with multiple members, or use RepositoryIamMember for additional members.IAM Configuration
The members array supports multiple identity formats:
allUsers: Anyone on the internetallAuthenticatedUsers: Anyone with a Google accountuser:{emailid}: Specific Google account (e.g.,user:alice@gmail.com)serviceAccount:{emailid}: Service account (e.g.,serviceAccount:my-app@appspot.gserviceaccount.com)group:{emailid}: Google group (e.g.,group:admins@example.com)domain:{domain}: All users in a G Suite domain (e.g.,domain:example.com)projectOwner:projectid,projectEditor:projectid,projectViewer:projectid: Project-level roles- Federated identities: Workload/workforce identity pool principals (e.g.,
principal://iam.googleapis.com/...)
[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
asia, europe, and us. Use the gcp.artifactregistry.getLocations data source to discover available locations.For IAM binding imports, use space-delimited identifiers with the resource path and role:
pulumi import gcp:artifactregistry/repositoryIamBinding:RepositoryIamBinding editor "projects/{{project}}/locations/{{location}}/repositories/{{repository}} roles/artifactregistry.reader"
The resource path can be shortened to {{project}}/{{location}}/{{repository}}, {{location}}/{{repository}}, or just {{repository}} if values are available from the provider configuration.
location, project, repository, role, and condition. Changing these requires recreating the resource.