Skip to content
BytePatterns

DOP-C02 · Domain 6: Security and Compliance · 17% of the exam

Task 6.1: Implement techniques for identity and access management at scale.

Access for people and machines across many accounts: roles, federation and IAM Identity Center, permissions boundaries for delegated administration, SCPs, attribute-based access control, and rotating machine credentials automatically.

Study it

  • IAM at scale: roles, federation, IAM Identity Center and session policies

    Partly covered by: Shared Responsibility & IAM

  • Delegation and guardrails: permissions boundaries, SCPs and attribute-based access control

    Partly covered by: Shared Responsibility & IAM

  • Machine credentials: Secrets Manager rotation and temporary credentials

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the AWS documentation page that proves it.

Question 1 · choose 1

Developers in a workload account must be able to create IAM roles for their own Lambda functions without waiting for the security team. Security requires that no role a developer creates can ever have more permissions than an approved policy named AppBoundary, and that developers cannot weaken this control. What should the DevOps engineer do?

  1. AAttach an SCP to the account that denies iam:CreateRole for every principal except the security team's role
  2. BAllow role creation only with iam:PermissionsBoundary set to AppBoundary, and deny edits to AppBoundary and boundary removal
  3. CSet AppBoundary as the permissions boundary of the developers' own role and allow them to create and pass roles without any condition
  4. DRequire developers to assume their role with a session policy equal to AppBoundary whenever they create a role
Show the answer and why
  • AAttach an SCP to the account that denies iam:CreateRole for every principal except the security team's role

    Incorrect

    This keeps the control but takes role creation away from the developers, which is the opposite of the request.

  • BAllow role creation only with iam:PermissionsBoundary set to AppBoundary, and deny edits to AppBoundary and boundary removal

    Correct

    A condition on iam:PermissionsBoundary lets the delegate create principals only with the required boundary, and denying edits to the boundary policy and its removal stops the delegate from escaping it.

  • CSet AppBoundary as the permissions boundary of the developers' own role and allow them to create and pass roles without any condition

    Incorrect

    The boundary limits the developers' role, but the roles they create can carry any policy, so they could create a more powerful role and use it.

  • DRequire developers to assume their role with a session policy equal to AppBoundary whenever they create a role

    Incorrect

    A session policy limits only that session. It places no limit on the permissions of the roles created during it.

Permissions boundaries are the IAM tool for delegating permission management. The delegate may create principals only if they carry the approved boundary, and must not be able to edit or detach that boundary.

Question 2 · choose 1

A shared services account has an IAM role that publishes release artifacts. A role named deploy-pipeline exists in each of about 150 accounts in the Workloads OU and its child OUs, and each of those roles must be able to assume the publishing role. Roles in accounts under any other OU, such as Sandbox, must not. Accounts join the Workloads OU every week and sometimes move between OUs, and the platform team does not want the publishing role's trust policy to change when that happens. What should the trust policy contain?

  1. AA principal of arn:aws:iam::*:role/deploy-pipeline, so that the role with that name in every account is trusted
  2. BA principal list with the account ID of every Workloads account, kept up to date by a Lambda function that runs when an account joins the OU
  3. CA principal of "AWS": "*" with a condition that matches the Workloads OU path in aws:SourceOrgPaths
  4. DA principal of "AWS": "*" with conditions on aws:PrincipalOrgPaths for the Workloads OU path and on aws:PrincipalArn for deploy-pipeline
Show the answer and why
  • AA principal of arn:aws:iam::*:role/deploy-pipeline, so that the role with that name in every account is trusted

    Incorrect

    A wildcard cannot match part of a principal name or ARN in the Principal element, so this does not name the roles in many accounts.

  • BA principal list with the account ID of every Workloads account, kept up to date by a Lambda function that runs when an account joins the OU

    Incorrect

    The trust policy would change every time an account joins or leaves the OU, which the platform team does not want, and the function is extra code to maintain.

  • CA principal of "AWS": "*" with a condition that matches the Workloads OU path in aws:SourceOrgPaths

    Incorrect

    aws:SourceOrgPaths is in the request context only when an AWS service principal calls on behalf of a resource. A role that assumes another role does not carry it, so the condition never matches.

  • DA principal of "AWS": "*" with conditions on aws:PrincipalOrgPaths for the Workloads OU path and on aws:PrincipalArn for deploy-pipeline

    Correct

    aws:PrincipalOrgPaths holds the organization path of the caller's account, so a path that ends in /* covers the OU and its child OUs, and aws:PrincipalArn narrows the trust to the deploy-pipeline roles.

A trust policy cannot name roles across many accounts with a wildcard in the Principal element, but it can trust every principal and then restrict access in the Condition element. aws:PrincipalOrgPaths follows the organization's structure, so an account that joins or leaves the Workloads OU gains or loses access without a policy change, and aws:PrincipalArn keeps other roles in those accounts out. The organization ID belongs at the start of the path, because OU IDs are unique only within one organization.

Question 3 · choose 1

An application on Amazon ECS with AWS Fargate connects to an Amazon RDS for PostgreSQL DB instance as the database user app_rw, whose password sits in a SecureString parameter. Security now requires that the application hold no long-lived database password at all, whether in a parameter, a secret or a file, that access for the application be granted and revoked through the task's IAM role, and that no rotation process exist for this user. The DB instance has spare memory, and the drivers the application uses support the required authentication. What should the DevOps engineer do?

  1. AMove the password to a Secrets Manager secret with a seven-day rotation schedule, and allow the task role to read the secret
  2. BTurn on Kerberos authentication for the DB instance with AWS Managed Microsoft AD, and create app_rw in the directory
  3. CTurn on IAM database authentication, grant rds_iam to app_rw, and allow the task role rds-db:connect on that database user
  4. DAllow the task role rds-db:connect on app_rw, and keep the password in the parameter for the application to connect with
Show the answer and why
  • AMove the password to a Secrets Manager secret with a seven-day rotation schedule, and allow the task role to read the secret

    Incorrect

    The application would still use a long-lived password, now stored in a secret, and the rotation schedule is the kind of process security wants to remove.

  • BTurn on Kerberos authentication for the DB instance with AWS Managed Microsoft AD, and create app_rw in the directory

    Incorrect

    Kerberos authenticates users that are stored in a directory, so access would depend on directory credentials, not on the task's IAM role, and it adds a directory to run.

  • CTurn on IAM database authentication, grant rds_iam to app_rw, and allow the task role rds-db:connect on that database user

    Correct

    The application then connects with an authentication token that is generated from the task role's credentials and lasts 15 minutes, so no database password is stored or rotated.

  • DAllow the task role rds-db:connect on app_rw, and keep the password in the parameter for the application to connect with

    Incorrect

    The rds-db:connect permission is used only by IAM database authentication. A connection with the stored password ignores it, and the long-lived password stays.

IAM database authentication replaces the database password with a short-lived token that is signed with AWS credentials, here the ECS task role's. Access is controlled in IAM through rds-db:connect on a resource ARN for one database user, so removing the permission from the role revokes access. On PostgreSQL the database user needs the rds_iam role, and IAM authentication then takes precedence over password authentication for that user. The feature needs extra memory on the DB instance.

Question 4 · choose 1

Batch servers in a company's own data center upload files to Amazon S3 with IAM user access keys stored in configuration files. A security review requires removing all long-term AWS credentials from these servers. The company already runs an internal certificate authority that issues X.509 certificates to every server. What should the DevOps engineer do?

  1. ARegister the internal CA as an IAM Roles Anywhere trust anchor and use the servers' certificates to get temporary role credentials
  2. BKeep the access keys and rotate them every 30 days with a scheduled script that stores new keys in the configuration files
  3. CAssign the servers' service accounts to users in IAM Identity Center and let the batch jobs sign in through the AWS access portal
  4. DStore the access keys in AWS Secrets Manager and have each server read them before every upload, using a second set of access keys
Show the answer and why
  • ARegister the internal CA as an IAM Roles Anywhere trust anchor and use the servers' certificates to get temporary role credentials

    Correct

    IAM Roles Anywhere gives workloads outside AWS temporary credentials for an IAM role, using X.509 certificates from a CA registered as a trust anchor.

  • BKeep the access keys and rotate them every 30 days with a scheduled script that stores new keys in the configuration files

    Incorrect

    Rotated access keys are still long-term credentials, which the review wants removed.

  • CAssign the servers' service accounts to users in IAM Identity Center and let the batch jobs sign in through the AWS access portal

    Incorrect

    IAM Identity Center is for workforce users signing in. Batch servers need a machine credential flow, not an interactive portal.

  • DStore the access keys in AWS Secrets Manager and have each server read them before every upload, using a second set of access keys

    Incorrect

    The servers would still need long-term keys to read the secret, so the long-term credentials remain.

For workloads outside AWS, IAM Roles Anywhere replaces stored access keys with short-lived role credentials, trusting the company's existing PKI. AWS best practice is that workloads use temporary credentials with IAM roles.

Question 5 · choose 1

A job scheduler assumes one shared automation role that has broad permissions. Each job should run with only the permissions it needs, such as read access to one bucket, without creating a separate role for every job. What should the DevOps engineer do?

  1. APass a session policy for each job when the scheduler assumes the role
  2. BAttach a permissions boundary to the shared role that allows only bucket reads
  3. CAdd an inline policy to the role before each job and remove it after
  4. DUse the role session name to describe what each job may access
Show the answer and why
  • APass a session policy for each job when the scheduler assumes the role

    Correct

    A session's permissions are the intersection of the role's policies and the session policy, which scopes down each session.

  • BAttach a permissions boundary to the shared role that allows only bucket reads

    Incorrect

    A boundary on the shared role limits every job the same way.

  • CAdd an inline policy to the role before each job and remove it after

    Incorrect

    Editing the shared role per job affects other jobs running at the same time.

  • DUse the role session name to describe what each job may access

    Incorrect

    A session name identifies a session; it does not limit permissions.

Session policies are passed when a role is assumed. They cannot grant more than the role allows, and they narrow each session to the job's needs.

Question 6 · choose 1

A central S3 bucket in the log archive account receives VPC flow logs that are published directly to Amazon S3 from every account in the company's organization, in all OUs, including Workloads, Sandbox and Security. Flow logs created in accounts outside the organization must not be able to write to it. Accounts join and leave every week. Today the bucket policy allows the delivery.logs.amazonaws.com service principal with an aws:SourceAccount condition that lists account IDs, which the team updates by hand, so delivery from a new account fails until the next edit. What should the DevOps engineer change in the bucket policy?

  1. AReplace the account list with an aws:SourceOrgPaths condition that matches the path of the Workloads OU
  2. BReplace the account list with an aws:ResourceOrgID condition that equals the organization ID
  3. CKeep the account list, but have a weekly Lambda function rewrite it from the Organizations ListAccounts API
  4. DReplace the account list with an aws:SourceOrgID condition that equals the organization ID
Show the answer and why
  • AReplace the account list with an aws:SourceOrgPaths condition that matches the path of the Workloads OU

    Incorrect

    OU paths suit delivery from part of an organization, but this path leaves out the Sandbox and Security accounts.

  • BReplace the account list with an aws:ResourceOrgID condition that equals the organization ID

    Incorrect

    This key describes the organization that owns the bucket being accessed, which is always the company's, so flow logs from outside accounts could still write.

  • CKeep the account list, but have a weekly Lambda function rewrite it from the Organizations ListAccounts API

    Incorrect

    This automates the list, but delivery from a new account still fails until the next run, and the team maintains the function.

  • DReplace the account list with an aws:SourceOrgID condition that equals the organization ID

    Correct

    The calling service passes the organization of the account that owns the flow log, so accounts that join or leave are covered without editing the policy, and outside flow logs are denied.

When an AWS service principal writes to a resource on behalf of resources in many accounts, aws:SourceOrgID matches the organization of the originating resource, here each flow log, so the policy needs no account list. aws:SourceOrgPaths applies the same check to chosen OUs, and aws:ResourceOrgID describes the resource being accessed rather than where the request came from.

Question 7 · choose 1

A team wrote one IAM policy that should let each IAM user access only the S3 prefix home/${aws:username}/. Users get Access Denied for their own folders. The policy JSON has no Version element. What should the DevOps engineer change?

  1. AReplace the variable with each user's name in separate policies
  2. BAdd "Version": "2012-10-17" to the policy so the variable works
  3. CAdd an s3:prefix condition that lists every user's folder name
  4. DAttach the policy to a group instead of to each user
Show the answer and why
  • AReplace the variable with each user's name in separate policies

    Incorrect

    Separate policies per user remove the benefit of one shared policy.

  • BAdd "Version": "2012-10-17" to the policy so the variable works

    Correct

    Without a supporting Version element, variables such as ${aws:username} are treated as literal strings.

  • CAdd an s3:prefix condition that lists every user's folder name

    Incorrect

    Listing every folder replaces the variable with a manual list.

  • DAttach the policy to a group instead of to each user

    Incorrect

    Attaching to a group does not make the variable work.

Policy variables were introduced with policy language version 2012-10-17. Policies without that Version element treat variables as plain text.

Question 8 · choose 1

An S3 bucket must invoke a Lambda function for new objects. Security wants the function's permission for S3 limited so that only that one bucket, in the company's own account, can invoke it. Where and how should the DevOps engineer grant the permission?

  1. AIn the function's execution role, allow s3:GetObject on that bucket
  2. BIn the bucket policy, allow lambda:InvokeFunction on the function's ARN for S3
  3. CIn the function's resource policy, allow S3 with bucket and account conditions
  4. DIn an SCP for the account, allow Amazon S3 to invoke every Lambda function
Show the answer and why
  • AIn the function's execution role, allow s3:GetObject on that bucket

    Incorrect

    The execution role governs what the function can do, not who can invoke it.

  • BIn the bucket policy, allow lambda:InvokeFunction on the function's ARN for S3

    Incorrect

    Invocation permission is granted on the function's resource-based policy.

  • CIn the function's resource policy, allow S3 with bucket and account conditions

    Correct

    S3 needs permission from the function's resource-based policy, which can be limited to a bucket and account.

  • DIn an SCP for the account, allow Amazon S3 to invoke every Lambda function

    Incorrect

    SCPs do not grant permissions.

For S3 triggers, Lambda's resource-based policy allows Amazon S3 to invoke the function, scoped to the bucket and account. The execution role covers the function's own access to S3.

Question 9 · choose 1

An IAM Access Analyzer external access analyzer keeps creating findings for a log bucket that is intentionally shared with a known auditing partner account. Security wants these expected findings kept out of the active list, including future ones, while still seeing all other findings. What should the DevOps engineer do?

  1. ADelete the analyzer and create it again at the start of each month
  2. BRemove the partner account's access to the log bucket permanently
  3. CArchive these findings by hand in the console each time that new ones appear
  4. DCreate an archive rule for the bucket and partner, applied to existing findings
Show the answer and why
  • ADelete the analyzer and create it again at the start of each month

    Incorrect

    Recreating the analyzer does not stop the expected findings.

  • BRemove the partner account's access to the log bucket permanently

    Incorrect

    The access is intentional and must stay.

  • CArchive these findings by hand in the console each time that new ones appear

    Incorrect

    Manual archiving does not cover future findings automatically.

  • DCreate an archive rule for the bucket and partner, applied to existing findings

    Correct

    Archive rules archive new findings that match the criteria and can be applied retroactively to existing ones.

Archive rules suit regularly granted access to a specific bucket or principal. They archive matching findings automatically so reviewers focus on unexpected access.

Practise domain 6 →Practise all domains →