Prepare and test your skills
Prepare and test your skills
Designing environment-specific Identity and Access Management (IAM) policies means controlling who can act on development, testing, and production by combining resource hierarchy, role choice, and runtime conditions. Identity and Access Management (IAM) (opens in a new tab) allow policies set high in the hierarchy flow downward to every child, while environment folders add only the narrow bindings each tier needs. Production therefore stays strict with approved identities and secure contexts, while development and staging stay flexible without risking production.
Environment isolation in Google Cloud uses folders inside one organization (opens in a new tab) to host development, testing, and production workloads for the same application. IAM allow policies set at the organization or a common parent folder inherit to every child project and resource, so shared viewer, logging, or security policies stay consistent without repetition. Policies set on an environment folder apply only to projects under that folder, which lets production stay strict while development and testing keep enough parity that a release validated in test behaves the same in production.
A separate staging organization tests organization-wide change, not daily development work. The staging organization mirrors the production folder structure with only a small number of projects and carries either the current production IAM and organization policies or the next version intended for production. Dedicated test users and groups in a staging Cloud Identity or Google Workspace account mirror production groups, so hierarchy and policy changes can be validated without impacting existing users. A separate experiment organization provides an unencumbered sandbox for tutorials and new services, with automation to delete resources after a set lifetime to control cost and risk.
Exam tip: Host development, testing, and production in folders within the same organization, and reserve a separate staging organization only for testing IAM, organization policy, and hierarchy changes.
Least privilege scales with environment risk by changing role breadth, scope, and trust boundaries. In production, basic roles such as Owner (roles/owner) are avoided because they include thousands of permissions across services and allow almost all resource and allow-policy changes. In test or development projects, basic roles may be acceptable when broader flexibility helps velocity, but production uses the most limited predefined roles or custom roles that meet the task, with role recommendations and Policy Simulator used to replace broad grants safely.
Each application component forms its own trust boundary with its own service account granted only the permissions that component needs. Roles are granted at the smallest scope possible, for example Publisher on a single Pub/Sub topic rather than on the whole project, and a role needed across many projects is granted once on their shared folder rather than repeated per project. Control over impersonation is equally scoped, because users with the Service Account User role on a service account can access everything that service account can access, and control over who can create and manage service accounts is explicitly limited. Administrative power is split so Project IAM Admin and Folder IAM Admin can modify allow policies without granting direct read, write, and administrative access to all resources, while Owner is reserved for near-universal access.
Cloud Deploy delivery controls restrict pipeline actions by resource, action type, and runtime context rather than by project-wide grants. An IAM policy binds a role such as roles/clouddeploy.developer or roles/clouddeploy.operator, or specific clouddeploy.deliveryPipelines.* permissions, to users, groups, or service accounts, and the binding is applied with setIamPolicy to a single delivery pipeline or target. Project-level grants with gcloud projects set-iam-policy affect all pipelines or targets in that project, so environment separation depends on applying narrow bindings at the pipeline or target resource inside the correct environment folder.
Fine-grained Cloud Deploy access separates who can build, release, promote, and approve across environments. The model distinguishes pipeline configuration from target promotion and approval:
IAM Conditions enforce the secure context by evaluating request attributes at runtime, such as resource name from API attributes or time of day, before a binding takes effect. Production promotion can therefore require an approved pipeline service account plus a maintenance window, while development promotion allows developer groups without that window. Separation of duties is preserved by granting promote rights and approve rights to different principals on the production target, so no single identity can both ship and self-approve a production rollout.
Preventive organization policy constraints keep environment IAM from being bypassed by external identities or persistent credentials. The Domain restricted sharing constraint (iam.allowedPolicyMemberDomains) limits IAM policy members to specified customer or organization IDs, so only managed accounts from approved domains can be added to development, staging, and production policies. Related constraints block creation or upload of service account keys and prevent automatic over-permissive grants to default service accounts, which pushes pipelines toward short-lived impersonation and per-component service accounts.
Separation of duties turns least privilege into an auditable operating model for each environment. Teams define the minimum permissions for each task, identify which users and roles truly need administrator rights, create a security group for administrators, and grant IAM roles to the group rather than to individuals. Console access is limited to that security group, multi-factor authentication (MFA) is required for its members, and IAM Conditions add context such as time or source constraints where production needs stronger assurance. At least two principals, or a group containing at least two principals, retain Owner on every project so administrative control survives personnel changes without widening daily access.
Auditable environment access depends on logging every policy change and regularly shrinking overbroad grants. Audit logs record all setIamPolicy() calls, so creation or modification of any environment binding can be traced to caller, time, and resource. Viewing inherited policy requires resourcemanager.organizations.getIamPolicy, resourcemanager.folders.getIamPolicy, or resourcemanager.projects.getIamPolicy on the parent, which reinforces that folder and organization grants must be reviewed as part of any environment audit.
Continuous review keeps development, staging, and production roles aligned as code and ownership change. IAM Recommender, Policy Analyzer, Policy Simulator, and Access Approval identify unused permissions, model the impact of downgrading a basic role to narrower roles, and add human approval for sensitive production access. Conditional role bindings and temporary elevated access let production write access expire automatically instead of persisting. Enforcement is automated through version-controlled infrastructure as code with Deployment Manager or Terraform, so environment IAM is validated before deployment and reapplied consistently across folders.
Implementing conditional IAM policies with context-aware access means a deployment permission is granted only when both identity and security context match. Identity and Access Management (IAM) checks who the principal is and what role they hold, while network and time context checks where, from what, and when the request comes. In deployment pipelines, this combination enforces least privilege across development, staging, and production so production can require a stricter context than lower environments.
Default IAM access decisions do not consider geolocation, source IP address, or origin Google Cloud project. A stolen access token or service account key is therefore usable from anywhere, including a machine controlled by an attacker. VPC Service Controls (opens in a new tab) adds the missing network boundary by placing projects inside a perimeter that denies access to restricted services from traffic originating outside it. Access is allowed only when the IAM allow policy permits the identity and the perimeter ingress rule permits the network context.
A VPC Service Controls perimeter denies access to restricted Google Cloud services from outside sources, including the console, developer workstations, and pipelines that run outside the perimeter. An ingress rule creates a narrow exception that allows an intended access path back into the perimeter. For deployment pipelines, the ingress rule allows only the IP addresses used by the pipeline and only the services the pipeline really needs, so a leaked credential cannot be reused broadly from another network.
The correct ingress design depends on where the deployment pipeline runs, because the available context signal changes with location:
| Pipeline location | Context signal to check | Ingress rule allows |
|---|---|---|
| Runs on Google Cloud | Source Google Cloud project | Only access from the project that contains the CI/CD system |
| Runs outside Google Cloud | Access level for network origin | Only clients that satisfy an access level for approved geo-locations or IP ranges, such as a corporate network |
| Runs on SaaS CI/CD | Shared or unknown source IPs | Same access-level approach, but with reduced effectiveness |
A SaaS-based pipeline often shares source IP addresses across customers or uses addresses that are not known in advance. IP-based ingress rules therefore provide weaker assurance for SaaS runners than for a pipeline with stable corporate IPs or a pipeline project inside Google Cloud.
Exam tip: IAM ignores source IP, geolocation, and source project by default; only a VPC Service Controls perimeter with ingress rules and access levels enforces that network context.
Conditional IAM in Cloud Deploy (opens in a new tab) programmatically attaches conditions to allow policies that grant or deny access to delivery resources. The conditions limit which principal can act, on which resource, and under what circumstance, which makes it possible to give developers broad access in development while restricting production promotions. Restrictable actions include creating a delivery pipeline or target for specific users or groups, updating or deleting a specific pipeline or target, creating a release for a specific pipeline, and creating or approving a rollout or promoting a release for a specific target or pipeline, optionally limited to a specified time window.
A time-window condition is especially useful for production, where rollout approval can be granted only during a change window. Resource Manager tags extend the same idea across the hierarchy by conditionally allowing or denying IAM and organization policies based on whether a resource carries a specific tag. A production project tagged env=prod can therefore require stricter conditions than projects tagged for development or staging.
A deployment pipeline acts through its service account regardless of which developer authored the code change. This disconnect creates a confused deputy risk, where an attacker who cannot deploy directly tricks the pipeline into performing a privileged action. Each pipeline must therefore use a dedicated service account whose email includes the pipeline name or ID, and that account must receive access only to the resources that specific pipeline needs.
Pipeline service accounts must not hold broad policy-management permissions. For most resources, a RESOURCE_TYPE.setIamPolicy permission lets the holder change the allow policy to grant access to others or expand its own access, which has the effect of full access unless constrained by a deny policy. Avoid roles that include any *.setIamPolicy permission and avoid the basic roles Editor and Owner for pipeline identities. When a pipeline must manage access or create resources, narrow the blast radius by granting *.setIamPolicy only for specific resources rather than the entire project, using IAM deny policies to constrain which permissions can be granted and to which principals, and using IAM Conditions to restrict which roles the pipeline is allowed to grant, allowing only roles without *.setIamPolicy.
Use Workload Identity Federation (opens in a new tab) so pipelines running in systems like GitHub Actions or GitLab can impersonate the service account with short-lived OpenID Connect tokens instead of long-lived service account keys. Do not pass access tokens as command-line arguments, avoid storing credentials in environment variables, and configure the CI/CD system to detect and mask tokens in logs, because pipeline logs are often visible to users who cannot modify the pipeline.
Managing and auditing IAM policy changes across environments is the controlled lifecycle that moves a permission change from proposal through impact analysis to deployment and audit across development, staging, and production. The lifecycle enforces the principle of least privilege, giving a principal only the permissions required for an assigned task, while keeping every setIamPolicy modification traceable. Automation through Deployment Manager or Terraform applies the same policy consistently, so development flexibility does not create production risk.
A controlled lifecycle for IAM policy changes defines minimum permissions first, then reviews, tests, and deploys the change through code rather than manual console edits. The workflow depends on separation of duties, so the principal who proposes a binding is not the same principal who approves and applies it in production. Policy code flows from version control to development to staging to production, and only after simulation and review does the change apply to the higher environment tier.
Core controls for the lifecycle work together to prevent standing over-privilege:
setIamPolicy permission broadly, because that permission allows a user to change permissions and take control of dataGranting Project IAM Admin and Folder IAM Admin allows modification of allow policies without granting direct read, write, and administrative access to all resources. Granting Owner (roles/owner) allows access and modification of almost all resources, including allow policies, so Owner is granted only when nearly universal access is required and at least two principals hold Owner on every project to preserve manageability if one leaves.
Impact analysis with IAM Recommender (opens in a new tab) and Policy Simulator predicts whether a least-privilege change is safe before it reaches production. IAM Recommender, part of Policy Intelligence, analyzes actual permission usage and recommends the most limited predefined roles or custom roles to replace overbroad grants. Policy Simulator then tests the proposed binding against historical access to show which accesses would be added or removed. Policy Analyzer supports ongoing review by showing which principals have what access across resources.
The three tools answer different questions during a role downgrade:
| Tool | Primary question | Choose when |
|---|---|---|
| IAM Recommender | What narrower role fits actual usage? | Replacing basic roles, which include thousands of permissions across all Google Cloud services, with least-privilege roles |
| Policy Simulator | Will this change break a principal's access? | Validating a role removal or downgrade before applying it, especially to production |
| Policy Analyzer | Who can do what today? | Auditing and adjusting assigned roles during regular access reviews |
Basic roles are avoided in production unless there is no alternative, while broader basic roles may be appropriate in test or development environments. Each application component is treated as a separate trust boundary with a separate service account that receives only its required permissions, so a compromise in one service does not flow into another. Caution applies to the Service Account User role, because a user granted that role on a service account can access all resources to which the service account has access.
Exam tip: IAM Recommender determines which narrower role to grant instead, while Policy Simulator ensures that changing the role won't affect the principal's access.
Centralized auditing with Cloud Audit Logs records every IAM policy creation and modification because audit logs contain all setIamPolicy() calls. The audit trail flows from each organization, folder, and project to centralized logging, where reviewers trace when an allow policy was created or changed and which principal made the call. The logging infrastructure itself remains read-only for all principals, including privileged roles, and the ability to disable logging is controlled through segregation of duties and break-glass procedures.
Effective auditing enables data-access audit logging, then reviews both policy changes and group membership on a schedule. Ownership and membership of groups used in allow policies are audited alongside the policies, since adding a member to a privileged group grants the group's roles. Regular reviews use IAM Recommender, Policy Analyzer, or Access Approval to confirm that permissions still match assigned tasks and to remove unused access. The Domain restricted sharing organization policy constraint (iam.allowedPolicyMemberDomains) further enforces trust by allowing only principals from specified customer or organization IDs to be added to IAM policies.
Using isolation to safely test policy changes separates where policies are tried from where production workloads run. Projects group resources that share the same trust boundary, such as resources for the same product or microservice, while folders separate development, testing, staging, and production within the same organization. Allow policies for child resources inherit from allow policies for parent resources, so a grant on a project applies to every virtual machine or topic in that project regardless of resource-level policy.
Common IAM and organization policies apply at the organization level or a common parent folder, and policies that differ between environment tiers apply at individual environment folders. Roles are granted at the smallest scope needed, for example granting Publisher only on a specific Pub/Sub topic, and a role spanning multiple projects is set at the folder level (opens in a new tab) instead of repeated at each project. A dedicated staging organization mirrors the production folder structure with only a small number of projects and dedicated test users and groups, and its policies either match production or reflect the next version intended for production. The staging organization is not used for day-to-day testing environments or for open experimentation, because policy experiments there would disrupt development teams, and a separate experimental organization provides a sandbox unencumbered by production policies.
Host development, testing, and production in folders within the same organization and reserve a separate staging organization only for testing Identity and Access Management (IAM), organization policy, and hierarchy changes. IAM allow policies set at the organization or a common parent folder inherit to every child project and resource, while policies set on an environment folder apply only to projects under that folder so production can stay strict while development and testing keep enough parity.
Production avoids basic roles such as Owner (roles/owner) because they include thousands of permissions across services and allow almost all resource and allow-policy changes, using the most limited predefined roles or custom roles instead. Each application component uses its own service account granted only the permissions it needs at the smallest scope, while test or development projects may accept basic roles when broader flexibility helps velocity.
Cloud Deploy access is restricted with resource-level bindings on specific pipelines and targets plus Identity and Access Management (IAM) Conditions for time windows, rather than project-wide grants. Separation of duties is preserved by granting promote rights and approve rights to different principals on the production target, so no single identity can both ship and self-approve a production rollout.
Default IAM access decisions do not consider geolocation, source IP address, or origin Google Cloud project, so a stolen access token or service account key is usable from anywhere. VPC Service Controls adds the missing network boundary by placing projects inside a perimeter that denies access from outside unless the IAM allow policy permits the identity and the ingress rule permits the network context, allowing only the pipeline IP addresses or source project and only the services the pipeline needs.
Your organization is establishing security controls for continuous deployment pipelines targeting a critical production Google Cloud project. You need to implement an environment-aware access control mechanism for engineers who trigger and approve production release pipelines to enforce least privilege.
The solution must satisfy the following requirements:
Which approach should you implement?
Last updated