Amazon

DVA-C02 Free Practice Questions — Page 13

Question 122

A developer is working on an application that will be deployed on AWS. The developer needs to test and debug the code locally. The code is packaged and stored in an Amazon S3 bucket. How can the developer test and debug the code locally with the LEAST amount of configuration?

A. Create an application and a deployment group in AWS CodeDeploy. For the compute platform, specify the local machine as the individual instance for the deployment. For the repository type, specify that the application is stored in Amazon S3. Start the deployment to test on the local machine.
B. Create a repository in AWS CodeArtifact. Publish the application code package to the repository. Before deployment, create an upstream repository to test and validate the code.
C. Create a build project in AWS CodeBuild. In AWS CodePipeline, add a CodeBuild test action by adding a stage and an action. For the action provider, specify a CodeBuild test and the build project. View the build log to see the test results.
D. Install the AWS CodeDeploy agent locally to validate the deployment package. Run the codedeploy-local command. Specify the S3 bucket where the code package is located by using the --bundle-location option.
Show Answer
Correct Answer: D
Explanation:
AWS CodeDeploy supports local validation of deployment bundles using the CodeDeploy agent and the codedeploy-local command. This allows a developer to test and debug a deployment package stored in Amazon S3 on a local machine with minimal configuration. The other options either involve AWS-managed CI/CD services rather than local testing (CodeBuild/CodePipeline), misuse CodeDeploy deployment groups, or use CodeArtifact for package management rather than local debugging.

Question 123

A developer is creating a database of products. Queries for frequently accessed products must have retrieval times of microseconds. To ensure data consistency, the application cache must be updated whenever products are added, changed, or deleted. Which solution will meet these requirements?

A. Set up an Amazon DynamoDB database and a DynamoDB Accelerator (DAX) cluster.
B. Set up an Amazon RDS database and an Amazon ElastiCache for Redis cluster. Implement a lazy loading caching strategy with ElastiCache.
C. Setup an Amazon DynamoDB database that has an in-memory cache. Implement a lazy loading caching strategy in the application.
D. Set up an Amazon RDS database and an Amazon DynamoDB Accelerator (DAX) cluster. Specify a TTL setting for the DAX cluster.
Show Answer
Correct Answer: A
Explanation:
Amazon DynamoDB Accelerator (DAX) is a fully managed, write-through/read-through in-memory cache designed specifically for DynamoDB. It delivers microsecond read latency and automatically keeps the cache consistent by updating or invalidating cached items when writes (adds, updates, deletes) occur through DAX, satisfying the consistency requirement. ElastiCache with lazy loading does not automatically update the cache on writes, and DAX cannot be used with Amazon RDS.

Question 124

A gaming application stores scores for players in an Amazon DynamoDB table that has four attributes: user_id, user_name, user_score, and user_rank. The users are allowed to update their names only. A user is authenticated by web identity federation. Which set of conditions should be added in the policy attached to the role for the dynamodb:PutItem API call?

A.
B.
C.
D.
Show Answer
Correct Answer: A
Explanation:
Use IAM condition keys to restrict writes so an authenticated user can only operate on their own item and only the mutable attribute. The policy should use dynamodb:LeadingKeys mapped to the federated identity user ID (for example ${www.amazon.com:user_id} depending on the identity provider) to ensure the partition key matches the caller, and dynamodb:Attributes to allow only the user_name attribute to be written. This prevents modification of user_score and user_rank while allowing name updates.

Question 125

A developer hosts a static website on Amazon S3 and connects the website to an Amazon CloudFront distribution. The website uses a custom domain name that points to the CloudFront URL. The developer has set up a continuous integration and continuous delivery (CI/CD) pipeline. The pipeline automatically runs when changes occur in an AWS CodeCommit repository. The pipeline has a source stage and then a build stage. The build stage invokes an AWS CodeBuild project that references a buildspec.yml file. The buildspec.yml file builds the code and deploys the static files to the S3 bucket. The pipeline runs successfully, and the latest website files are visible in the S3 bucket and at the S3 website URL. However, when the developer accesses the website through the CloudFront domain, the updates are not reflected on the website. What should the developer configure the buildspec.yml file to do to resolve this issue?

A. Properly synchronize the objects in the S3 bucket with new files from the source stage.
B. Delete the previous website files in the S3 bucket and redeploy the website files.
C. Invalidate the file caches for the primary CloudFront distribution.
D. Modify the cross-origin resource sharing (CORS) policy of the S3 bucket and redeploy the website files.
Show Answer
Correct Answer: C
Explanation:
CloudFront caches objects at edge locations. Although the updated files are successfully deployed to the S3 bucket and are visible via the S3 website endpoint, CloudFront can continue serving cached versions until they expire. Adding a CloudFront invalidation step (for example, using the AWS CLI create-invalidation command) to the buildspec.yml ensures the edge caches are cleared so CloudFront fetches the latest content from S3.

Question 126

A company uses AWS to run its learning management system (LMS) application. The application runs on Amazon EC2 instances behind an Application Load Balancer (ALB). The application's domain name is managed in Amazon Route 53. The application is deployed in a single AWS Region, but the company wants to improve application performance for users all over the world. Which solution will improve global performance with the LEAST operational overhead?

A. Set up an Amazon CloudFront distribution that uses the ALB as the origin server. Configure Route 53 to create a DNS alias record that points the application's domain name to the CloudFront distribution URL.
B. Launch more EC2 instances behind the ALConfigure the ALB to use session affinity (sticky sessions). Create a Route 53 alias record for the ALB by using a geolocation routing policy.
C. Create an AWS Client VPN endpoint in the VPInstruct users to connect to the VPN to access the application. Create a Route 53 alias record for the VPN endpoint. Configure Route 53 to use a geolocation routing policy.
D. Deploy the application to multiple Regions across the world. Create a Route 53 alias record for the ALB by using a latency-based routing policy.
Show Answer
Correct Answer: A
Explanation:
Using Amazon CloudFront with the existing Application Load Balancer as the origin improves global performance by serving cached content from edge locations and accelerating delivery over the AWS global network, while requiring minimal architectural changes. Pointing the Route 53 alias record to the CloudFront distribution is the standard approach. The other options either do not meaningfully improve global performance (B), are inappropriate for public application access (C), or require a complex multi-Region deployment with higher operational overhead (D).

Question 127

A developer is creating a solution to track an account's Amazon S3 buckets over time. The developer has created an AWS Lambda function that will run on a schedule. The function will list the account's S3 buckets and will store the list in an Amazon DynamoDB table. The developer receives a permissions error when the developer runs the function with the AWSLambdaBasicExecutionRole AWS managed policy. Which combination of permissions should the developer use to resolve this error? (Choose two.)

A. Cross-account IAM role
B. Permission for the Lambda function to list buckets in Amazon S3
C. Permission for the Lambda function to write in DynamoDB
D. Permission for Amazon S3 to invoke the Lambda function
E. Permission for DynamoDB to invoke the Lambda function
Show Answer
Correct Answer: B, C
Explanation:
AWSLambdaBasicExecutionRole only provides CloudWatch Logs permissions. The Lambda function also needs permission to call S3 ListBuckets (s3:ListAllMyBuckets) and permission to write items to the DynamoDB table (such as dynamodb:PutItem or BatchWriteItem). No cross-account role is required, and neither S3 nor DynamoDB needs permission to invoke the Lambda because it runs on a schedule.

Question 128

A developer uses Amazon S3 Event Notifications to invoke AWS Lambda functions. The Lambda functions process images after the images are uploaded to S3 buckets. The developer has set up a development S3 bucket, a production S3 bucket, a development Lambda function, and a production Lambda function in the same AWS account. The developer notices that uploads to the development S3 bucket wrongly invoke the production Lambda function. The developer must prevent development data from affecting the production Lambda function. What should the developer do to meet these requirements?

A. Update the execution role for the production Lambda function. Add a policy that allows the execution role to read from only the production S3 bucket.
B. Update the S3 bucket policy for the production S3 bucket to invoke the production Lambda function. Update the S3 bucket policy for the development S3 bucket to invoke the development Lambda function.
C. Separate the development environment and the production environment into their own AWS accounts. Update the execution role for each Lambda function. Add a policy that allows the execution role to read from only the S3 bucket that is in the same account.
D. Separate the development environment and the production environment into their own AWS accounts. Add a resource policy to the Lambda functions to allow only S3 bucket events in the same account to invoke the functions.
Show Answer
Correct Answer: D
Explanation:
The issue is preventing development events from invoking the production Lambda. S3 invokes Lambda through the Lambda function's resource-based policy, not the Lambda execution role or the S3 bucket policy. The strongest and AWS-recommended isolation is to separate development and production into different AWS accounts, then configure each Lambda resource policy to allow invocation only from the S3 bucket in the same account. This prevents development bucket events from affecting the production function even if notification configuration is incorrect.

Question 129

A developer is building a microservice that uses AWS Lambda to process messages from an Amazon Simple Queue Service (Amazon SQS) standard queue. The Lambda function calls external APIs to enrich the SQS message data before loading the data into an Amazon Redshift data warehouse. The SQS queue must handle a maximum of 1,000 messages per second. During initial testing, the Lambda function repeatedly inserted duplicate data into the Amazon Redshift table. The duplicate data led to a problem with data analysis. All duplicate messages were submitted to the queue within 1 minute of each other. How should the developer resolve this issue?

A. Create an SQS FIFO queue. Enable message deduplication on the SQS FIFO queue.
B. Reduce the maximum Lambda concurrency that the SQS queue can invoke.
C. Use Lambda's temporary storage to keep track of processed message identifiers
D. Configure a message group ID for every sent message. Enable message deduplication on the SQS standard queue.
Show Answer
Correct Answer: A
Explanation:
An SQS standard queue provides at-least-once delivery and can deliver duplicate messages. If duplicate messages submitted within a short time window are causing duplicate inserts, using an SQS FIFO queue with deduplication enabled prevents duplicate messages with the same deduplication ID from being delivered within the 5-minute deduplication interval. A throughput requirement of 1,000 messages/second is supported by high-throughput FIFO queues when configured appropriately. Reducing Lambda concurrency does not eliminate duplicate delivery, Lambda temporary storage is not reliable for cross-invocation deduplication, and standard queues do not support message groups or queue-side deduplication.

Question 130

A developer is building various microservices for an application that will run on Amazon EC2 instances. The developer needs to monitor the end-to-end view of the requests between the microservices and debug any issues in the various microservices. What should the developer do to accomplish these tasks?

A. Use Amazon CloudWatch to aggregate the microservices' logs and metrics, and build the monitoring dashboard.
B. Use AWS CloudTrail to aggregate the microservices' logs and metrics, and build the monitoring dashboard.
C. Use the AWS X-Ray SDK to add instrumentation in all the microservices, and monitor using the X-Ray service map.
D. Use AWS Health to monitor the health of all the microservices.
Show Answer
Correct Answer: C
Explanation:
AWS X-Ray is purpose-built for distributed tracing of microservices. By instrumenting each service with the AWS X-Ray SDK, the developer can trace end-to-end requests across Amazon EC2-hosted microservices, visualize dependencies with the X-Ray service map, and identify latency, errors, and bottlenecks for debugging. CloudWatch focuses on metrics and logs, CloudTrail records AWS API activity, and AWS Health reports AWS service health rather than application-level tracing.

Question 131

A developer is building an application integrating an Amazon API Gateway with an AWS Lambda function. When calling the API, the developer receives the following error: Wed Nov 08 01:13:00 UTC 2017 : Method completed with status: 502 What should the developer do to resolve the error?

A. Change the HTTP endpoint of the API to an HTTPS endpoint.
B. Change the format of the payload sent to the API Gateway.
C. Change the format of the Lambda function response to the API call.
D. Change the authorization header in the API call to access the Lambda function.
Show Answer
Correct Answer: C
Explanation:
A 502 Bad Gateway error from Amazon API Gateway when invoking AWS Lambda commonly indicates that API Gateway received an invalid or malformed response from the Lambda function. Ensure the Lambda function returns the expected proxy integration response format (for example, including valid statusCode, headers if used, and a string body).

$19

Get all 553 questions with detailed answers and explanations

  • Instant download HTML + PDF delivered the moment payment clears.
  • Secure Stripe checkout we never see or store your card details.
  • 7-day refund if files are defective see our refund policy.