60 Practice Questions & Answers
You are deploying a Lambda function that needs to access a DynamoDB table in another AWS account. What is the most secure way to grant this access?
-
A
Create a single IAM user that has permissions across both accounts and share credentials
-
B
Use the AWS root account credentials to access the DynamoDB table directly
-
C
Store AWS access keys in the Lambda environment variables for the other account
-
D
Create an IAM role in the Lambda's account with permissions to DynamoDB, and configure a cross-account trust relationship with the DynamoDB table's resource policy
✓ Correct
Explanation
Cross-account access should use IAM roles with trust relationships, not hardcoded credentials. This follows the principle of least privilege and avoids exposing sensitive credentials.
Which AWS service allows you to create a fully managed message broker that supports MQTT and WebSocket protocols for real-time communication?
-
A
Amazon SNS
-
B
AWS IoT Core
✓ Correct
-
C
Amazon SQS
-
D
Amazon MQ
Explanation
AWS IoT Core is the managed service designed for IoT devices and real-time messaging using MQTT and WebSocket protocols. Amazon MQ provides traditional message brokers like ActiveMQ, while SNS and SQS are different messaging services.
You need to ensure that your API Gateway REST API only accepts requests from a specific IP address range. What is the most appropriate approach?
-
A
Use Lambda authorizers to check the source IP in the request context
-
B
Use API Gateway resource policies to restrict access by source IP
✓ Correct
-
C
Implement IP filtering at the CloudFront distribution level only
-
D
Configure security groups on the API Gateway endpoint
Explanation
API Gateway resource policies support IP-based access control directly at the API level. While Lambda authorizers and CloudFront can also help, resource policies are the most direct and native approach.
An application running on EC2 instances needs to write logs to CloudWatch Logs. The instances do not have public IP addresses. What is the most cost-effective solution?
-
A
Use the CloudWatch agent with local file buffering and manual uploads
-
B
Configure a NAT instance in a public subnet
-
C
Attach an Elastic IP address to each instance and route through a NAT gateway
-
D
Use a VPC endpoint for CloudWatch Logs
✓ Correct
Explanation
VPC endpoints for CloudWatch Logs provide private connectivity without requiring NAT gateways or public IP addresses, making this the most cost-effective solution for private instances.
When using AWS SAM (Serverless Application Model), which file defines the infrastructure and resources for your serverless application?
-
A
buildspec.yml
-
B
package.json
-
C
template.yaml
✓ Correct
-
D
serverless.yml
Explanation
AWS SAM uses a template.yaml (or template.json) file to define serverless resources. buildspec.yml is for CodeBuild, serverless.yml is for the Serverless Framework, and package.json is for Node.js projects.
Your Lambda function processes large JSON payloads from S3 and sometimes times out. You've already increased the timeout to 900 seconds. What should you consider next?
-
A
Implement concurrent Lambda invocations using SQS batching
-
B
All of the above are viable approaches depending on the situation
✓ Correct
-
C
Increase the Lambda memory allocation to improve CPU performance
-
D
Use S3 Select to filter data before processing in Lambda
Explanation
All three approaches can address timeout issues: more memory increases CPU, S3 Select reduces data transfer, and concurrent processing via SQS distributes the workload. The best choice depends on the specific bottleneck.
You want to trace requests across multiple AWS services in your application. Which AWS service provides this capability?
-
A
AWS X-Ray
✓ Correct
-
B
CloudWatch Metrics
-
C
Amazon EventBridge
-
D
AWS CloudTrail
Explanation
AWS X-Ray is designed for distributed tracing across microservices and AWS services. CloudWatch Metrics tracks performance data, CloudTrail logs API calls, and EventBridge routes events between services.
A DynamoDB table is receiving inconsistent read latencies. You notice that some items are much larger than others (50KB vs 1KB). What optimization should you consider?
-
A
Redesign the schema to split large items into multiple smaller items
✓ Correct
-
B
Configure DynamoDB global secondary indexes for all attributes
-
C
Enable DynamoDB Accelerator (DAX) to cache frequently accessed items
-
D
Increase the read capacity units for the table
Explanation
Large item sizes in DynamoDB consume more capacity and can cause hot partitions. Splitting items into smaller chunks reduces read latency and improves efficiency. DAX helps with caching but doesn't solve the underlying schema issue.
When deploying an application with AWS CodeDeploy, which configuration file specifies how the application should be deployed?
-
A
appspec.yaml
✓ Correct
-
B
codedeploy-config.xml
-
C
buildspec.yml
-
D
deployment.json
Explanation
CodeDeploy uses appspec.yaml (or appspec.json) to define deployment actions, lifecycle event hooks, and file locations. buildspec.yml is for CodeBuild, not CodeDeploy.
Your application uses Cognito user pools for authentication. You need to implement multi-factor authentication (MFA) for certain user groups. What is the best approach?
-
A
Use a separate Cognito identity pool to manage MFA settings per group
-
B
Configure MFA at the app client level and use the AdminInitiateAuth API
-
C
Enable MFA globally for all users in the user pool
-
D
Create a Lambda trigger for the pre-authentication event to enforce MFA conditionally
✓ Correct
Explanation
Lambda triggers in Cognito allow conditional logic to enforce MFA for specific groups. While you can enable MFA at the app client level (option A), Lambda triggers provide finer-grained control based on user attributes or groups.
You are using RDS with read replicas. An application query is running slowly even though you've added read replicas. What should you investigate first?
-
A
Replication lag between the primary and replica databases
-
B
The network latency between the application and the replica endpoint
-
C
Whether the read replica is in the same availability zone as the application
-
D
The query execution plan and database indexes on the replica
✓ Correct
Explanation
If a query runs slowly on a read replica, the first step is to analyze the query execution plan and verify proper indexing, as read replicas have identical schema and data. While replication lag and network latency are possible issues, schema/index problems are more common.
An API Gateway REST API endpoint is responding with 429 (Too Many Requests) errors. What is the primary cause?
-
A
The backend Lambda function is returning errors
-
B
The API key is invalid or expired
-
C
The API Gateway throttling limits have been exceeded
✓ Correct
-
D
CloudFront caching is misconfigured
Explanation
HTTP 429 responses indicate throttling due to exceeded request limits. API Gateway has default throttle limits (10,000 RPS) that can be adjusted. Backend errors would return 5xx codes, invalid API keys would return 403.
You need to process a large number of files from S3 in parallel. Which approach is most suitable for a serverless architecture?
-
A
Use S3 Batch Operations to process files directly without Lambda
-
B
Use an EC2 instance to poll S3 and dispatch work to Lambda functions
-
C
Implement a scheduled CloudWatch Events rule to scan S3 periodically
-
D
Create an S3 event notification that triggers a Lambda function for each object
✓ Correct
Explanation
S3 event notifications automatically trigger Lambda for each object creation, providing native parallel processing in a serverless manner. This scales automatically without managing compute resources.
When implementing API versioning in API Gateway, what is a drawback of using path-based versioning (e.g., /v1/resource vs /v2/resource)?
-
A
It can lead to duplicate code and maintenance overhead if not managed carefully
✓ Correct
-
B
It prevents CloudFront from caching API responses effectively
-
C
It increases API Gateway costs significantly
-
D
It requires creating separate API Gateway instances for each version
Explanation
Path-based versioning requires maintaining separate code paths or resources for each version, which can lead to duplication and maintenance challenges. Header-based versioning avoids this by using the same endpoint with different logic based on headers.
Your Lambda function needs to retrieve a secret from AWS Secrets Manager on every invocation. What optimization should you implement?
-
A
Create a new Secrets Manager client for each invocation
-
B
Store the secret in a Lambda environment variable instead
-
C
Use AWS Systems Manager Parameter Store instead, which is faster
-
D
Cache the secret value outside the Lambda handler function using global variables
✓ Correct
Explanation
Caching secrets in global variables (outside the handler) persists across warm invocations, reducing API calls to Secrets Manager. Environment variables are not suitable for secrets, and both services have similar performance.
You are deploying a containerized application using ECS with a load balancer. The application needs to scale based on CPU utilization. Which service should you use?
-
A
Elastic Beanstalk auto-scaling policies
-
B
CloudWatch alarms with SNS notifications to manually scale
-
C
EC2 Auto Scaling groups for the ECS cluster instances
-
D
Application Auto Scaling with an ECS service as the target
✓ Correct
Explanation
Application Auto Scaling targets ECS services directly and scales the number of tasks based on metrics like CPU utilization. EC2 Auto Scaling manages the cluster infrastructure, but Application Auto Scaling manages the service-level scaling.
A developer is using the AWS CLI to query DynamoDB and wants to filter results based on a complex condition. Which parameter should be used?
-
A
KeyConditionExpression
-
B
ScanFilter
-
C
ConditionExpression
-
D
FilterExpression
✓ Correct
Explanation
FilterExpression is used to filter results after a Query or Scan operation. KeyConditionExpression is for specifying partition and sort key conditions. ScanFilter is deprecated, and ConditionExpression is for put/update/delete operations.
You need to ensure that an S3 bucket can only be accessed through a specific CloudFront distribution. What should you configure?
-
A
S3 Block Public Access settings on the bucket
-
B
A VPC endpoint for S3 and restrict its usage
-
C
An S3 bucket policy that allows access only from the CloudFront distribution's Origin Access Identity (OAI)
✓ Correct
-
D
CloudFront geographic restrictions to match the S3 bucket region
Explanation
Using an Origin Access Identity (OAI) and configuring the bucket policy to allow access only from that OAI ensures all S3 content is served through CloudFront. Block Public Access prevents public access but doesn't restrict to CloudFront specifically.
When creating a Lambda function, which runtime would be appropriate for a Python application that uses compiled C extensions?
-
A
A custom Docker image runtime with the necessary C libraries and Python
✓ Correct
-
B
nodejs18.x with a Python subprocess
-
C
python3.11 with a custom Lambda layer containing compiled binaries
-
D
python3.11
Explanation
Custom Docker images allow full control over system libraries and compiled dependencies needed for C extensions. Standard Python runtimes have limited ability to include compiled native extensions, though Lambda layers can help in some cases.
An application uses SQS for asynchronous processing. Messages are occasionally processed more than once. What is the most likely cause?
-
A
The application is using FIFO queues instead of standard queues
-
B
The visibility timeout is too short, allowing the same message to be processed again
✓ Correct
-
C
The queue is configured with a dead-letter queue
-
D
The queue has long polling enabled
Explanation
If visibility timeout is too short, a message becomes visible again before the consumer finishes processing, causing duplicate processing. This is the most common cause of message duplication in SQS. Long polling is a retrieval mechanism and doesn't cause duplication.
You are designing a system where DynamoDB needs to perform transactions across multiple items. What constraint should you be aware of?
-
A
A single transaction can include at most 100 operations, but items can be across different partition keys
✓ Correct
-
B
Transactions cannot be used with DynamoDB Streams
-
C
All items in a transaction must be in the same partition key
-
D
Transactions are limited to a maximum size of 4 MB
Explanation
DynamoDB transactions (TransactWriteItems and TransactGetItems) support up to 100 operations and can span multiple partition keys. The 4 MB limit applies to individual items, and transactions work fine with Streams.
A Lambda function uses boto3 to interact with multiple AWS services. To optimize performance, what should you do with the boto3 clients?
-
A
Use environment variables to store pre-created client objects
-
B
Create clients at the module level outside the handler to reuse them across invocations
✓ Correct
-
C
Create clients inside the Lambda handler function for each invocation
-
D
Create a new client for each service call to ensure thread safety
Explanation
Creating boto3 clients at the module level (outside the handler) allows them to be reused across warm invocations, improving performance by reusing connections. The client should be created once and reused, not recreated per invocation.
You need to implement blue-green deployment for an application on EC2 using CodeDeploy. What is a key advantage of this approach?
-
A
It allows you to test the new version before switching traffic and enables quick rollback
✓ Correct
-
B
It reduces the number of EC2 instances required for your application
-
C
It automatically scales your EC2 instances during deployment
-
D
It eliminates the need for load balancers
Explanation
Blue-green deployment runs two identical production environments. You deploy to the inactive (green) environment, test it, then switch traffic. This allows quick rollback if issues are detected. It doesn't eliminate load balancers, auto-scaling, or reduce instance count needs.
An application deployed on Elastic Beanstalk is experiencing slow performance. The .ebextensions configuration contains commands that run during deployment. What could be the issue?
-
A
The RDS database connected to the application is undersized
-
B
The commands are running sequentially and blocking the deployment process
✓ Correct
-
C
The Elastic Beanstalk environment is using the wrong EC2 instance type
-
D
CloudWatch monitoring is not enabled for the environment
Explanation
Commands in .ebextensions run during deployment and can significantly increase deployment time if they're inefficient or sequential. This doesn't directly cause runtime performance issues, but long commands can delay environment availability. However, inefficient commands during deployment are the most likely cause here.
When using AWS Amplify to build a web application, which feature allows you to add authentication without writing backend code?
-
A
Amplify API with GraphQL
-
B
Amplify DataStore with encryption
-
C
Amplify Hosting
-
D
Amplify Authentication with Amazon Cognito integration
✓ Correct
Explanation
Amplify Authentication provides pre-built UI components and libraries that integrate with Amazon Cognito, enabling authentication without backend development. Other Amplify features provide different capabilities but not authentication specifically.
A developer is building a serverless application using AWS Lambda. The function needs to process messages from an SQS queue and occasionally experiences timeout errors. Which approach should be used to improve reliability?
-
A
Increase the Lambda memory allocation without changing timeout settings
-
B
Increase the Lambda function timeout and implement exponential backoff in the application code
-
C
Switch from SQS to SNS for better performance
-
D
Reduce the batch size of messages processed and configure a Dead Letter Queue for failed messages
✓ Correct
Explanation
Reducing batch size prevents processing too many messages at once, and a Dead Letter Queue captures failed messages for later analysis. This improves reliability and allows for proper error handling.
What is the primary purpose of AWS Secrets Manager in application development?
-
A
To monitor and log all API calls made to AWS services
-
B
To encrypt data at rest in DynamoDB tables
-
C
To securely store, rotate, and manage sensitive data such as database credentials and API keys
✓ Correct
-
D
To control access to AWS resources using IAM policies
Explanation
AWS Secrets Manager is specifically designed to store sensitive information, automatically rotate credentials, and manage secrets throughout their lifecycle.
A developer has deployed an API using Amazon API Gateway and AWS Lambda. The API requires authentication for certain endpoints. Which approach provides the most fine-grained control over authorization?
-
A
Configure API Gateway API keys for all endpoints
-
B
Use IAM roles for all API consumers regardless of their authentication method
-
C
Use API Gateway resource policies to block all requests by default
-
D
Implement custom authorizers in Lambda to evaluate tokens and determine access permissions
✓ Correct
Explanation
Lambda custom authorizers (authorizers) allow developers to implement sophisticated authorization logic that evaluates tokens and claims to make fine-grained access control decisions.
When deploying an application with AWS CloudFormation, a developer needs to pass environment-specific values to the template. What is the recommended way to handle different configurations for dev, staging, and production environments?
-
A
Store all environment values directly in the CloudFormation template and manually edit the template for each deployment
-
B
Use CloudFormation parameter files (JSON) that define environment-specific values for each stack
✓ Correct
-
C
Use Systems Manager Parameter Store exclusively for all configuration management
-
D
Store configuration in environment variables and reference them within the template using intrinsic functions
Explanation
CloudFormation parameter files allow developers to define environment-specific values separately from the template, enabling consistent deployments across different environments without template modification.
A Lambda function reads data from DynamoDB and occasionally encounters throttling errors. What is the most appropriate solution to handle this scenario?
-
A
Migrate the data to Amazon ElastiCache to reduce DynamoDB load
-
B
Switch the DynamoDB table to use a different partition key for better distribution
-
C
Immediately retry the operation using exponential backoff and jitter to avoid overwhelming the service
✓ Correct
-
D
Increase the DynamoDB table's provisioned throughput capacity immediately when errors occur
Explanation
Exponential backoff with jitter is the recommended approach for handling throttling as it allows the service to recover while spreading retry requests over time, preventing cascading failures.
A developer is using AWS X-Ray to trace requests through a distributed application. Which of the following best describes what X-Ray provides?
-
A
Automated remediation of application errors by triggering Lambda functions on detected anomalies
-
B
Centralized logging of all application events with full-text search capabilities
-
C
Real-time monitoring of CPU and memory utilization across all EC2 instances
-
D
A service map visualization showing how requests flow through application components and identifying performance bottlenecks
✓ Correct
Explanation
AWS X-Ray creates visual service maps that show how requests traverse through microservices and identifies latency issues, errors, and performance bottlenecks in distributed applications.
When using Amazon DynamoDB with a global secondary index (GSI), a developer notices that queries on the GSI are returning stale data. What is the likely cause?
-
A
The GSI has insufficient provisioned throughput compared to the base table
-
B
DynamoDB does not support querying GSIs with filter expressions
-
C
The partition key used in the GSI query was not updated before the read operation
-
D
GSIs are eventually consistent by default, so there may be a delay before writes are reflected in query results
✓ Correct
Explanation
Global secondary indexes in DynamoDB are eventually consistent, meaning there is a replication delay before writes to the base table appear in GSI results, unlike the base table which offers strong consistency options.
A developer needs to deploy a Node.js application using AWS Elastic Beanstalk and wants to run custom commands during the deployment process. Which approach should be used?
-
A
Include all custom commands in the application's package.json start script
-
B
Create .ebextensions configuration files with commands to execute at specified deployment phases
✓ Correct
-
C
Use AWS Systems Manager Run Command to execute scripts on all instances in the environment
-
D
Manually SSH into the Elastic Beanstalk instances and execute the commands after deployment completes
Explanation
AWS Elastic Beanstalk uses .ebextensions configuration files (YAML format) to define custom commands that run during different deployment phases, allowing automated setup without manual intervention.
A Lambda function is invoked asynchronously and occasionally fails. The developer wants to capture failed invocations for later analysis. What is the best solution?
-
A
Use Lambda Dead-Letter Queues (DLQ) to automatically send failed invocation payloads to SQS or SNS for later processing
✓ Correct
-
B
Enable Lambda function versioning to track which versions had failures
-
C
Configure CloudWatch Logs to capture all Lambda output and manually search for errors
-
D
Use CloudTrail to log all Lambda API calls and filter for InvokeFunction errors
Explanation
Lambda DLQs automatically capture failed asynchronous invocations and send them to an SQS queue or SNS topic, allowing developers to examine and reprocess failed messages.
When developing with AWS SDK for JavaScript, a developer needs to handle errors from an API call. Which error handling mechanism is most appropriate for managing both service-specific errors and generic failures?
-
A
Use try-catch blocks to capture all thrown errors uniformly without distinguishing error types
-
B
Use the AWS SDK's built-in retry mechanism which automatically handles all error scenarios
-
C
Configure CloudWatch alarms to notify when errors occur instead of handling them in code
-
D
Wrap SDK calls in promises and use .catch() to handle rejection, checking error code and message properties
✓ Correct
Explanation
AWS SDK errors in JavaScript have specific error properties like 'code' and 'message' that can be examined in promise .catch() handlers to distinguish between service errors and network failures for appropriate handling.
A developer is using Amazon S3 to store application data and needs to ensure that sensitive files are not accidentally exposed to the public. What combination of controls provides the strongest protection?
-
A
Set all S3 objects to use private ACLs without any policy-based controls
-
B
Use S3 encryption and rely on AWS to prevent public access automatically
-
C
Configure CloudFront distribution for all S3 access and restrict direct S3 access through VPC endpoints
-
D
Enable S3 Block Public Access settings at the account level and use bucket policies to explicitly deny public access
✓ Correct
Explanation
S3 Block Public Access combined with restrictive bucket policies provides defense-in-depth, preventing both accidental and intentional public exposure through multiple layers of protection.
What is the key difference between using SQS FIFO queues and standard SQS queues in terms of message ordering and delivery?
-
A
FIFO queues guarantee exactly-once processing and message ordering, while standard queues offer best-effort ordering and at-least-once delivery
✓ Correct
-
B
There is no practical difference; the choice depends only on cost considerations and message volume
-
C
FIFO queues have lower latency but do not support message attributes, while standard queues support all features
-
D
Standard queues provide better performance but lose all messages during failover, while FIFO queues replicate across regions automatically
Explanation
FIFO (First-In-First-Out) queues guarantee message ordering and exactly-once delivery semantics, while standard queues provide higher throughput with at-least-once delivery and best-effort ordering.
A developer has created an AWS Lambda function that connects to a relational database. The function experiences connection pool exhaustion under load. Which approach best addresses this issue?
-
A
Migrate the database to DynamoDB to eliminate the need for connection pools
-
B
Use RDS Proxy to manage database connections and implement connection pooling at the application layer, reducing the number of direct database connections
✓ Correct
-
C
Increase the Lambda function memory to allocate more resources for connection management
-
D
Create a new database connection for each Lambda invocation to avoid pool exhaustion
Explanation
Amazon RDS Proxy acts as a database proxy that manages connection pooling, allowing thousands of Lambda functions to share a smaller number of database connections, preventing exhaustion.
When using AWS CodePipeline to automate application deployment, a developer wants to perform manual approval before deploying to the production environment. How should this be configured?
-
A
Create an IAM policy that requires MFA for all production deployments and rely on that mechanism
-
B
Use a Lambda function triggered by CloudWatch Events to pause the pipeline execution
-
C
Configure AWS Systems Manager Automation documents to request approval via SNS notifications
-
D
Add an Approval action stage in the pipeline that requires manual approval before proceeding to the production deployment stage
✓ Correct
Explanation
AWS CodePipeline has a native Approval action that stops pipeline execution and sends notifications, requiring manual review and approval before the next stage executes.
A developer is building an application that uses Amazon Cognito for user authentication. Which statement best describes the purpose of Cognito User Pools versus Identity Pools?
-
A
User Pools handle user authentication and token generation, while Identity Pools provide temporary AWS credentials for accessing AWS services
✓ Correct
-
B
Both User Pools and Identity Pools serve the same purpose with minor naming differences
-
C
User Pools are deprecated in favor of using Identity Pools exclusively for modern applications
-
D
Identity Pools manage user profiles and passwords, while User Pools provide access to AWS resources
Explanation
Cognito User Pools manage user authentication, registration, and JWT token generation, while Identity Pools (Federated Identities) exchange authentication tokens for temporary AWS credentials to access services like S3 or DynamoDB.
A Lambda function is being invoked by multiple AWS services including API Gateway, SNS, and CloudWatch Events. The function needs to handle different event structures appropriately. What is the best practice for structuring the handler code?
-
A
Configure API Gateway to normalize all events into a standard format before invoking the function
-
B
Use a single generic handler that processes all events without distinguishing between source types
-
C
Implement conditional logic to inspect the event structure and route to appropriate handler functions for each source type
✓ Correct
-
D
Create separate Lambda functions for each event source to simplify the code structure
Explanation
Implementing event source detection logic allows a single Lambda function to handle multiple event types by routing to specialized handlers based on event structure characteristics.
When implementing a continuous integration pipeline with AWS CodeBuild, a developer needs to run unit tests and build the application. Which configuration element defines the build process?
-
A
A Docker image uploaded to ECR that CodeBuild automatically executes as the build environment
-
B
An EC2 instance with pre-installed build tools that CodeBuild automatically discovers and uses
-
C
An AWS CloudFormation template that provisionally creates build environments on-demand
-
D
A CodeBuild project that references a buildspec.yml file containing build commands and environment configuration
✓ Correct
Explanation
AWS CodeBuild uses a buildspec.yml file (or inline buildspec) to define the build process including phases (install, pre_build, build, post_build) and environment variables for each project.
A developer is designing a caching strategy for frequently accessed data. The application uses both DynamoDB for persistent storage and ElastiCache for caching. What is the recommended pattern for ensuring cache consistency?
-
A
Implement a write-through or write-behind cache pattern where data is written to DynamoDB and the cache is invalidated or updated accordingly
✓ Correct
-
B
Store data exclusively in ElastiCache and treat DynamoDB as a read-only backup
-
C
Configure DynamoDB Streams to automatically update ElastiCache whenever data changes
-
D
Write all data to ElastiCache first, then asynchronously update DynamoDB to maintain consistency
Explanation
Write-through and write-behind patterns maintain consistency by ensuring updates to the persistent store (DynamoDB) trigger appropriate cache updates or invalidations.
A developer needs to log structured application events to CloudWatch Logs. Which approach best implements this for easy querying and analysis?
-
A
Log events as JSON objects with consistent field names, then use CloudWatch Logs Insights to query the structured data
✓ Correct
-
B
Log all events as plain text strings with no consistent formatting
-
C
Use CloudTrail exclusively to capture all application events automatically without code changes
-
D
Write all logs to S3 for long-term storage and use Athena for querying
Explanation
Structured JSON logging with consistent fields enables CloudWatch Logs Insights to parse and query events efficiently, making troubleshooting and analysis much easier.
When using AWS SAM (Serverless Application Model) to deploy a serverless application, what is the primary advantage over using raw CloudFormation templates?
-
A
SAM uses a simpler, more concise syntax for defining serverless resources with automatic transformation to CloudFormation
✓ Correct
-
B
SAM eliminates the need for parameter files in CloudFormation deployments
-
C
SAM provides serverless-specific intrinsic functions not available in standard CloudFormation
-
D
SAM provides better security by encrypting all credentials automatically
Explanation
AWS SAM provides a shorthand syntax specifically optimized for serverless resources (Lambda, API Gateway, DynamoDB) that automatically transforms into standard CloudFormation templates during deployment.
A developer is implementing request validation in API Gateway for a REST API. Which validation method is most efficient for catching malformed requests before they reach Lambda?
-
A
Deploy the API and rely on Lambda functions to perform all validation and return error responses
-
B
Use API Gateway request validators to enforce schema validation on request payloads, headers, and parameters before invocation
✓ Correct
-
C
Configure CloudFront with request filtering rules to validate incoming requests
-
D
Implement a Lambda authorizer that validates all request properties in addition to authentication
Explanation
API Gateway Request Validators can validate request structure against a JSON Schema before the request reaches Lambda, preventing unnecessary function invocations and improving efficiency.
A developer is using Amazon S3 versioning and needs to retrieve a specific version of an object. Which API call should be used to access previous object versions?
-
A
Configure S3 Select to retrieve specific versions based on query criteria
-
B
Use GetObject with the VersionId parameter to retrieve a specific object version
✓ Correct
-
C
Use ListObjectVersions to view all versions, then download each one separately
-
D
Use S3 CloudFront distribution with version query parameters
Explanation
The S3 GetObject API with the VersionId parameter directly retrieves a specific version of an object from a versioned bucket.
When developing with AWS SDK, a developer encounters rate limiting errors from an AWS service. What is the most appropriate SDK-level solution for handling transient failures?
-
A
Immediately fail the operation and display an error message to the user
-
B
Increase the SDK timeout values to prevent rate limiting altogether
-
C
Implement custom retry logic in the application code with fixed delay between attempts
-
D
Use the SDK's built-in retry mechanism with exponential backoff, which automatically retries transient failures
✓ Correct
Explanation
AWS SDKs include built-in automatic retry logic with exponential backoff for transient failures like rate limiting, reducing the need for custom retry implementation.
A developer is designing an application that processes large files from S3. The files need to be transformed before being written back to S3. Which approach provides the best scalability for variable file sizes?
-
A
Implement a custom streaming solution with Kinesis to handle file processing in real-time
-
B
Use AWS Glue for batch ETL processing of all files in scheduled batches, regardless of current load
-
C
Use a single powerful EC2 instance with large storage to process all files sequentially
-
D
Trigger Lambda functions from S3 events, processing files in memory with a configurable timeout and using S3 Transfer Acceleration for uploads
✓ Correct
Explanation
Lambda functions triggered by S3 events automatically scale to handle concurrent file uploads, and developers can adjust memory/timeout for different file sizes, making this highly scalable.
In a microservices architecture using API Gateway with multiple backend Lambda functions, a developer notices latency issues due to cold starts. Which combination of strategies would most effectively reduce cold start impact?
-
A
Increase Lambda memory allocation exclusively without considering function code optimization
-
B
Migrate all functions to require VPC access to improve performance through private connectivity
-
C
Use CloudWatch Events to periodically invoke Lambda functions and enable provisioned concurrency for frequently accessed functions
✓ Correct
-
D
Use a single monolithic Lambda function instead of multiple microservices to reduce cold starts
Explanation
Provisioned concurrency keeps Lambda functions initialized and ready, while scheduled invocations prevent cold starts; combined with memory optimization, these strategies significantly reduce latency.
You are developing a Lambda function that needs to write logs to CloudWatch Logs. The function currently lacks permissions to perform this action. Which service should you use to grant the Lambda function the necessary permissions?
-
A
AWS Systems Manager Parameter Store
-
B
VPC security groups
-
C
AWS Secrets Manager
-
D
IAM roles and policies
✓ Correct
Explanation
IAM roles and policies are used to grant permissions to AWS services like Lambda. You attach an execution role to the Lambda function with a policy that allows CloudWatch Logs actions such as logs:CreateLogGroup, logs:CreateLogStream, and logs:PutLogEvents.
Your application uses Amazon DynamoDB and you need to retrieve multiple items that share the same partition key efficiently. Which DynamoDB operation should you use?
-
A
Query operation with the partition key and sort key condition
✓ Correct
-
B
Scan operation on the entire table
-
C
GetItem operation for each item individually
-
D
BatchGetItem operation across multiple tables
Explanation
The Query operation is designed to retrieve all items with a specific partition key, optionally filtered by sort key conditions. It is more efficient than Scan as it only accesses items with the matching partition key, not the entire table.
You are deploying an application that requires environment-specific configuration values such as database endpoints and API keys. These values should not be hardcoded in your application code. What is the best practice for managing these values?
-
A
Include them in the application's CloudFormation template as hardcoded strings
-
B
Store them in environment variables using Lambda environment variables or Systems Manager Parameter Store/Secrets Manager
✓ Correct
-
C
Embed them in the application code and use a separate build for each environment
-
D
Store them in a public S3 bucket that your application can access
Explanation
Using Lambda environment variables, Systems Manager Parameter Store, or AWS Secrets Manager allows you to externalize configuration from code, supporting different environments without code changes. This follows the twelve-factor app methodology and improves security.
A developer wants to trace requests across multiple AWS services in their application. Which AWS service provides distributed tracing capabilities to visualize the flow of requests through their application?
-
A
AWS CloudTrail
-
B
Amazon CloudWatch Metrics
-
C
AWS Config
-
D
AWS X-Ray
✓ Correct
Explanation
AWS X-Ray provides distributed tracing functionality that helps developers analyze and debug distributed applications by tracking requests as they travel through various AWS services and components.
You have a Lambda function that processes messages from an SQS queue. The function occasionally fails and you want failed messages to be automatically retried. Additionally, you want messages that fail after multiple retries to be sent to a separate queue for dead-letter handling. How should you configure this?
-
A
Manually implement retry logic inside the Lambda function and call SendMessage to a dead-letter queue on failure
-
B
Configure the Lambda function's event source mapping with maximum event age and maximum retry attempts, and set the SQS queue's redrive policy to a dead-letter queue
✓ Correct
-
C
Enable Lambda's built-in automatic retry mechanism and configure the SQS queue's redrive policy with a dead-letter queue
-
D
Use EventBridge to intercept failed messages and route them through a Step Functions workflow for retries
Explanation
When using SQS as a Lambda event source, you configure the event source mapping with retry behavior. The SQS queue itself has a redrive policy that automatically sends messages that exceed the visibility timeout (after retries) to a designated dead-letter queue.
Your application needs to store temporary session data that expires after a set period of time. The data must be highly available and support fast access. Which AWS service is best suited for this use case?
-
A
Amazon S3 with lifecycle policies
-
B
Amazon DynamoDB with TTL
-
C
Amazon RDS with automatic cleanup jobs
-
D
Amazon ElastiCache (Redis or Memcached)
✓ Correct
Explanation
ElastiCache provides in-memory caching with Redis or Memcached, offering very fast access to session data. While DynamoDB with TTL could work, ElastiCache is optimized for this high-performance caching scenario.
You are writing a Lambda function that calls an external API. The API has rate limiting restrictions. You want to implement exponential backoff with jitter when the API returns a 429 (Too Many Requests) status code. Where should you implement this logic?
-
A
In the Lambda function code using try-catch blocks to handle exceptions and implement retry logic
✓ Correct
-
B
In the CloudWatch alarm that monitors API errors
-
C
In the API Gateway integration response mapping
-
D
In the Lambda function code itself before making the API call
Explanation
Exponential backoff with jitter should be implemented within the Lambda function code using exception handling and retry logic. This gives you fine-grained control over the retry behavior when specific status codes like 429 are encountered.
Your serverless application uses API Gateway to expose Lambda functions. You need to validate incoming request payloads against a JSON schema before the request reaches the Lambda function. What is the most efficient way to accomplish this?
-
A
Implement validation logic at the beginning of each Lambda function
-
B
Configure CloudFormation templates to validate all incoming requests
-
C
Use Lambda layers to share validation code across all functions and validate in each function
-
D
Use API Gateway request validators with a JSON schema model
✓ Correct
Explanation
API Gateway request validators allow you to validate request payloads, query parameters, and headers against JSON schemas before the request reaches your Lambda function. This approach is more efficient as it prevents invalid requests from consuming Lambda resources.
You have deployed a Lambda function with an API Gateway trigger. The function occasionally times out when calling a third-party service. You want to implement a timeout handling strategy that gracefully degrades the service by returning cached data when the external call fails. What approach should you use?
-
A
Configure CloudWatch alarms to detect timeouts and automatically invoke a second Lambda function that returns cached data
-
B
Use Step Functions to orchestrate the Lambda function call with built-in retry and fallback policies that reference a secondary data source
-
C
Implement try-catch error handling in your Lambda function with a fallback mechanism that retrieves cached data from ElastiCache or DynamoDB when the timeout occurs
✓ Correct
-
D
Increase the Lambda timeout to 15 minutes and increase the API Gateway timeout accordingly
Explanation
Implementing try-catch error handling with a fallback to cached data directly in the Lambda function is the most straightforward and efficient approach. This allows graceful degradation without adding additional complexity or AWS service dependencies.
You are developing a microservices application where one service needs to asynchronously invoke another service. The invocation should be decoupled and reliable. Which AWS service combination is best suited for this asynchronous communication pattern?
-
A
SQS queue with Lambda event source mapping, where one service publishes messages to the queue and another service consumes them
✓ Correct
-
B
DynamoDB streams with Lambda triggers for immediate processing
-
C
Direct Lambda function invocation with synchronous calls
-
D
API Gateway with cross-service HTTP calls
Explanation
SQS provides reliable, decoupled asynchronous communication between services. By configuring Lambda with SQS as an event source, messages are reliably queued and processed by the consuming Lambda function, providing automatic retry and dead-letter queue capabilities.