AWS Developer Associate (DVA-C02) · 26% practice allocation

AWS DVA-C02: Security Practice Questions

5 free sample questions from the Security domain, with answers and explanations. The full DVA-C02 bank has 275 questions across 5 domains. Questions are scenario-based and written from the official AWS exam guide.

1.

A developer is configuring an IAM role for an AWS Lambda function that needs to write items to an Amazon DynamoDB table and publish messages to an Amazon SNS topic. The security team requires least-privilege access. Which combination of actions should be included in the IAM policy attached to the Lambda execution role? (Select TWO)

  • A. iam:PassRole on the Lambda function's execution role ARN
  • B. dynamodb:PutItem on the specific DynamoDB table ARN✓ Correct
  • C. sns:* on arn:aws:sns:::*
  • D. sns:Publish on the specific SNS topic ARN✓ Correct
  • E. dynamodb:* on arn:aws:dynamodb:::*
Explanation

Least-privilege means granting only the specific actions needed on the specific resources. dynamodb:PutItem on the exact table ARN grants only the write permission needed for DynamoDB. sns:Publish on the exact topic ARN grants only the publish permission needed for SNS. dynamodb:* on a wildcard ARN is overly permissive, granting all DynamoDB actions across all tables — violating least-privilege. sns:* on a wildcard ARN is similarly over-permissive. iam:PassRole is used when a service needs to pass a role to another AWS service; it is not required for a Lambda function to write to DynamoDB or SNS.

2.

A company has an application running on Amazon EC2 instances in Account A. The application must assume an IAM role in Account B (cross-account) to read from an Amazon S3 bucket in Account B. A developer has created the role in Account B with the necessary S3 permissions. Which TWO configurations are required to enable the EC2 application to successfully assume the cross-account role? (Select TWO)

  • A. The trust policy of the role in Account B must allow sts:AssumeRole from the EC2 instance profile role ARN in Account A✓ Correct
  • B. Account A must enable VPC peering with Account B before cross-account role assumption is possible
  • C. The S3 bucket policy in Account B must explicitly allow the Account A EC2 instance profile role to perform s3:GetObject
  • D. The EC2 instance profile role in Account A must have an IAM policy that allows sts:AssumeRole on the Account B role's ARN✓ Correct
  • E. The developer must enable AWS Organizations Service Control Policies (SCPs) to allow cross-account STS calls between Account A and Account B
Explanation

Cross-account role assumption requires two-sided trust: (1) The role in Account B must have a trust policy that explicitly allows sts:AssumeRole for the principal in Account A (the EC2 instance profile role ARN). (2) The EC2 instance profile role in Account A must have a permissions policy that includes sts:AssumeRole on the Account B role ARN. Both conditions must be met. The S3 bucket policy in Account B does not need to explicitly allow the Account A role when using cross-account role assumption — once the role in Account B is assumed, the application acts as that Account B role, and the bucket policy only needs to allow the Account B role (or inherit account-level permissions). VPC peering is irrelevant to IAM/STS cross-account role assumption, which operates over the public STS API endpoint. SCPs are only relevant if the accounts are in AWS Organizations and there is a deny SCP in place; they are not required to enable cross-account calls.

3.

An AWS Lambda function processes messages from an Amazon SQS queue. The messages contain sensitive customer data. A compliance requirement mandates that the data must be encrypted at rest using a customer-managed AWS KMS key (CMK), and the Lambda function must be able to decrypt messages. Which permissions must be granted so that the Lambda function can process the encrypted SQS messages? (Select TWO)

  • A. Grant the Lambda execution role sqs:ReceiveMessage, sqs:DeleteMessage, and sqs:GetQueueAttributes on the SQS queue✓ Correct
  • B. Grant the Lambda execution role kms:CreateGrant on the CMK
  • C. Grant the SQS service principal kms:GenerateDataKey and kms:Decrypt on the CMK in the key policy✓ Correct
  • D. Grant the Lambda execution role kms:Decrypt on the CMK used to encrypt the SQS queue
  • E. Grant the Lambda execution role sqs:SendMessage on the SQS queue
  • F. Grant the Lambda execution role kms:GenerateDataKey on the CMK used to encrypt the SQS queue
Explanation

Two separate permission grants are needed for this architecture:

[A] The Lambda execution role needs SQS permissions (sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes) to poll and process messages. Without these, the Lambda service cannot retrieve messages from the queue on the function's behalf. [C] The SQS service itself (not Lambda) performs the KMS encryption and decryption of the queue's data key. The KMS key policy must grant the SQS service principal (sqs.amazonaws.com) kms:GenerateDataKey (to encrypt new messages) and kms:Decrypt (to decrypt messages for the consumer). Lambda does not call KMS directly for SQS SSE — SQS handles this transparently.

[B] Wrong – Lambda does not directly call KMS to decrypt SQS messages. SQS server-side encryption (SSE-SQS with KMS) is handled by the SQS service internally. Lambda needs SQS API permissions, not KMS permissions, for this use case. [D] Wrong – kms:GenerateDataKey is used for encrypting (producing) data. Lambda is a consumer, not a producer of the encryption. Even if Lambda needed KMS access, it would be Decrypt, not GenerateDataKey. [E] Wrong – sqs:SendMessage allows publishing messages to the queue, not consuming them. Lambda as an SQS consumer needs ReceiveMessage and DeleteMessage. [F] Wrong – kms:CreateGrant is an administrative KMS action used to create grants for delegating key usage; it is not needed for a standard Lambda-SQS processing pattern.

4.

A developer is building a REST API with Amazon API Gateway and needs to authenticate requests using JSON Web Tokens issued by an Amazon Cognito User Pool. The developer wants the least amount of custom code to implement this. Which authorization method should the developer configure on the API Gateway method?

  • A. A Cognito User Pool authorizer that references the User Pool ARN✓ Correct
  • B. An API Gateway resource policy that whitelists the Cognito User Pool ID
  • C. An IAM authorizer that uses AWS Signature Version 4 signed requests
  • D. A Lambda authorizer that validates the JWT signature using the Cognito JWKS endpoint
Explanation

A Cognito User Pool authorizer is the native, no-custom-code integration between API Gateway and Cognito User Pools. API Gateway automatically validates the JWT (ID or access token) against the specified User Pool, including signature verification and expiry checks, with no Lambda function required.

[A] Wrong – A Lambda authorizer can validate JWTs, but requires writing and maintaining custom validation code (fetching JWKS, verifying signature, checking claims), which contradicts the 'least custom code' requirement. [B] Wrong – IAM authorization uses AWS Signature Version 4, not JWTs. Clients would need AWS credentials, not Cognito tokens, making it unsuitable here. [D] Wrong – A resource policy controls which principals (e.g., AWS accounts, VPC endpoints) can invoke an API; it does not perform JWT authentication or interact with Cognito User Pools.

5.

A developer is implementing a multi-tenant SaaS application on AWS. Each tenant is represented by a separate IAM role. The application's central Lambda function must assume different tenant roles to perform actions in each tenant's account. The Lambda function has an IAM execution role. An engineer attempts to call STS AssumeRole for a tenant role but receives an 'Access Denied' error. Which THREE conditions must ALL be true for AssumeRole to succeed? (Select THREE)

  • A. The target tenant role must be in the same AWS account as the Lambda function
  • B. The Lambda function must be deployed inside a VPC with a NAT Gateway to reach the STS endpoint
  • C. The Lambda execution role's IAM policy must include sts:AssumeRole for the target tenant role ARN✓ Correct
  • D. The target tenant role's trust policy must list the Lambda execution role's ARN as a trusted principal with sts:AssumeRole allowed✓ Correct
  • E. The AWS Organizations SCP (if applicable) on the target account must not deny sts:AssumeRole✓ Correct
  • F. The target tenant role's permission policy must grant the Lambda execution role explicit access
Explanation

For STS AssumeRole to succeed, three conditions must all be satisfied:

[A] The calling principal's identity-based policy must explicitly Allow sts:AssumeRole for the target role ARN. Without this, the request is implicitly denied at the IAM evaluation stage for the caller. [B] The target role's trust policy (a resource-based policy) must explicitly trust the calling principal (the Lambda execution role ARN) and allow the sts:AssumeRole action. This is the 'who can assume me' definition of the role. [E] If the target account is governed by AWS Organizations, any SCP that applies a Deny on sts:AssumeRole (or restricts STS actions) will block the call, even if both the identity policy and trust policy allow it. SCPs are evaluated as an AND with identity-based policies in the policy evaluation logic.

[C] Wrong – Cross-account AssumeRole is a core feature of AWS STS and does not require same-account placement. The tenant role can be in a completely different AWS account. [D] Wrong – The target role's permission policy defines what the assumed role can DO (its permissions after assumption), not who can assume it. The trust policy governs who can assume the role; the permission policy is irrelevant to the AssumeRole authorization decision. [F] Wrong – Lambda functions do not need to be in a VPC to call AWS APIs, including STS. By default, Lambda functions run in an AWS-managed network with full access to AWS public endpoints. A VPC with NAT Gateway is only needed if the Lambda is inside a VPC and needs outbound internet/AWS API access.

Test yourself across every DVA-C02 domain

The free DVA-C02 practice test mixes about 20 questions weighted like the exam. The full 275-question bank adds instant grading, flashcards and a timed mock exam.

Study this domain

Security study guide (DVA-C02) →

Other DVA-C02 domains

← All AWS Developer Associate study resources