# Free DVA-C02 practice questions

> 10 free DVA-C02 practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/aws-dva-c02/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/aws-dva-c02/

### Question 1 of 10

A Node.js Lambda handler is declared as exports.handler = async (event) => { s3.putObject(params).promise(); return 'done'; }. The function reports success, but objects often never appear in S3. What is wrong?

- A. Async handlers also need the callback parameter; without calling callback(null), Lambda discards in-flight network requests
- B. The handler must return an object with statusCode and body; a plain string return makes Lambda cancel pending SDK calls
- C. The execution role lacks s3:PutObject, and Lambda swallows AccessDenied errors from un-awaited SDK calls instead of failing the invocation
- D. The putObject promise is never awaited, so the handler resolves and the environment freezes before the request finishes

**Answer:** D

**Explanation:** In an async handler, returning before awaiting the promise ends the invocation, and the execution environment is frozen, so pending work may never complete. Async handlers signal completion by resolving their promise; adding a callback is not needed and mixing the two styles is discouraged. A missing s3:PutObject permission would surface as a rejected promise and a consistent failure, not intermittent success, and the root problem is still that nothing awaits it. The statusCode/body shape only matters for proxy integrations and has no effect on in-flight SDK requests.

### Question 2 of 10

A Lambda function charges customer cards and is triggered from a queue that delivers messages at least once. The team must guarantee a card is never charged twice for the same payment request. What is the best approach?

- A. Set maxReceiveCount to 1 in the queue's redrive policy so a payment message is never delivered to the function twice
- B. Increase the function timeout and the queue's visibility timeout so a message is not redelivered while its charge is in progress
- C. Move to an SQS FIFO queue with content-based deduplication so duplicate payment messages are dropped before the function sees them
- D. Use the payment request ID as an idempotency key stored with a DynamoDB conditional write, returning the saved result on repeats

**Answer:** D

**Explanation:** An idempotency key stored with a conditional write lets the function detect a repeat and return the earlier result instead of charging again, which is the pattern implemented by Powertools for AWS Lambda idempotency. A maxReceiveCount of 1 sends any failed message straight to the dead-letter queue, losing legitimate retries, and does not stop at-least-once duplicates. FIFO deduplication only covers a 5-minute window on the producer side and does not help when the consumer is retried after partially processing. Longer timeouts reduce but do not eliminate redelivery.

### Question 3 of 10

A worker polls an Amazon SQS standard queue and takes about 90 seconds to process each message. The queue uses the default visibility timeout. The team sees many messages processed twice. What is the most likely fix?

- A. Increase the queue's visibility timeout to longer than the maximum processing time, for example 2 minutes
- B. Enable long polling by setting ReceiveMessageWaitTimeSeconds to 20 so workers receive fewer empty and duplicate responses
- C. Reduce the message retention period to 60 seconds so a message that is not deleted quickly expires instead of being delivered again
- D. Add a dead-letter queue with maxReceiveCount set to 1

**Answer:** A

**Explanation:** The default visibility timeout is 30 seconds, so a message becomes visible again while the first worker is still processing it and another worker receives it. Setting the timeout above the processing time (or extending it with ChangeMessageVisibility) prevents this. Long polling reduces empty receives but does not affect redelivery. A DLQ with maxReceiveCount 1 moves messages aside after a redelivery instead of preventing it. A 60-second retention period is below the 90-second processing time and would delete messages that have not yet been processed.

### Question 4 of 10

A Cognito user pool has groups named Admins and Viewers. Users federate through a Cognito identity pool to call AWS APIs directly. Admins must receive an IAM role with write permissions, and Viewers a read-only role. How should this be configured?

- A. Assign an IAM role to each user pool group and set the identity pool to choose the role from the token (cognito:preferred_role)
- B. Use one authenticated role whose policies check the cognito:groups claim in a condition on each AWS service call
- C. Tag both IAM roles with the group name and enable attribute-based access control on the identity pool to pick the role
- D. Create a separate identity pool for Admins and for Viewers and let the client choose which pool to sign in to

**Answer:** A

**Explanation:** User pool groups can carry an IAM role, and the identity pool can choose the role from the token, so each user receives credentials matching their group. The cognito:groups claim is not available as an IAM condition key, so one role cannot distinguish groups that way. Letting the client pick an identity pool means any user could choose the admin pool. ABAC maps user attributes to principal tags used in policy conditions; it does not select between roles based on role tags.

### Question 5 of 10

An application encrypts records with AWS KMS and wants each ciphertext to be bound to the tenant it belongs to, so that a ciphertext for tenant A cannot be decrypted while claiming tenant B, and so that CloudTrail shows which tenant each decrypt was for. What should the developer use?

- A. Move each tenant to its own AWS account with a dedicated KMS key and cross-account roles
- B. Prepend the Base64-encoded tenant ID to each ciphertext and check it before calling Decrypt
- C. Pass an encryption context containing the tenant ID on both the Encrypt and Decrypt calls
- D. Create a KMS alias per tenant that points to the shared key and encrypt using that alias

**Answer:** C

**Explanation:** Encryption context is non-secret additional authenticated data: decryption fails unless the same context is supplied, and the context is recorded in CloudTrail. A prepended encoded ID is just application data that can be swapped, with no cryptographic binding. Separate accounts are a heavy architectural change the requirement does not need. Aliases are only names for a key, so ciphertext from any alias decrypts the same way and CloudTrail shows only the key.

### Question 6 of 10

An application in account A (111111111111) must read objects from an S3 bucket in account B. Account B's security team wants to control access through a role they own. Which setup is correct?

- A. Configure S3 Cross-Region Replication from the bucket in account B to a bucket in account A and have the application read the replica
- B. Create an IAM user in account B with S3 read permissions and store its access keys in Secrets Manager in account A for the app
- C. Add a bucket policy in account B that grants s3:GetObject to the account A root principal, with no role involved
- D. In account B, create a role with S3 read access that trusts account A; allow the app's role sts:AssumeRole on it and use the returned credentials

**Answer:** D

**Explanation:** Cross-account role assumption needs a trust policy on account B's role and sts:AssumeRole permission for the caller, after which the app uses temporary credentials, and account B controls access through the role it owns. A bucket policy granting account A works technically but bypasses the role the security team wants to own. IAM user keys are long-lived secrets held outside the owner's control. Replication copies the data instead of granting controlled access.

### Question 7 of 10

A team runs a containerized API on Amazon ECS with an Application Load Balancer. They want CodeDeploy blue/green deployments that shift traffic to the new task set and allow quick rollback. What is required?

- A. Run a second ECS cluster for each release and switch the Route 53 alias record from the old ALB to the new one
- B. Set the service's deployment controller to CODE_DEPLOY and give the ALB two target groups and a production listener
- C. Keep the ECS deployment controller with a rolling update, maximumPercent 200 and minimumHealthyPercent 100 for side-by-side tasks
- D. Add an appspec.yml with BeforeInstall and AfterInstall hooks and an EC2/On-Premises compute platform deployment group

**Answer:** B

**Explanation:** CodeDeploy blue/green for ECS requires the CODE_DEPLOY deployment controller, an ALB or NLB with two target groups, and listeners that CodeDeploy switches between the original and replacement task sets. A rolling update with the ECS controller replaces tasks in place and does not involve CodeDeploy. A second cluster with DNS changes is a manual process with slow, cache-dependent rollback. BeforeInstall and AfterInstall are EC2/on-premises hooks; ECS appspec files use hooks such as BeforeAllowTraffic and AfterAllowTraffic.

### Question 8 of 10

A company keeps internal npm packages that several CodeBuild projects must install, and also wants to proxy and cache packages from the public npm registry. Which service should the developer use?

- A. AWS Systems Manager Distributor packages shared across the CodeBuild projects' accounts
- B. AWS CodeArtifact with an external connection to the public npm registry
- C. An S3 bucket with static website hosting serving a mirrored npm registry index
- D. Amazon ECR private repositories with a pull through cache rule for registry.npmjs.org

**Answer:** B

**Explanation:** CodeArtifact is a managed artifact repository that hosts private packages and can proxy and cache public registries such as npmjs through an external connection, with npm configured via a login command. ECR stores OCI artifacts such as container images and its pull through cache does not support npm. A static S3 site is not an npm registry and does not proxy upstream packages. Distributor packages software for Systems Manager-managed instances.

### Question 9 of 10

A Lambda function with a 5-minute timeout consumes an SQS queue whose visibility timeout is 60 seconds. Many messages are processed twice and some end up in the dead-letter queue although processing succeeded. What should the developer change?

- A. Reduce the batch size to 1 so each invocation finishes well within the queue's 60-second visibility timeout
- B. Set the visibility timeout to at least six times the function timeout
- C. Switch to a FIFO queue so each message group is processed by only one invocation at a time
- D. Raise the redrive policy's maxReceiveCount to 100 so messages are retried more often before moving to the DLQ

**Answer:** B

**Explanation:** If the visibility timeout is shorter than processing time, messages reappear and are received again, inflating receive counts until they move to the DLQ; AWS recommends a queue visibility timeout of at least six times the function timeout. A batch size of 1 does not shorten a slow single message, which can still exceed 60 seconds. A higher maxReceiveCount hides the symptom while duplicates continue. FIFO queues have the same visibility timeout semantics.

### Question 10 of 10

An X-Ray trace shows that a Python Lambda function spends 150 ms in every invocation establishing a new connection to DynamoDB. The code creates boto3.client('dynamodb') inside the handler. What should the developer change?

- A. Create the client once outside the handler so warm invocations reuse it
- B. Switch from GetItem to a Scan with a filter so one request returns everything the function needs
- C. Raise the function timeout and memory so connection setup completes within each invocation
- D. Put DynamoDB Accelerator (DAX) in front of the table so lookups come from an in-memory cache

**Answer:** A

**Explanation:** Objects created during initialization persist across warm invocations, so the client and its HTTP connections are reused. A Scan reads far more data than GetItem and still creates a new client each time. More timeout or memory does not remove the per-invocation connection setup. DAX speeds reads, but the client would still be recreated every invocation and DAX requires its own client and VPC setup.

Ready for a timed run? Take the free 15-question DVA-C02 mini exam: https://devopscodelab.com/app/exams/aws-dva-c02/mini/

DevOpsCode Lab is not affiliated with AWS. DVA-C02 and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
