The gcp:apigee/environmentIamMember:EnvironmentIamMember resource, part of the Pulumi GCP provider, manages IAM access to Apigee environments by granting roles to individual members, groups of members, or replacing entire policies. This guide focuses on three capabilities: non-authoritative member grants, authoritative role bindings, and complete policy replacement.
These three resources (EnvironmentIamMember, EnvironmentIamBinding, EnvironmentIamPolicy) serve different use cases and have compatibility constraints. EnvironmentIamPolicy cannot be used with the other two resources, as they will conflict over policy state. EnvironmentIamBinding and EnvironmentIamMember can coexist only if they manage different roles. The examples are intentionally small. Combine them with your own Apigee organization and environment infrastructure.
Grant a single user access to an environment
Most IAM configurations start by granting individual users specific roles without affecting existing access.
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 identifies who receives access (user, service account, group, or domain). The role property specifies the permission level. This non-authoritative approach adds the member to the role without removing other members, making it safe for incremental access grants.
Manage all members for a specific role
When you need to control the complete list of who has a particular role, binding resources define the authoritative member list 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 array replaces the complete list of identities with the specified role. Other roles on the environment remain unchanged. This authoritative approach for a single role ensures you know exactly who has viewer access, but removes any members not in your list.
Replace the entire IAM policy for an environment
Organizations managing IAM centrally often need to set the complete policy document, replacing all existing configuration.
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 a complete IAM policy document, typically retrieved from getIAMPolicy. This replaces the entire policy for the environment, removing any roles or members not in the new policy. Use this approach only when you need full control and understand the risk of overwriting existing access.
Beyond these examples
These snippets focus on specific IAM management approaches: incremental member grants, authoritative role bindings, and complete policy replacement. They’re intentionally minimal rather than full access control configurations.
The examples reference pre-existing infrastructure such as an Apigee organization and environment. They focus on configuring IAM access rather than provisioning the Apigee resources themselves.
To keep things focused, common IAM patterns are omitted, including:
- Conditional IAM bindings (condition property)
- Custom role definitions and formatting
- Service account and group member types
- Federated identity principals
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 Environment IAM Member 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
gcp.apigee.EnvironmentIamPolicy cannot be used with gcp.apigee.EnvironmentIamBinding or gcp.apigee.EnvironmentIamMember because they will conflict over the policy configuration.Configuration & Identity Formats
Supported formats include:
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}- G Suite domain (e.g.,domain:example.com)projectOwner:projectid,projectEditor:projectid,projectViewer:projectid- Project roles- Federated identities (e.g.,
principal://iam.googleapis.com/locations/global/workforcePools/...)
organizations/{{org_name}} (e.g., organizations/my-org).[projects|organizations]/{parent-name}/roles/{role-name} (e.g., projects/my-project/roles/my-custom-role).Import & Custom Roles
{{org_id}}/environments/{{environment}} roles/viewer user:jane@example.com. For custom roles, use the full role path like projects/my-project/roles/my-custom-role.Immutability & Constraints
envId, orgId, role, and member. Changing any of these requires recreating the resource.