Question 1
A SaaS vendor needs access to resources in a customer's AWS account. The customer creates an IAM role that the vendor's account can assume. The security team wants to prevent the confused deputy problem. What should be added to the role?
- A condition in the role's trust policy that limits aws:SourceIp to the vendor's office IP ranges.
- A condition in the role's trust policy that requires a unique sts:ExternalId value provided by the vendor. — Correct
- A condition in the role's permissions policy that requires aws:MultiFactorAuthPresent to be true.
- A permissions boundary on the role that limits it to the actions that the vendor needs.
Correct answer
A condition in the role's trust policy that requires a unique sts:ExternalId value provided by the vendor.
Explanation
An external ID in the trust policy ensures the vendor assumes the role only on behalf of this customer. MFA does not apply to service-to-service calls. IP conditions are fragile and do not address the confused deputy problem. A boundary limits permissions but does not control who assumes the role.
Question 2
A developer creates a Lambda function with a new IAM role, and the creation fails with the error 'The role defined for the function cannot be assumed by Lambda.' The role has a permissions policy for DynamoDB. What is the cause?
- The role's permissions policy does not include the AWSLambdaBasicExecutionRole managed policy for logs.
- The role's name does not start with the required lambda- prefix for execution roles.
- The role's trust policy does not allow the lambda.amazonaws.com service principal to call sts:AssumeRole. — Correct
- The developer does not have the lambda:InvokeFunction permission on the new function.
Correct answer
The role's trust policy does not allow the lambda.amazonaws.com service principal to call sts:AssumeRole.
Explanation
The trust policy controls who can assume the role, and Lambda must be trusted. Missing log permissions cause logging failures, not assume-role errors. Invoke permission is unrelated to creation. Role names have no required prefix.
Question 3
A backend service with no user context needs to call an API protected by a Cognito user pool authorizer that requires the orders/read scope. How should the service obtain a token?
- Create a user pool app client with a client secret, define a resource server with the orders/read scope, and use the client credentials grant. — Correct
- Create a service user in the user pool and have the service sign in with that user's password by using the USER_PASSWORD_AUTH flow.
- Use an identity pool unauthenticated role to obtain AWS credentials, and send the access key ID as the bearer token.
- Generate an API key in API Gateway and send it in the Authorization header in place of a Cognito token.
Correct answer
Create a user pool app client with a client secret, define a resource server with the orders/read scope, and use the client credentials grant.
Explanation
The client credentials grant issues access tokens with custom scopes for machine-to-machine calls. A shared service user is a password to manage. AWS credentials are not Cognito tokens. API keys are not accepted by a Cognito authorizer.
Question 4
After a user confirms an account in a Cognito user pool, the application must create a profile record in DynamoDB. Which solution meets this requirement with the LEAST custom infrastructure?
- Configure a pre authentication Lambda trigger that writes the profile record.
- Configure an EventBridge rule on the CloudTrail ConfirmSignUp event.
- Have the client app call the profile API after the user signs in.
- Configure a post-confirmation Lambda trigger that writes the profile record. — Correct
Correct answer
Configure a post-confirmation Lambda trigger that writes the profile record.
Explanation
The post-confirmation trigger runs once, right after confirmation. Pre authentication runs on every sign-in. CloudTrail-based rules add latency and setup. A client call can be skipped or fail.
Question 5
A team wants to replace a broad IAM policy on a Lambda function's role with a least-privilege policy based on the actions the function actually used over the last 90 days. Which AWS feature should the team use?
- IAM Access Analyzer policy generation based on AWS CloudTrail activity. — Correct
- The IAM credential report for the account.
- AWS Trusted Advisor security checks that list unused permissions for each IAM role.
- AWS Config managed rules that evaluate the permissions attached to each IAM role.
Correct answer
IAM Access Analyzer policy generation based on AWS CloudTrail activity.
Explanation
Access Analyzer can generate a policy from the actions recorded in CloudTrail. Trusted Advisor, the credential report, and Config do not build a policy from actual usage.
Question 6
A company uses AWS KMS to encrypt sensitive fields before writing them to DynamoDB. A new requirement says that a field encrypted for one customer must fail to decrypt if it is copied into another customer's record. How should the developer implement this?
- Encrypt the whole DynamoDB table with an AWS owned key instead of a customer managed key.
- Create a separate KMS alias for each customer that points to the same KMS key, and encrypt each customer's fields by using that customer's alias.
- Pass an encryption context that contains the customer ID on Encrypt and require the same context on Decrypt. — Correct
- Enable automatic key rotation on the KMS key so that each customer's fields are encrypted with a different version of the key material.
Correct answer
Pass an encryption context that contains the customer ID on Encrypt and require the same context on Decrypt.
Explanation
An encryption context is bound to the ciphertext as additional authenticated data, so decryption fails if a different context is supplied. Aliases that point to the same key do not separate data. Rotation does not tie ciphertext to a customer. Table encryption does not protect individual fields.
Question 7
A developer has an IAM policy that allows s3:* on arn:aws:s3:::reports-bucket/*. The developer can download objects but receives AccessDenied when listing the bucket contents. What should the developer do?
- Add s3:ListBucket on the resource arn:aws:s3:::reports-bucket to the policy. — Correct
- Add s3:ListAllMyBuckets on the resource arn:aws:s3:::reports-bucket/* to the policy.
- Add a bucket ACL that grants the developer READ_ACP permission on the bucket.
- Change the resource to arn:aws:s3:::reports-bucket/*/* so that it covers all prefixes.
Correct answer
Add s3:ListBucket on the resource arn:aws:s3:::reports-bucket to the policy.
Explanation
ListBucket applies to the bucket ARN, not the object ARN, so the policy needs a resource without /*. ListAllMyBuckets lists all buckets in the account and uses the resource *. Adding more wildcards to the object ARN does not cover the bucket. READ_ACP lets you read ACLs, not list objects.
Question 8
A security policy requires that all requests to an S3 bucket use HTTPS. Requests over HTTP must be rejected. What should the developer do?
- Enable default encryption on the bucket with SSE-S3 so that every object is encrypted.
- Add a bucket policy statement that denies all S3 actions when aws:SecureTransport is false. — Correct
- Enable S3 Object Lock in governance mode so that objects cannot be read without TLS.
- Add a CORS configuration to the bucket that allows only https:// origins to send requests.
Correct answer
Add a bucket policy statement that denies all S3 actions when aws:SecureTransport is false.
Explanation
The aws:SecureTransport condition identifies non-TLS requests, and a deny blocks them. Default encryption protects data at rest, not in transit. Object Lock prevents deletion. CORS applies only to browser cross-origin requests.
Question 9
A REST API in API Gateway must allow only users who are signed in to an Amazon Cognito user pool. The developer wants API Gateway to validate tokens without writing or maintaining authorization code. Which authorization method should be used?
- A Cognito user pool authorizer on the API methods. — Correct
- AWS_IAM authorization with Signature Version 4 requests.
- An API key that is required by a usage plan on the stage.
- A Lambda authorizer that validates the JWT signature.
Correct answer
A Cognito user pool authorizer on the API methods.
Explanation
A Cognito user pool authorizer validates the tokens natively. A Lambda authorizer requires custom code. IAM authorization needs AWS credentials, not user pool tokens. API keys identify clients for usage plans and are not an authentication mechanism.
Question 10
An application uses a Cognito user pool. Only users with an email address in the company's domain may register, and those users must be confirmed automatically. What should the developer do?
- Add a pre token generation Lambda trigger that blocks tokens for users who registered with other domains.
- Add a pre sign-up Lambda trigger that rejects other domains and sets autoConfirmUser and autoVerifyEmail for the company domain. — Correct
- Add a post-confirmation Lambda trigger that deletes users from other domains and confirms company users with the AdminConfirmSignUp API.
- Enable self-registration only for the company domain in the user pool's sign-up attribute settings.
Correct answer
Add a pre sign-up Lambda trigger that rejects other domains and sets autoConfirmUser and autoVerifyEmail for the company domain.
Explanation
The pre sign-up trigger runs before the user is created and can reject or auto-confirm the user. A post-confirmation trigger runs too late. Blocking tokens still creates accounts. There is no built-in domain restriction setting.