The gcp:apigee/environmentIamMember:EnvironmentIamMember resource, part of the Pulumi GCP provider, manages IAM permissions for Apigee environments by granting roles to individual members, groups of members, or replacing entire policies. This guide focuses on three capabilities: non-authoritative single-member grants, authoritative role-level member lists, and complete policy replacement.
The three IAM resource types (EnvironmentIamMember, EnvironmentIamBinding, EnvironmentIamPolicy) reference existing Apigee environments and have strict compatibility rules. EnvironmentIamPolicy cannot be combined with the other two types; EnvironmentIamBinding and EnvironmentIamMember can coexist only if they manage different roles. The examples are intentionally small. Choose the resource type that matches your permission management strategy.
Grant a role to a single member non-authoritatively
When you need to add one person or service account without affecting other permissions, EnvironmentIamMember provides incremental access control.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.apigee.EnvironmentIamMember("member", {
orgId: apigeeEnvironment.orgId,
envId: apigeeEnvironment.name,
role: "roles/viewer",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.apigee.EnvironmentIamMember("member",
org_id=apigee_environment["orgId"],
env_id=apigee_environment["name"],
role="roles/viewer",
member="user:jane@example.com")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/apigee"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigee.NewEnvironmentIamMember(ctx, "member", &apigee.EnvironmentIamMemberArgs{
OrgId: pulumi.Any(apigeeEnvironment.OrgId),
EnvId: pulumi.Any(apigeeEnvironment.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.Apigee.EnvironmentIamMember("member", new()
{
OrgId = apigeeEnvironment.OrgId,
EnvId = apigeeEnvironment.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.apigee.EnvironmentIamMember;
import com.pulumi.gcp.apigee.EnvironmentIamMemberArgs;
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 EnvironmentIamMember("member", EnvironmentIamMemberArgs.builder()
.orgId(apigeeEnvironment.orgId())
.envId(apigeeEnvironment.name())
.role("roles/viewer")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:apigee:EnvironmentIamMember
properties:
orgId: ${apigeeEnvironment.orgId}
envId: ${apigeeEnvironment.name}
role: roles/viewer
member: user:jane@example.com
The member property specifies a single identity in the format user:email, serviceAccount:email, group:email, or other supported formats. This resource adds the member to the role without removing other members who already have that role. The orgId and envId properties identify the target environment.
Grant a role to multiple members authoritatively
When you need to define the complete membership list for a specific role, EnvironmentIamBinding replaces all existing members for that role.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.apigee.EnvironmentIamBinding("binding", {
orgId: apigeeEnvironment.orgId,
envId: apigeeEnvironment.name,
role: "roles/viewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.apigee.EnvironmentIamBinding("binding",
org_id=apigee_environment["orgId"],
env_id=apigee_environment["name"],
role="roles/viewer",
members=["user:jane@example.com"])
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/apigee"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := apigee.NewEnvironmentIamBinding(ctx, "binding", &apigee.EnvironmentIamBindingArgs{
OrgId: pulumi.Any(apigeeEnvironment.OrgId),
EnvId: pulumi.Any(apigeeEnvironment.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.Apigee.EnvironmentIamBinding("binding", new()
{
OrgId = apigeeEnvironment.OrgId,
EnvId = apigeeEnvironment.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.apigee.EnvironmentIamBinding;
import com.pulumi.gcp.apigee.EnvironmentIamBindingArgs;
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 EnvironmentIamBinding("binding", EnvironmentIamBindingArgs.builder()
.orgId(apigeeEnvironment.orgId())
.envId(apigeeEnvironment.name())
.role("roles/viewer")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:apigee:EnvironmentIamBinding
properties:
orgId: ${apigeeEnvironment.orgId}
envId: ${apigeeEnvironment.name}
role: roles/viewer
members:
- user:jane@example.com
The members property takes an array of identities. This resource is authoritative for the specified role: it replaces the complete member list for that role while preserving other roles in the environment. If another member had this role before, they lose it unless explicitly listed in members.
Replace the entire IAM policy authoritatively
When you need complete control over all IAM bindings, EnvironmentIamPolicy replaces the entire 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.apigee.EnvironmentIamPolicy("policy", {
orgId: apigeeEnvironment.orgId,
envId: apigeeEnvironment.name,
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.apigee.EnvironmentIamPolicy("policy",
org_id=apigee_environment["orgId"],
env_id=apigee_environment["name"],
policy_data=admin.policy_data)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/apigee"
"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 = apigee.NewEnvironmentIamPolicy(ctx, "policy", &apigee.EnvironmentIamPolicyArgs{
OrgId: pulumi.Any(apigeeEnvironment.OrgId),
EnvId: pulumi.Any(apigeeEnvironment.Name),
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.Apigee.EnvironmentIamPolicy("policy", new()
{
OrgId = apigeeEnvironment.OrgId,
EnvId = apigeeEnvironment.Name,
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.apigee.EnvironmentIamPolicy;
import com.pulumi.gcp.apigee.EnvironmentIamPolicyArgs;
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 EnvironmentIamPolicy("policy", EnvironmentIamPolicyArgs.builder()
.orgId(apigeeEnvironment.orgId())
.envId(apigeeEnvironment.name())
.policyData(admin.policyData())
.build());
}
}
resources:
policy:
type: gcp:apigee:EnvironmentIamPolicy
properties:
orgId: ${apigeeEnvironment.orgId}
envId: ${apigeeEnvironment.name}
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 output from gcp.organizations.getIAMPolicy, which defines all role bindings in a single structure. This resource is fully authoritative: it removes any permissions not explicitly defined in the policy. You cannot use EnvironmentIamPolicy alongside EnvironmentIamBinding or EnvironmentIamMember, as they will conflict over policy ownership.
Beyond these examples
These snippets focus on specific IAM management features: incremental vs authoritative permission management, and single-member and multi-member role grants. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as Apigee environments (orgId and envId references). They focus on permission assignment rather than environment provisioning.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Custom role definitions and formatting
- Service account and federated identity configuration
- Policy conflict resolution between resource types
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 Apigee EnvironmentIamMember resource reference for all available configuration options.
Let's manage GCP Apigee Environment IAM Access
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
You have three options:
- EnvironmentIamPolicy - Authoritative, replaces the entire IAM policy
- EnvironmentIamBinding - Authoritative for a specific role, preserves other roles
- EnvironmentIamMember - Non-authoritative, adds a single member to a role while preserving other members
EnvironmentIamPolicy cannot be used with EnvironmentIamBinding or EnvironmentIamMember because they will conflict over the policy configuration.Configuration & Formats
The member parameter supports multiple formats:
allUsersorallAuthenticatedUsersfor broad accessuser:{email},serviceAccount:{email},group:{email}for specific identitiesdomain:{domain}for G Suite domainsprojectOwner/Editor/Viewer:{projectid}for project-level rolesprincipal://...for federated identities (workload/workforce pools)
[projects|organizations]/{parent-name}/roles/{role-name}. For example, projects/my-project/roles/my-custom-role or organizations/my-org/roles/my-custom-role.orgId must be in the format organizations/{{org_name}}.Immutability & Lifecycle
envId, member, orgId, role, and condition. Changes to any of these require recreating the resource.