All AWS exams
Free DVA-C02 practice test: 30 questions with answers
30 original questions for AWS Certified Developer - Associate, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
- Real exam
- 65 questions, 130 min
All 30 DVA-C02 questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Development with AWS Services (8 questions)
Question 1
A Lambda function must read items from a DynamoDB table and call an external API. The function needs its own access to DynamoDB, with no hard-coded keys. What should the developer configure?
- AAn execution role for the function with a policy that allows the needed DynamoDB actions
- BA long-lived IAM access key pair stored in the function's environment variable
- CA bucket policy attached to the DynamoDB table that grants object-level read and write actions to callers
- DA resource-based policy on the API Gateway REST API that permits invoke requests but no table access
Show answer and explanationHide answer
Correct answer: AA Lambda execution role provides temporary credentials scoped to the permitted DynamoDB actions, without stored keys. Environment-variable keys are long-lived secrets, and bucket policies and gateway policies do not grant table access.
Question 2
A developer needs an application to send a message to an SQS queue and have many consumers process messages independently, each with its own copy. Which pattern fits best?
- ASend the message directly to each consumer over HTTP
- BWrite the message to a shared file on EC2
- CUse a single standard queue with one consumer that forwards copies
- DPublish to an SNS topic and subscribe one SQS queue per consumer
Show answer and explanationHide answer
Correct answer: DFan-out from SNS to multiple SQS queues gives each consumer its own copy and independent processing. Direct HTTP calls couple the producer to each consumer, shared files do not notify consumers, and a single consumer does not give independent copies.
Question 3
A DynamoDB table is queried by customer ID and by order date. The developer wants to query by order date without scanning the table. What should be added?
- AA larger provisioned write throughput on the table
- BA global secondary index with order date as the partition key
- CA full table scan with a filter expression on each query
- DA second table with the same partition key and attribute
Show answer and explanationHide answer
Correct answer: BA global secondary index with the order date as key supports efficient queries on that attribute. Capacity changes do not add access paths, scans read the whole table, and duplicating the table creates synchronization work.
Question 4
A developer wants to process a large file uploaded to S3 by invoking a function automatically. Which configuration triggers the function on each new object?
- AAn EventBridge cron rule that polls the S3 bucket with ListObjectsV2 for new objects every minute
- BAn S3 event notification that invokes the Lambda function for object creation events
- CA Lambda layer packaged with the bucket names and the object key prefix as static configuration values
- DThe interface VPC endpoint attached to the function's subnets for private routing to Amazon S3
Show answer and explanationHide answer
Correct answer: BS3 event notifications can invoke Lambda for object creation events, which starts the function as each file arrives. Polling adds delay and cost, VPC endpoints do not trigger functions, and layers hold code or libraries.
Question 5
A Lambda function is invoked frequently and most of its time is spent in cold starts caused by heavy initialization code. Which change reduces latency for user requests?
- AIncrease the function timeout to 15 minutes so that slow initialization finishes within each request's time budget
- BAdd more code to the handler so that each call performs extra preparation, logging and cache warming work per invocation
- CMove expensive initialization outside the handler so it runs once per execution environment, and consider provisioned concurrency
- DDisable the function's logging by removing the CloudWatch Logs permissions from its execution role and turning off active X-Ray tracing entirely
Show answer and explanationHide answer
Correct answer: CInitialization outside the handler is reused across warm invocations, and provisioned concurrency keeps environments ready. Adding work to the handler, longer timeouts and disabled logs do not reduce cold-start latency.
Question 6
An API built with API Gateway calls a Lambda function. Clients must be able to call the API only with a valid token from the company's identity provider. Which feature enforces this?
- AA public API with no authorizer and a shared secret passed as query parameter in the URL
- BA Lambda authorizer or an Amazon Cognito user pool authorizer on the API methods
- CA CloudFront cache behavior setting with no token checks at the edge
- DAn S3 bucket policy on the API's stage response cache granting s3:GetObject to anonymous callers
Show answer and explanationHide answer
Correct answer: BAuthorizers on API Gateway methods validate tokens before the request reaches the function, which enforces the requirement. A secret in the URL, cache settings and bucket policies do not validate caller identity.
Question 7
A developer wants to store and retrieve application configuration values such as feature flags, and change them without redeploying the application. Which service is designed for this?
- AAmazon Glacier Deep Archive
- BAWS CodeCommit
- CAWS AppConfig
- DAmazon Route 53
Show answer and explanationHide answer
Correct answer: CAWS AppConfig manages configuration and feature flags with validation and controlled rollout, and applications can pick up changes without redeployment. The other services archive data, host code repositories and provide DNS.
Question 8
A developer needs a Lambda function to call another Lambda function and wait for the result before continuing, and both must complete within the same request. Which invocation type is appropriate?
- AAsynchronous invocation (Event) with no result
- BSending an email with input data
- CPolling an S3 bucket for a reply file
- DSynchronous invocation (RequestResponse)
Show answer and explanationHide answer
Correct answer: DA synchronous invocation waits for the callee to finish and returns its response, which fits a wait-for-result pattern. Asynchronous invocation returns immediately, while polling a bucket or sending email are indirect and fragile.
Security (8 questions)
Question 9
Which two configurations let a browser-based app on one domain call an API on another domain safely? (Choose two.)
- ACORS headers that allow only the web app's origin
- BAllowing every origin with credentials for every method
- CPre-flight OPTIONS responses that list the allowed methods and headers
- DDisabling HTTPS for faster calls
- EA bucket policy granting the browser access
Show answer and explanationHide answer
Correct answer: A, CReturning CORS headers for the app's origin and answering pre-flight OPTIONS requests with the allowed methods and headers lets the browser make the call safely. Allowing every origin with credentials, disabling HTTPS and bucket policies do not provide that safe, scoped access.
Question 10
A Cognito user pool is used to sign in users of a mobile app, and the app must call an API Gateway API with the user's identity. Which token should the API validate?
- AA random string the mobile app generates and keeps on the handset
- BThe ID token or access token issued by the user pool for the authenticated user
- CA static API key hard-coded in the app and shipped in every build
- DThe user's password sent in the request header on each API call
Show answer and explanationHide answer
Correct answer: BThe user pool issues ID and access tokens after authentication, and the API can validate them with a Cognito authorizer. Random strings, passwords sent per request and embedded API keys do not prove the authenticated user's identity.
Question 11
A developer wants to ensure that an S3 object uploaded by an application is encrypted with a customer managed KMS key. Which configuration achieves this?
- AUpload the object without encryption and rely on the bucket's policy and ACL grants
- BSpecify the KMS key ID in the upload request, or set the bucket's default encryption to that key
- CEncrypt the object client-side with a password stored in the object's key name as a prefix on each upload
- DUse the root account access key for every upload to the bucket, kept in the build script
Show answer and explanationHide answer
Correct answer: BSpecifying the KMS key on upload, or setting it as the bucket default, applies SSE-KMS with the customer managed key. Unencrypted uploads, passwords in object names and root keys do not meet the requirement.
Question 12
A Lambda function reads a secret from Secrets Manager. The function's execution role has permission to read the secret, but the call fails because the secret is encrypted with a customer managed key. What is missing?
- APermission for the execution role to use the customer managed KMS key for decryption
- BA VPC interface endpoint for CloudWatch Logs in the function's private subnet, with DNS enabled
- CA new function alias that points to the latest published version of the function code and its variables
- DA higher function timeout of 15 minutes with a larger memory allocation for each invocation
Show answer and explanationHide answer
Correct answer: AA customer managed key requires the role to have kms:Decrypt permission through the key policy or IAM, in addition to permission to read the secret. Timeouts, endpoints and aliases do not address decryption permission.
Question 13
A developer must log every AWS API call made in the account to a central S3 bucket for audit. Which service should be enabled?
- AAWS CloudTrail with a trail that delivers logs to the bucket
- BAWS Budgets cost reports for monthly spending alerts
- CAmazon CloudFront access logs for distribution requests
- DAmazon Polly text-to-speech service for voice output
Show answer and explanationHide answer
Correct answer: ACloudTrail records API activity across the account and can deliver logs to S3 for central retention. CloudFront logs cover content requests, Budgets tracks cost, and Polly is a speech service.
Question 14
A Lambda function receives user input that is inserted into a SQL query. Which change reduces the risk of SQL injection?
- ARemove input validation and sanitization checks from the handler to keep the code simple and fast
- BUse parameterized queries or prepared statements instead of string concatenation
- CLog the raw query and its user-supplied parameters to a publicly readable file for later review
- DIncrease the function's memory size and ephemeral storage to speed up input parsing logic
Show answer and explanationHide answer
Correct answer: BParameterized queries keep user input separate from the query structure, which prevents injection. Removing validation, adding memory and publishing logs do not address injection.
Question 15
A developer must store a configuration file that contains a database password for an ECS task. The password must not appear in the task definition in plain text. Which option meets this?
- AReference the secret from Secrets Manager or Systems Manager Parameter Store as a secret in the task definition
- BCommit the password to the container image during the build so every task that pulls it can read the value in /app/config/db.yaml
- CPut the password in the environment variable list in plain text for the production database user, which anyone with read access can view
- DPrint the password in the container's startup logs at every boot so the value is captured by CloudWatch Logs and retained for auditing
Show answer and explanationHide answer
Correct answer: AECS task definitions can reference secrets from Secrets Manager or Parameter Store so the value is injected at runtime and not stored in plain text. Plain environment variables, images and logs expose the password.
Question 16
Which two practices reduce the risk of exposing secrets in a serverless application? (Choose two.)
- AStore secrets in Secrets Manager or Parameter Store and retrieve them at runtime
- BPut secrets in the function's environment variables in plain text for every environment
- CCommit a .env file with production credentials to the repository
- DScan the code repository for committed secrets before merging
- EPrint the decrypted secret in each log line for debugging
Show answer and explanationHide answer
Correct answer: A, DRetrieving secrets at runtime from a managed store keeps them out of code and configuration, and scanning catches accidental commits. Plain environment variables, committed env files and logged secrets all expose values.
Troubleshooting and Optimization (7 questions)
Question 17
A Lambda function times out intermittently when calling an external API. The developer wants to find which downstream call is slow inside each invocation. Which tool gives this detail?
- AAWS Trusted Advisor checks for cost optimization and security
- BAmazon QuickSight dashboard for request counts
- CAWS X-Ray tracing with the function's tracing enabled
- DAWS Pricing Calculator estimate for monthly cost
Show answer and explanationHide answer
Correct answer: CX-Ray traces show the timing of each segment and subsegment within a request, including external calls. Pricing, dashboards and advisory checks do not show per-call timing.
Question 18
A developer needs to find the cause of a Lambda error in logs from the last hour that contain a specific request ID. Which CloudWatch feature is most efficient?
- AScrolling through the log stream by hand looking for the request ID
- BDeleting the log group and reproducing the issue in staging today
- CEnabling a new custom metric for Lambda CPU utilization
- DCloudWatch Logs Insights query filtering on the request ID
Show answer and explanationHide answer
Correct answer: DLogs Insights can filter log events by a field such as request ID over a time window quickly. Manual scrolling is slow, deleting logs destroys evidence, and CPU metrics do not locate a specific request.
Question 19
A DynamoDB query returns throttling errors during a traffic spike, even though the table's total capacity appears sufficient. What is the most likely cause?
- AThe application uses a single region endpoint for writes and reads
- BThe table has too few attributes per item, so each query returns the full item at peak
- CThe function's memory is too low for the batch size used
- DA hot partition key that receives a disproportionate share of requests
Show answer and explanationHide answer
Correct answer: DThrottling on a single partition can happen even when total capacity looks sufficient, because each partition has its own throughput limit. A key design with better distribution fixes this. Attribute counts, regions and memory are not the usual cause.
Question 20
A developer wants to reduce the number of reads from DynamoDB for data that changes rarely and is requested often. Which service should be placed in front of the table?
- AAmazon SES for email delivery and bounce handling with a dedicated IP
- BDynamoDB Accelerator (DAX) for microsecond cached reads
- CAmazon Athena for ad hoc queries on S3 data files
- DAWS Backup for scheduled snapshots of EBS volumes and RDS databases
Show answer and explanationHide answer
Correct answer: BDAX is an in-memory cache for DynamoDB that reduces read latency and load for frequently read items. The other services serve email, backup and ad hoc analytics.
Question 21
An application using the AWS SDK sometimes receives throttling errors from an API. The developer wants the SDK to retry with increasing delays rather than failing immediately. What should be used?
- ASending every request at once in parallel without client-side limits
- BA loop that retries immediately with no delay between each attempt
- CDisabling retries so that the failure is visible to the calling code
- DThe SDK's built-in retry with exponential backoff and jitter
Show answer and explanationHide answer
Correct answer: DExponential backoff with jitter spreads retries over time and reduces the chance of repeated throttling. Immediate retries and unlimited parallel bursts make throttling worse, and disabling retries pushes failures to users.
Question 22
A Lambda function's cost has risen sharply after a change. The function now processes each message separately from a queue, and the messages are small. Which change reduces the number of invocations?
- AIncrease the SQS batch size and set a batching window for the event source mapping
- BTurn off the event source mapping for the queue during peak hours so that messages wait in the queue
- CIncrease the function timeout to 15 minutes and raise the reserved concurrency for the queue
- DUse a separate Lambda function for each message with its own event source mapping in the queue
Show answer and explanationHide answer
Correct answer: ALarger batch sizes and batching windows let one invocation process many messages, which lowers invocation count and cost. Disabling the mapping stops processing, longer timeouts do not reduce invocations, and separate functions multiply them.
Question 23
A developer wants to measure the latency of an API as seen by clients around the world, with caching at edge locations. Which service provides the most useful metrics?
- AAWS Backup job history for each scheduled vault recovery point and restore test
- BAmazon Polly usage metrics for characters synthesized per voice and region
- CAmazon CloudFront metrics with real-time logs for the distribution
- DAmazon Connect call logs for contact flows and queue wait times per region
Show answer and explanationHide answer
Correct answer: CCloudFront metrics and real-time logs show request and latency data from edge locations for a distribution. The other services are unrelated to API latency.
Deployment (7 questions)
Question 24
A team deploys a Lambda function with a new version every week and wants to shift 10 percent of traffic to the new version first, then increase it after checks pass. Which feature supports this?
- ALambda aliases with weighted routing between two versions
- BEditing the function code directly in the production console today
- CDisabling the function's logs during each deployment
- DDeleting the old version before deploying the new one in the account
Show answer and explanationHide answer
Correct answer: AAliases with weighted routing shift a percentage of invocations to a new version and allow gradual promotion. Deleting old versions, live editing and disabling logs remove safeguards.
Question 25
A CodeBuild project must build a container image and push it to Amazon ECR. The build should not contain long-term AWS keys. Which configuration is correct?
- AMake the ECR repository public so that anonymous users and other accounts can pull images
- BStore the account's access keys in the buildspec file as environment variables for builds
- CShare the root account password with the CodeBuild project through a shared env file
- DUse the CodeBuild service role with permission to push to the ECR repository
Show answer and explanationHide answer
Correct answer: DThe CodeBuild service role supplies temporary credentials scoped to the ECR push permission, which avoids stored keys. Keys in buildspec, root passwords and public repositories all create security problems.
Question 26
A developer uses AWS CodeDeploy to update an application on an EC2 fleet. A deployment must stop automatically if health checks fail on the new instances. Which setting enables this?
- ADeleting the appspec.yml file from the revision bundle and redeploying
- BRunning the deployment on every instance at once with no health checks
- CTurning off the health check on the load balancer and its target group
- DAutomatic rollback on deployment failure in the deployment group configuration
Show answer and explanationHide answer
Correct answer: DCodeDeploy can roll back automatically when a deployment fails, including when health checks fail, which limits the impact. Deleting the appspec file, disabling health checks and running all at once remove the safeguard.
Question 27
A team wants infrastructure defined in code and deployed through a pipeline that runs tests before any production change. Which AWS service combines source, build, test and deploy stages?
- AAmazon Cognito
- BAWS Glue
- CAWS CodePipeline
- DAmazon Lightsail
Show answer and explanationHide answer
Correct answer: CCodePipeline orchestrates source, build, test and deploy stages, which can include CodeBuild and CloudFormation. The other services provide identity, data integration and simple hosting.
Question 28
A serverless application needs different configuration values for dev and prod, and the team wants the template to remain the same for both. Which approach works best with AWS SAM?
- AMaintain two separate templates that are edited by hand for each environment and kept in sync manually
- BUse parameters in the template with per-environment parameter files or overrides at deploy time
- CStore the configuration in a shared spreadsheet and sync it by hand for every environment
- DHard-code the production values in the template and change them after deployment by hand through the console
Show answer and explanationHide answer
Correct answer: BParameters and per-environment overrides keep one template for both environments and avoid drift between two hand-edited versions. Hard-coded production values and spreadsheets are error-prone.
Question 29
Which two statements about AWS SAM and CloudFormation are correct? (Choose two.)
- ASAM templates are transformed into CloudFormation templates at deployment time
- BChanges to a CloudFormation stack can be previewed with a change set before execution
- CSAM can deploy resources only in the console and not from the CLI
- DCloudFormation stacks cannot be updated once created
- ESAM requires a manual step to create each Lambda function
Show answer and explanationHide answer
Correct answer: A, BSAM extends CloudFormation and transforms its templates into standard CloudFormation during deployment, and change sets preview updates before they run. SAM supports the CLI, stacks can be updated, and SAM creates functions automatically from the template.
Question 30
A developer must roll back a CloudFormation stack update that failed in the middle. The stack is in the UPDATE_ROLLBACK_FAILED state. What is the typical next step?
- ADelete the stack immediately from the console without checking the state of each resource first
- BCreate a new stack with the same name while the old one is still in place and running
- CFix the cause of the failure, then continue the rollback or skip the resources that cannot roll back
- DIgnore the state because the stack is still usable for application traffic and the console shows the stack as healthy
Show answer and explanationHide answer
Correct answer: CA failed rollback usually needs the underlying cause fixed, after which the rollback can continue or specific resources can be skipped. Deleting without checking, duplicating the name and ignoring the state can leave resources orphaned or the stack inconsistent.
Want more DVA-C02 questions?
The full bank has 100 questions with answers and explanations, as a PDF, an online practice exam, or both.
Both formats together. The best value.
Instant access after payment, with 90 days of updates. Checkout is on our store, AIExamCerts.