Manage GCP Tag Key IAM Bindings

The gcp:tags/tagKeyIamBinding:TagKeyIamBinding resource, part of the Pulumi GCP provider, manages IAM role bindings for tag keys, controlling which identities can perform operations on tags. This guide focuses on two capabilities: granting roles to multiple members authoritatively and adding individual members non-authoritatively.

IAM bindings reference existing TagKey resources and require valid Google Cloud identities. The examples are intentionally small. Combine them with your own tag key infrastructure and identity management.

Grant a role to multiple members

Teams managing tag key permissions 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.tags.TagKeyIamBinding("binding", {
    tagKey: key.name,
    role: "roles/viewer",
    members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp

binding = gcp.tags.TagKeyIamBinding("binding",
    tag_key=key["name"],
    role="roles/viewer",
    members=["user:jane@example.com"])
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/tags"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := tags.NewTagKeyIamBinding(ctx, "binding", &tags.TagKeyIamBindingArgs{
			TagKey: pulumi.Any(key.Name),
			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.Tags.TagKeyIamBinding("binding", new()
    {
        TagKey = key.Name,
        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.tags.TagKeyIamBinding;
import com.pulumi.gcp.tags.TagKeyIamBindingArgs;
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 TagKeyIamBinding("binding", TagKeyIamBindingArgs.builder()
            .tagKey(key.name())
            .role("roles/viewer")
            .members("user:jane@example.com")
            .build());

    }
}
resources:
  binding:
    type: gcp:tags:TagKeyIamBinding
    properties:
      tagKey: ${key.name}
      role: roles/viewer
      members:
        - user:jane@example.com

The TagKeyIamBinding resource is authoritative for the specified role. The members array lists all identities that should have this role; any existing members not in this list are removed. The tagKey property references the tag key resource, and role specifies the IAM role to grant. This approach works well when you want complete control over who has a specific role.

Add a single member to a role

When you need to grant access to one additional identity without affecting existing members, use TagKeyIamMember instead.

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const member = new gcp.tags.TagKeyIamMember("member", {
    tagKey: key.name,
    role: "roles/viewer",
    member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp

member = gcp.tags.TagKeyIamMember("member",
    tag_key=key["name"],
    role="roles/viewer",
    member="user:jane@example.com")
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/tags"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := tags.NewTagKeyIamMember(ctx, "member", &tags.TagKeyIamMemberArgs{
			TagKey: pulumi.Any(key.Name),
			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.Tags.TagKeyIamMember("member", new()
    {
        TagKey = key.Name,
        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.tags.TagKeyIamMember;
import com.pulumi.gcp.tags.TagKeyIamMemberArgs;
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 TagKeyIamMember("member", TagKeyIamMemberArgs.builder()
            .tagKey(key.name())
            .role("roles/viewer")
            .member("user:jane@example.com")
            .build());

    }
}
resources:
  member:
    type: gcp:tags:TagKeyIamMember
    properties:
      tagKey: ${key.name}
      role: roles/viewer
      member: user:jane@example.com

TagKeyIamMember is non-authoritative: it adds one member to a role without replacing existing grants. The member property takes a single identity string (format: “user:email”, “serviceAccount:email”, “group:email”). This resource preserves other members who already have the role, making it safe to use alongside other IAM grants. You can combine multiple TagKeyIamMember resources for the same role, or mix TagKeyIamMember with TagKeyIamBinding as long as they target different roles.

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 TagKey resources (via key.name). They focus on configuring IAM bindings rather than provisioning tag keys or managing identity providers.

To keep things focused, common IAM patterns are omitted, including:

  • Conditional IAM bindings (condition property)
  • Policy-level management (TagKeyIamPolicy)
  • Custom role configuration

These omissions are intentional: the goal is to illustrate how each IAM binding approach is wired, not provide drop-in access control modules. See the TagKeyIamBinding resource reference for all available configuration options.

Let's manage GCP Tag Key IAM Bindings

Get started with Pulumi Cloud, then follow our quick setup guide to deploy this infrastructure.

Try Pulumi Cloud for FREE

Frequently Asked Questions

Resource Selection & Conflicts
Can I use TagKeyIamPolicy with TagKeyIamBinding or TagKeyIamMember?
No, gcp.tags.TagKeyIamPolicy cannot be used with gcp.tags.TagKeyIamBinding or gcp.tags.TagKeyIamMember because they will conflict over the policy state.
Can I use TagKeyIamBinding and TagKeyIamMember together?
Yes, but only if they manage different roles. Using both for the same role causes conflicts.
Which IAM resource should I use for managing tag key permissions?
Use gcp.tags.TagKeyIamPolicy for full policy control (replaces entire policy), gcp.tags.TagKeyIamBinding for managing all members of a specific role, or gcp.tags.TagKeyIamMember for adding individual members non-authoritatively.
Configuration & Roles
How do I specify custom roles for tag key IAM bindings?
Custom roles must use the full 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.
What properties can't I change after creating a TagKeyIamBinding?
The role, tagKey, and condition properties are immutable and cannot be changed after creation.
Member Identities
What member identity formats are supported?

Supported formats include:

  • Users: user:alice@gmail.com
  • Service accounts: serviceAccount:my-app@appspot.gserviceaccount.com
  • Groups: group:admins@example.com
  • Domains: domain:example.com
  • Special identifiers: allUsers, allAuthenticatedUsers
  • Project roles: projectOwner:my-project, projectEditor:my-project, projectViewer:my-project
  • Federated identities: principal://iam.googleapis.com/locations/global/workforcePools/example-contractors/subject/joe@example.com

Using a different cloud?

Explore security guides for other cloud providers: