Tüm alıştırma soruları

1542 soru

Soru 281Soru

A developer is writing an AWS Lambda function that retrieves data from an Amazon RDS database. To optimize the function's performance and minimize connection overhead, the developer wants to reuse the database connection across multiple function invocations. How should the developer structure the function code to achieve this?

Cevabı ve açıklamayı göster

Cevap: Initialize the database connection client outside of the Lambda handler function.

Cevap

Initialize the database connection client outside of the Lambda handler function.
Initializing the database connection client outside of the Lambda handler function allows the connection to be kept alive in the execution context's memory. When subsequent invocations occur (warm starts), Lambda reuses the existing container and execution context, making the existing database connection immediately available and avoiding connection overhead.

Adım Adım Çözüm

1
Analyze the request to reuse database connections in an AWS Lambda function.
Identify that the database connection should persist across warm invocations.
Reusing connections avoids the overhead of establishing a new connection on every function invocation.
2
Evaluate where to declare the database connection client in the code.
Determine that variables declared outside the handler function (global scope) are retained when the execution context is reused.
AWS Lambda preserves the execution context (including global variables) for subsequent invocations until the container is destroyed.
3
Select the configuration that places the client initialization in the global scope.
Choose the option to initialize the database connection client outside of the Lambda handler function.
This is the AWS-recommended pattern for client reuse, database connection management, and latency reduction.

Anahtar Kavram

AWS Lambda Execution Context Reuse
Tahmini Süre:45s
Soru 282Soru

An organization's order-fulfillment system uses an AWS Lambda function to process batch payloads and write them to an Amazon Aurora PostgreSQL database located in a private subnet of a VPC. The Lambda function is configured to access the database directly by running within the same private VPC subnets. Database credentials must be retrieved from AWS Secrets Manager on each execution. During load testing, the Lambda function experiences connection timeouts when trying to retrieve secrets from Secrets Manager. Additionally, high concurrency causes the database to reject connections due to reaching its maximum connection limit. Which combination of actions should the developer take to resolve these issues? (Select two.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Create an Interface VPC endpoint (AWS PrivateLink) for AWS Secrets Manager in the VPC, and associate it with the route tables and subnets used by the Lambda function.; Set up an Amazon RDS Proxy for the Aurora database and configure the Lambda function to connect to the proxy endpoint instead of the database instance.

Cevap

To resolve the issues, the developer must create an Interface VPC endpoint (AWS PrivateLink) for AWS Secrets Manager in the VPC, and set up an Amazon RDS Proxy for the Aurora database to manage connection pooling.
Creating an Interface VPC Endpoint (AWS PrivateLink) for AWS Secrets Manager creates private network interfaces in the subnets, enabling the Lambda function to reach Secrets Manager without leaving the AWS network. Setting up Amazon RDS Proxy pools database connections, preventing concurrent Lambda invocations from exhausting the database instance's connection limits.

Adım Adım Çözüm

1
Analyze the connection timeouts to AWS Secrets Manager.
The Lambda function runs inside private subnets of a custom VPC to reach the RDS database. Without a NAT Gateway or VPC endpoints, resources in private subnets cannot access public AWS endpoints like Secrets Manager.
AWS Secrets Manager is a public service. To connect to it privately from a private VPC subnet, an Interface VPC Endpoint must be established.
2
Analyze the database connection limit exhaustion.
AWS Lambda is highly scalable and creates separate execution environments (and database connections) for concurrent requests, which quickly overwhelms traditional database connection limits.
To manage connections effectively, Amazon RDS Proxy should be introduced between the Lambda function and the database to pool and reuse database connections.

Anahtar Kavram

VPC endpoints are required for private VPC subnets to access public AWS services without a NAT Gateway, and RDS Proxy manages connection pooling for highly concurrent serverless environments.
Soru 283Soru

A developer is building a mobile fitness application that stores daily user activity summaries in an Amazon DynamoDB table. The table is configured with UserId as the partition key and ActivityDate as the sort key. The developer needs to retrieve the activity summary for a specific user on a specific date in the most efficient and secure manner. Which two actions should the developer take?

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Use the GetItem API operation specifying both the UserId and ActivityDate to retrieve the item.; Initialize the AWS SDK DynamoDB client using the default credential provider chain.

Cevap

Use the GetItem API operation specifying both the UserId and ActivityDate to retrieve the item, and initialize the AWS SDK DynamoDB client using the default credential provider chain.
Using the GetItem operation is the most efficient and cost-effective way to retrieve a single item when both the partition key (UserId) and sort key (ActivityDate) are known, consuming only the capacity units required for that single item. Additionally, initializing the AWS SDK DynamoDB client using the default credential provider chain follows security best practices by dynamically loading credentials from IAM roles or environment variables, avoiding the need to hardcode secrets.

Adım Adım Çözüm

1
Identify the primary key components required for the item lookup.
Both the partition key (UserId) and the sort key (ActivityDate) are known for the target item.
DynamoDB requires both keys of a composite primary key to perform a single-item GetItem lookup.
2
Select the most efficient DynamoDB API operation.
Choose GetItem instead of Scan or Query.
GetItem retrieves a single item directly using its primary key, minimizing latency and RCU consumption.
3
Select the secure method for configuring AWS SDK credentials.
Use the default credential provider chain.
This avoids hardcoding AWS credentials in the code, adhering to the principle of least privilege and secure credential management.

Anahtar Kavram

Efficient item retrieval using GetItem and secure client authentication using the default credential provider chain.
Soru 284Soru

A developer is building a serverless API where an Amazon API Gateway REST API is integrated with an AWS Lambda function using Lambda proxy integration. The Lambda function processes user data and returns a response. During testing, clients receive a 502502 Bad Gateway error. The Lambda execution logs show that the function ran successfully and completed without error. Which two changes should the developer make to the Lambda function's response to resolve this issue? (Select two.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Format the return value of the Lambda handler as a JSON object containing the statusCode and body fields.; Ensure that the body field of the returned JSON object is serialized as a string.

Cevap

The developer should format the return value of the Lambda handler as a JSON object containing the statusCode and body fields, and ensure that the body field of the returned JSON object is serialized as a string.
For an Amazon API Gateway REST API utilizing Lambda proxy integration, the backend Lambda function must return a JSON response with a specific schema. This schema requires a 'statusCode' key (as an integer) and a 'body' key (which must be a string). If the function finishes successfully but returns a malformed structure or a non-string 'body' value, API Gateway cannot construct the HTTP response and returns a 502502 Bad Gateway error.

Adım Adım Çözüm

1
Identify the integration type between Amazon API Gateway and the AWS Lambda function.
The integration type is Lambda proxy integration.
This determines the response structure requirements. Lambda proxy integration bypasses integration response mappings and expects the Lambda function to return a specific JSON payload format directly.
2
Verify the structure of the Lambda response payload.
Ensure the payload is a JSON object containing the statusCode and body keys.
API Gateway requires the statusCode to determine the HTTP response code and the body key to populate the response payload. Without these fields, API Gateway returns a 502502 Bad Gateway error.
3
Serialize the body payload.
Convert the body object into a string (e.g., using JSON.stringify()).
API Gateway requires the body parameter within the returned JSON object to be a string. Returning a raw JSON object or array under the body key will cause the integration to fail.

Anahtar Kavram

API Gateway Lambda Proxy Integration Response Format
Soru 285Soru

A development team has configured a telemetry analysis application where an Amazon SQS queue triggers an AWS Lambda function to process device payloads. During load testing, the team observes the following issues:

1. Telemetry payloads are occasionally processed multiple times by different concurrent executions of the Lambda function.
2. The Lambda function periodically fails with a 'No space left on device' error when downloading temporary configuration files for validation.

Which two changes should the developer implement to resolve these issues? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Configure the SQS queue's visibility timeout to be at least six times the timeout of the Lambda function.; Modify the Lambda function code to delete the downloaded validation files from the /tmp directory before the handler execution completes.

Cevap

The correct options are configuring the SQS queue's visibility timeout to be at least six times the Lambda function's timeout, and deleting the validation files from the /tmp directory before the handler execution completes.
Configuring the SQS queue's visibility timeout to be at least six times the Lambda function's timeout prevents messages from being visible to other consumers while the active invocation is running, thereby resolving the duplicate processing issue. Additionally, explicitly deleting downloaded files from the /tmp directory before the execution finishes ensures that subsequent invocations reusing the execution context do not run out of space.

Adım Adım Çözüm

1
Analyze the cause of duplicate message processing in SQS-to-Lambda integrations.
Identify that if SQS visibility timeout is too close to or less than Lambda's execution timeout, messages can reappear in the queue before the Lambda function finishes processing, leading to duplicate invocations.
This establishes that the SQS queue's visibility timeout must be set to at least six times the Lambda function's timeout.
2
Analyze the cause of the 'No space left on device' error in Lambda executions.
Understand that because Lambda execution contexts are reused, files downloaded to the /tmp directory persist across subsequent invocations, eventually exhausting the storage limit.
This shows the need to clean up temporary files in the /tmp directory at the end of each handler execution.

Anahtar Kavram

AWS Lambda ephemeral storage lifecycle management and Amazon SQS integration timeout best practices.
Soru 286Soru

A developer is building a serverless application where a frontend web application, hosted on a custom domain, interacts with a backend REST API. The backend is configured using Amazon API Gateway with a Lambda proxy integration. To support cross-origin requests, the developer enabled CORS on the API Gateway resource using the AWS Console, which successfully created the OPTIONS method. However, when the frontend application attempts to send a POST request, the browser console displays a CORS error indicating that the 'Access-Control-Allow-Origin' header is missing. What must the developer do to resolve this issue?

Cevabı ve açıklamayı göster

Cevap: Modify the Lambda function's code to return a JSON object that includes a 'headers' field containing 'Access-Control-Allow-Origin' with the appropriate origin value, alongside the 'statusCode' and 'body' fields.

Cevap

Modify the Lambda function's code to return a JSON object that includes a 'headers' field containing 'Access-Control-Allow-Origin' with the appropriate origin value, alongside the 'statusCode' and 'body' fields.
In Amazon API Gateway, when using Lambda proxy integration, the backend Lambda function is responsible for returning the entire HTTP response. This response must be a JSON object containing 'statusCode', 'body', and 'headers'. To support CORS, the 'headers' object must explicitly contain the 'Access-Control-Allow-Origin' header. Enabling CORS via the API Gateway console only configures the mock integration for the preflight OPTIONS method, but does not modify the response payload returned by the Lambda function for actual HTTP methods like POST.

Adım Adım Çözüm

1
Analyze the integration type between API Gateway and the Lambda function.
The API uses Lambda proxy integration.
Knowing the integration type is critical because Lambda proxy integrations bypass API Gateway's integration response mappings, shifting the responsibility of formatting the HTTP response (including headers) to the backend Lambda function.
2
Determine the source of the missing header error.
The preflight OPTIONS method succeeds, but the POST request fails due to a missing 'Access-Control-Allow-Origin' header.
This confirms that while API Gateway handles CORS for the preflight OPTIONS check (since the console automatically configures the mock response), the actual POST response returned by Lambda lacks the required header.
3
Formulate the correct payload structure for the Lambda function response.
Return a JSON object containing 'statusCode', 'body' (as a stringified JSON), and a 'headers' object with 'Access-Control-Allow-Origin'.
This compliant structure ensures that API Gateway parses the response correctly and forwards the required CORS headers to the browser.

Anahtar Kavram

API Gateway Lambda Proxy Integration CORS Requirements
Soru 287Soru

An online learning platform stores student registration records in an Amazon DynamoDB table. The table uses StudentID as the partition key. A new feature requires retrieving a list of all students who registered in the last 3030 days. Registration dates are stored in an attribute named RegistrationDate. Which approach should the developer use to retrieve these records with the lowest latency and minimal Read Capacity Unit (RCU) consumption?

Cevabı ve açıklamayı göster

Cevap: Create a Global Secondary Index (GSI) with RegistrationDate as the partition key, and perform a Query operation on the GSI.

Cevap

Create a Global Secondary Index (GSI) with RegistrationDate as the partition key, and perform a Query operation on the GSI.
Creating a Global Secondary Index (GSI) with RegistrationDate as the partition key enables the application to use the Query operation. A Query operation targets only the items within the specified partition key value, significantly reducing latency and RCU consumption compared to scanning the entire table.

Adım Adım Çözüm

1
Analyze the table key schema and query requirements.
The base table only supports querying by StudentID. Because the query needs to look up records by RegistrationDate (a non-key attribute), a direct Query operation on the base table is not possible.
DynamoDB Query operations require specifying the partition key of the index or table being queried.
2
Compare Query and Scan operations for data retrieval.
A Scan operation reads every item in the table, whereas a Query searches only items matching the partition key. A Scan is highly inefficient for large datasets.
To minimize latency and RCU consumption, the developer must find a way to perform a Query instead of a Scan.
3
Design a secondary index to enable the Query operation.
Create a Global Secondary Index (GSI) using RegistrationDate as the partition key. Perform a Query operation against this GSI to retrieve the records.
A GSI allows queries on alternate keys, returning only the desired records and consuming minimal RCUs.

Anahtar Kavram

Using Global Secondary Indexes (GSIs) and the Query operation instead of a Scan operation to retrieve data efficiently based on non-key attributes.
Soru 288Soru

A developer is building a REST API in Amazon API Gateway. To allow the frontend development team to test their application before the backend microservices are fully implemented, the developer wants to configure an endpoint to return a mock response with a static JSON payload and an HTTP 200 status code. Which two actions must the developer take to configure this Mock integration in API Gateway? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Configure the Method Response to include the HTTP 200 status code, and configure the Integration Response for the 200 status with an application/json body mapping template that outputs the static JSON payload.; Set the method's integration type to MOCK, and define an Integration Request mapping template for the application/json content type that returns a JSON object containing a statusCode of 200.

Cevap

To configure a Mock integration in Amazon API Gateway to return a static JSON response, the developer must set the method's integration type to MOCK and configure the Integration Request with a mapping template returning a statusCode (such as 200). Additionally, the developer must define the HTTP 200 status code in the Method Response and configure the corresponding Integration Response with an application/json body mapping template that contains the static JSON payload.
The correct options explain the two halves of a Mock integration configuration: setting the integration type to MOCK with an Integration Request template that outputs a statusCode (e.g., 200), and configuring the Method Response (to define the 200 HTTP code) along with an Integration Response mapping template to return the static JSON payload.

Adım Adım Çözüm

1
Set the integration type of the API Gateway method to MOCK.
Specifies that API Gateway should generate a direct response without forwarding the request to a backend service.
This establishes a Mock integration.
2
Configure an Integration Request mapping template for application/json that returns a statusCode key, such as {'statusCode': 200}.
Provides API Gateway with the status code parameter needed to route the mock request internally.
API Gateway uses this statusCode value to select the matching Integration Response.
3
Define an HTTP 200 status code in the Method Response, and configure the corresponding 200 Integration Response with a body mapping template containing the static JSON payload.
Maps the internal status code to the client-facing response and formats the final static response body returned to the client.
This ensures the client receives the expected HTTP 200 status code and mock JSON payload.

Anahtar Kavram

Mock integrations in API Gateway bypass backend services and use mapping templates in both the Integration Request and Integration Response to construct static client responses.
Soru 289Soru

An engineering team is building a REST API using Amazon API Gateway that integrates with a legacy HTTP backend service using an HTTP integration (non-proxy). When the legacy backend cannot find a record, it returns an HTTP status code 404 with a plain text error message. The team wants the API Gateway to intercept this 404 response and instead return an HTTP status code 200 to the client, containing a structured JSON payload: {"available": false, "reason": "Record not found"}. Which configuration steps must the developer perform in API Gateway to meet these requirements?

Cevabı ve açıklamayı göster

Cevap: In the Method Response configuration, ensure the 200 status code is defined. In the Integration Response configuration, create a mapping rule with an HTTP status regex of 404, map it to the 200 method response, and define an application/json mapping template to output the custom JSON payload.

Cevap

In the Method Response configuration, ensure the 200 status code is defined. In the Integration Response configuration, create a mapping rule with an HTTP status regex of 404, map it to the 200 method response, and define an application/json mapping template to output the custom JSON payload.
To transform a backend response's status code and body in a non-proxy integration, you must first define the target status code (200) in the Method Response. Then, in the Integration Response, you map the backend's response status code (404) to the target Method Response status code (200) and specify a mapping template to output the required JSON format. This decouples the client-facing API contract from the legacy backend implementation.

Adım Adım Çözüm

1
Define the target HTTP status code in the Method Response configuration.
The API Gateway method is configured to allow a client-facing HTTP 200 response.
Before mapping any integration response to a client response status, that status code must exist in the Method Response configuration.
2
Configure the Integration Response mapping rule for HTTP 404.
API Gateway intercepts backend HTTP 404 responses and redirects them to the 200 Method Response path.
The HTTP status regex in the Integration Response matches the incoming backend status code to direct it to the appropriate client status code.
3
Specify an application/json mapping template in the Integration Response.
The backend plain text body is transformed into the desired JSON format.
Mapping templates (VTL) reshape backend payloads to conform to the client's expected interface.

Anahtar Kavram

API Gateway Integration Response Mapping
Tahmini Süre:2m 0s
Soru 290Soru

A developer is writing a backend service for a task management application. The application stores user tasks in an Amazon DynamoDB table with UserId as the partition key and TaskId as the sort key. The developer needs to retrieve all tasks associated with a specific UserId that have a status of 'Pending'. The developer wants to minimize latency and the consumption of Read Capacity Units (RCUs).

Which two actions should the developer take to retrieve the required items efficiently? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Perform a Query operation specifying the UserId in the key condition expression.; Use a FilterExpression in the Query operation to return only tasks with a status of 'Pending'.

Cevap

To retrieve the tasks efficiently, the developer should perform a Query operation specifying the UserId in the key condition expression, and use a FilterExpression in that Query operation to filter for tasks with a status of 'Pending'.
The most efficient way to retrieve multiple items sharing the same partition key (UserId) is to perform a Query operation. A FilterExpression can then be applied to the Query operation to narrow down the results to only include those where the status is 'Pending'. This ensures only the relevant partition is read, minimizing RCU consumption and latency.

Adım Adım Çözüm

1
Determine the appropriate DynamoDB API operation.
Since the developer has the partition key (UserId) and wants to retrieve all matching items, the Query operation is the correct choice. GetItem cannot retrieve multiple items without the sort key, and Scan reads the entire table which is inefficient.
Using Query minimizes Read Capacity Unit (RCU) consumption by targeting only the specific partition.
2
Apply the filter for non-key attributes.
Since 'status' is not part of the primary key, a FilterExpression must be added to the Query operation to filter out items where the status is not 'Pending'.
FilterExpression is applied after the query reads the partition, reducing the payload size returned to the application.

Anahtar Kavram

Efficient data retrieval using DynamoDB Query and FilterExpressions
Soru 291Soru

A developer is implementing a serverless data processing application where an Amazon Kinesis data stream triggers an AWS Lambda function via an event source mapping. During high-traffic periods, temporary downstream database connection failures cause the Lambda function to fail when processing certain batches. This results in the entire batch of records being repeatedly retried, causing head-of-line blocking and redundant processing of valid records. The developer wants to isolate the failing records, avoid processing duplicates where possible, and capture failed records for offline analysis without stalling stream ingestion.

Which two configurations should the developer apply to the Lambda event source mapping to meet these requirements? (Select two.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Set BisectBatchOnFunctionError to true in the event source mapping configuration.; Configure an on-failure destination (DestinationConfig) in the event source mapping to route discarded record metadata to an Amazon SQS queue.

Cevap

The correct configurations are to enable BisectBatchOnFunctionError in the event source mapping and configure an on-failure destination on the mapping to route metadata of discarded records to an Amazon SQS queue.
To prevent head-of-line blocking in Kinesis event source mappings, the developer must set BisectBatchOnFunctionError to true. This splits the failed batch into two halves and retries them separately, narrowing down the failure to the specific failing record. To capture failed records without stalling ingestion, the developer should configure an on-failure destination on the event source mapping itself. When a batch reaches its maximum retry limit or maximum record age, Lambda discards the batch and sends metadata (including shard ID and sequence number) to the destination.

Adım Adım Çözüm

1
Analyze the event source mapping behavior for stream-based sources.
Identify that by default, a single failed record in a batch causes the entire batch to be retried repeatedly, leading to head-of-line blocking.
This helps locate where the logic for splitting batches and routing failures resides.
2
Select the correct mechanism to isolate failing records within a batch.
Enable BisectBatchOnFunctionError so that Lambda splits the failing batch in half and retries each half independently.
This isolates the problematic record and allows successful records in the original batch to proceed.
3
Select the correct mechanism to capture permanently failing records without blocking the stream.
Configure an on-failure destination on the event source mapping.
Since the stream is polled synchronously by Lambda, standard function-level DLQs do not apply. An on-failure destination ensures that record metadata is captured once retry limits are exhausted.

Anahtar Kavram

Error handling configurations for AWS Lambda event source mappings integrated with Amazon Kinesis Data Streams.
Soru 292Soru

A developer is working on an AWS Lambda function that retrieves transaction data from an Amazon RDS PostgreSQL database running in a private subnet of a VPC. The function must also send an HTTP request to a third-party payment processor endpoint on the public internet. The developer configures the Lambda function to run inside the same VPC and private subnets as the database. Testing reveals that the Lambda function successfully queries the database but times out when attempting to connect to the payment processor.

Which configuration change should the developer make to resolve this connection timeout?

Cevabı ve açıklamayı göster

Cevap: Configure a NAT Gateway in a public subnet of the VPC, and add a route in the route table of the Lambda function's subnets to direct internet-bound traffic to the NAT Gateway.

Cevap

Configure a NAT Gateway in a public subnet of the VPC, and add a route in the route table of the Lambda function's subnets to direct internet-bound traffic to the NAT Gateway.
The correct action is to route internet-bound traffic through a NAT Gateway. When a Lambda function is configured to run inside a VPC, it accesses resources via Elastic Network Interfaces (ENIs) allocated in the configured subnets. Since these ENIs do not have public IP addresses, they cannot communicate directly with the internet, even if placed in a public subnet. To enable internet connectivity, the function must be placed in private subnets, and the corresponding route table must route all external traffic (0.0.0.0/0) to a NAT Gateway deployed in a public subnet.

Adım Adım Çözüm

1
Analyze the network route paths for the Lambda function inside the VPC.
The Lambda function is in a private subnet with route paths to the database, but it has no route to the internet.
Since Lambda ENIs do not have public IPs, they cannot use an Internet Gateway directly even if placed in a public subnet.
2
Introduce a NAT Gateway into the network architecture.
A NAT Gateway is created in a public subnet of the VPC, which has a route to the Internet Gateway.
The NAT Gateway acts as a proxy, translating private IPs to its own public IP for outgoing internet traffic.
3
Update the routing table of the Lambda function's private subnet.
A route for 0.0.0.0/0 pointing to the NAT Gateway is added to the private subnet's route table.
This directs all external traffic from the Lambda function through the NAT Gateway, resolving the connection timeout.

Anahtar Kavram

VPC Networking for AWS Lambda
Soru 293Soru

A developer is designing a REST API in Amazon API Gateway that must secure access to its endpoints using an existing Amazon Cognito User Pool. The developer wants to validate the JSON Web Tokens (JWTs) passed in the `Authorization` header of client requests with the minimum amount of custom code and lowest latency. Which configuration should the developer implement in API Gateway?

Cevabı ve açıklamayı göster

Cevap: Configure a Cognito User Pool authorizer on the API Gateway methods and set the Token Source to 'Authorization'

Cevap

Configure a Cognito User Pool authorizer on the API Gateway methods and set the Token Source to 'Authorization'
The native Cognito User Pool authorizer in Amazon API Gateway validates the JWT signatures from Cognito User Pools directly at the gateway layer. This requires no custom code, is easy to set up, and avoids the cold-start latency and execution costs of a Lambda function.

Adım Adım Çözüm

1
Identify the authentication source and requirements
The client sends a JWT from Amazon Cognito User Pool in the 'Authorization' header, and the goal is validation with minimal code and latency.
This establishes that we need to inspect the header and compare it with the Cognito User Pool keys.
2
Evaluate API Gateway's built-in capabilities vs custom solutions
API Gateway provides a native 'Cognito User Pool Authorizer' that validates JWTs automatically without invoking Lambda functions.
Choosing a native feature eliminates code maintenance (minimizes custom code) and reduces execution overhead (minimizes latency).
3
Configure the token source mapping
Map the token source field to 'Authorization' so API Gateway knows which incoming header contains the JWT.
API Gateway requires this mapping to extract the token for verification.

Anahtar Kavram

API Gateway Cognito User Pool Authorizer
Soru 294Soru

A developer is configuring an Amazon SQS FIFO queue to process incoming order events. To ensure that duplicate orders are ignored during a 5-minute window and that orders are processed in the strict order they were received, which TWO configurations must the developer implement?

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Provide a unique MessageDeduplicationId for each sent message, or enable Content-Based Deduplication on the queue.; Provide a MessageGroupId for each message to group related messages for ordered sequential processing.

Cevap

To ensure deduplication and ordered delivery in Amazon SQS FIFO queues, the developer must configure the MessageDeduplicationId (or use Content-Based Deduplication) and provide a MessageGroupId.
The correct options are specifying a MessageDeduplicationId (or enabling Content-Based Deduplication) and providing a MessageGroupId. SQS FIFO queues require a MessageDeduplicationId to uniquely identify messages and discard duplicates within the 5-minute deduplication window. They also require a MessageGroupId to guarantee that messages belonging to the same group are processed sequentially in the order they were sent.

Adım Adım Çözüm

1
Identify the mechanism for message deduplication in Amazon SQS FIFO queues.
Amazon SQS FIFO queues use a MessageDeduplicationId or Content-Based Deduplication to identify duplicates within a 5-minute window.
This prevents duplicate processing of identical messages.
2
Identify the mechanism for message ordering in Amazon SQS FIFO queues.
Amazon SQS FIFO queues require a MessageGroupId to group messages that must be processed in order.
This ensures that messages within the same group are processed sequentially, preserving the strict ordering requirement.

Anahtar Kavram

SQS FIFO Message Deduplication and Grouping
Soru 295Soru

A developer is configuring a REST API in Amazon API Gateway that integrates with an AWS Lambda function. The API must use a Lambda non-proxy (custom) integration to allow request transformation. The developer needs to pass the incoming client request header X-App-Tenant-Id as a JSON property named tenantId in the payload sent to Lambda. Additionally, if the Lambda function fails with an error message containing TenantSuspended, the API must return an HTTP 403 Forbidden status code and a custom JSON message to the client. Which two configurations are required to meet these requirements? (Select two.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Define a mapping template of type application/json in the Integration Request that extracts the header value using the expression $input.params('X-App-Tenant-Id').; Configure an Integration Response with a Lambda Error Regex pattern set to .*TenantSuspended.* and map it to a Method Response with a 403 status code.

Cevap

To pass the header, define an Integration Request mapping template for application/json that extracts the header using $input.params('X-App-Tenant-Id'). To map the backend error, configure an Integration Response with a Lambda Error Regex pattern matching .*TenantSuspended.* and map it to a 403 Method Response.
The correct configurations are defining a mapping template in the Integration Request using the $input.params('X-App-Tenant-Id') expression, and configuring an Integration Response with a Lambda Error Regex pattern to capture the exception and return a 403 Method Response. With Lambda non-proxy integration, developers use Integration Request mapping templates to extract parameters and shape the payload, and Integration Responses to map backend error messages to target HTTP status codes.

Adım Adım Çözüm

1
Configure the Integration Request mapping template.
Extracts the client header value and constructs a JSON payload with a tenantId property for the backend Lambda function.
Because Lambda non-proxy integration is used, API Gateway must explicitly transform the incoming HTTP request metadata into a JSON format expected by the Lambda function.
2
Configure a Method Response for the resource method.
Defines an HTTP 403 status code response block for the client.
API Gateway requires that the HTTP status code (Method Response) be defined before the integration response mapping can target it.
3
Configure the Integration Response mapping rules.
Matches the error message string from Lambda using regex and maps the execution result to the 403 Method Response.
For custom integrations, API Gateway evaluates the errorMessage field returned from Lambda against the configured regex pattern to determine which HTTP response code to send back.

Anahtar Kavram

API Gateway Lambda Custom Integration Request and Response Mapping
Tahmini Süre:2m 0s
Soru 296Soru

A developer is implementing a transaction processing system using an Amazon SQS FIFO queue. The system must process transactions in the exact order they occur. During testing, the developer notices that when two different transactions with identical message bodies are sent within two minutes of each other, the second transaction is discarded. Content-based deduplication is disabled on the queue. How should the developer modify the application configuration or message attributes to ensure both transactions are processed?

Cevabı ve açıklamayı göster

Cevap: Set a unique MessageDeduplicationId parameter on each sent message.

Cevap

Set a unique MessageDeduplicationId parameter on each sent message.
Setting a unique MessageDeduplicationId on each sent message ensures that Amazon SQS treats transactions with identical bodies as distinct messages, preventing incorrect deduplication when content-based deduplication is disabled.

Adım Adım Çözüm

1
Analyze the message discard behavior in the SQS FIFO queue.
The second message is discarded because it has an identical body to a message sent within the 5-minute deduplication window, and content-based deduplication is disabled.
SQS FIFO queues require a mechanism to distinguish between duplicate retries and distinct messages with the same payload.
2
Evaluate SQS FIFO deduplication parameters.
When content-based deduplication is disabled, SQS relies strictly on the MessageDeduplicationId token passed with the message.
A unique MessageDeduplicationId tells SQS that the message is distinct despite having the same body.
3
Select the correct option to configure.
Setting a unique MessageDeduplicationId on each message.
This allows both transactions to bypass the 5-minute deduplication check and be successfully queued.

Anahtar Kavram

SQS FIFO Message Deduplication
Soru 297Soru

A developer has implemented an AWS Lambda function that is triggered by an Amazon SQS queue. The function retrieves database credentials from AWS Secrets Manager, connects to an Amazon RDS PostgreSQL database in a private subnet, and processes messages. During load testing, the database experiences connection exhaustion, and some SQS messages are processed multiple times. Which TWO actions should the developer take to resolve these issues?

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Move the database connection initialization and secrets retrieval code outside of the Lambda handler function.; Configure the SQS queue's visibility timeout to be at least six times the timeout configuration of the Lambda function.

Cevap

Initialize the database connection and secrets retrieval outside of the handler function, and configure the SQS queue's visibility timeout to be at least six times the Lambda function's timeout.
Moving the connection code outside the handler allows subsequent invocations to reuse the established database connections from the execution context. Configuring the SQS visibility timeout to be at least six times the Lambda function's timeout prevents messages from being visible to other pollers before the active execution has completed.

Adım Adım Çözüm

1
Analyze the database connection exhaustion issue.
The Lambda function is creating a new connection on every invocation. By moving the connection logic outside the handler, the function leverages execution context reuse.
This maintains persistent database connection pools across multiple invocations in the same execution container.
2
Analyze the duplicate message processing issue.
If the execution time of the function exceeds the SQS queue's visibility timeout, messages become visible to other function instances while still processing.
Setting the visibility timeout to at least six times the Lambda timeout provides a safety buffer for processing and retries.

Anahtar Kavram

Reusing execution contexts and managing integration timeouts are critical for optimizing Lambda performance and ensuring message delivery semantics.
Tahmini Süre:1m 30s
Soru 298Soru

A developer is building a backend service that retrieves user profile history records from an Amazon DynamoDB table. The table is configured with UserID as the partition key and LastUpdated as the sort key. The developer wants to retrieve all historical records for a specific UserID using the AWS SDK. Which approach should the developer use to perform this retrieve operation most efficiently and securely?

Cevabı ve açıklamayı göster

Cevap: Perform a Query operation specifying the UserID in the key condition expression, and initialize the AWS SDK client using the default credential provider chain.

Cevap

Perform a Query operation specifying the UserID in the key condition expression, and initialize the AWS SDK client using the default credential provider chain.
The correct approach retrieves the historical records using the Query API since it directly queries the table using the partition key, ensuring minimal Read Capacity Unit consumption. It also secures the application by utilizing the default credential provider chain to handle authentication.

Adım Adım Çözüm

1
Determine the optimal DynamoDB API operation to retrieve multiple items that share the same partition key.
The Query operation is selected because it directly targets the partition key and reads only the matching items.
Unlike Scan, which reads every item in the table, Query minimizes Read Capacity Unit consumption and request latency.
2
Identify the secure method for managing AWS credentials when initializing the SDK client.
The default credential provider chain is used to automatically load credentials from IAM roles or environment variables.
Hardcoding credentials in the code exposes sensitive access keys to repositories and unauthorized users.

Anahtar Kavram

DynamoDB Query operations and secure AWS SDK credential initialization

Alternatif Yöntem

If only a single specific historical record is needed and both the partition key and sort key are known, the GetItem API operation would be the most efficient approach.
Tahmini Süre:45s
Soru 299Soru

A developer is designing a real-time fleet logistics tracking system. The system stores shipment event logs in an Amazon DynamoDB table. The table has `CarrierID` (String) as the partition key and `EventID` (String) as the sort key. The application must support three operations:

1. Retrieve all event logs for a specific carrier within a specific timestamp window, ordered from the most recent to the oldest.
2. Retrieve a specific event log's details across all carriers using the unique `EventID`.
3. Update the status of up to 10 event logs simultaneously in a single transaction, ensuring all updates succeed or all fail together.

Which combination of DynamoDB configurations and API operations will meet these requirements most efficiently? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Create a Global Secondary Index (GSI) with `CarrierID` as the partition key and `Timestamp` as the sort key. Query this GSI with `ScanIndexForward` set to `false` to retrieve the sorted logs.; Create a Global Secondary Index (GSI) with `EventID` as the partition key. Query this GSI to retrieve the specific event details, and use the `TransactWriteItems` API to execute the transaction updates.

Cevap

To meet the requirements efficiently, create a Global Secondary Index (GSI) with CarrierID as the partition key and Timestamp as the sort key, and query it with ScanIndexForward set to false. Additionally, create a GSI with EventID as the partition key to query specific events, and use the TransactWriteItems API to perform atomic updates.
To retrieve sorted logs by carrier and timestamp efficiently, a Global Secondary Index (GSI) with CarrierID as the partition key and Timestamp as the sort key is required. Querying this GSI with ScanIndexForward set to false returns the results in descending order. To retrieve an event by EventID without knowing the CarrierID, a GSI with EventID as the partition key is needed. To perform atomic updates on up to 10 logs simultaneously, the TransactWriteItems API must be used because it provides transactional guarantees where either all updates succeed or all fail.

Adım Adım Çözüm

1
Identify the most efficient way to query sorted event logs by carrier and timestamp.
Define a Global Secondary Index (GSI) with CarrierID as the partition key and Timestamp as the sort key. Perform a Query operation rather than a Scan. Set ScanIndexForward to false to return items in descending chronological order.
A Query on a GSI is much more efficient than a Scan on the base table because it target-reads only the matching partition key and sort key range, conserving Read Capacity Units (RCUs).
2
Identify how to retrieve a specific event log across all carriers without knowing the CarrierID.
Define a Global Secondary Index (GSI) with EventID as the partition key. Retrieve the item by performing a Query on this GSI.
Since CarrierID is the partition key of the base table, locating an item by EventID alone would require scanning the entire base table. A GSI on EventID enables direct, single-lookup queries across all partitions.
3
Determine the API operation required for executing atomic write updates across multiple items.
Use the TransactWriteItems API rather than BatchWriteItem.
TransactWriteItems provides ACID transaction guarantees, ensuring that either all status updates succeed or none are applied. BatchWriteItem does not support transactional atomicity and can result in partial successes.

Anahtar Kavram

Optimizing DynamoDB queries and transactions using Global Secondary Indexes (GSIs) and TransactWriteItems.
Soru 300Soru

A developer is building a mobile shopping application that stores product details in an Amazon DynamoDB table. The application currently retrieves products belonging to a specific department by performing a Scan operation on the base table and filtering the results using a FilterExpression on the Department attribute. This is causing high latency and excessive Read Capacity Unit (RCU) consumption. Which two actions should the developer take to retrieve the products efficiently while minimizing RCU consumption? (Select TWO.)

Geçerli olan tümünü seçin

Cevabı ve açıklamayı göster

Cevap: Create a Global Secondary Index (GSI) with Department as the partition key.; Use the Query API operation on the GSI to retrieve the products.

Cevap

Create a Global Secondary Index (GSI) with Department as the partition key, and use the Query API operation on the GSI to retrieve the products.
To optimize the read operations and minimize Read Capacity Unit (RCU) consumption, the developer should create a Global Secondary Index (GSI) using the Department attribute as the partition key, and then use the Query API operation instead of Scan. The Query operation only reads the items that share the target partition key, significantly reducing the RCU footprint compared to a full Scan.

Adım Adım Çözüm

1
Analyze the current data retrieval pattern.
The application performs a Scan on the base table and filters items using a FilterExpression.
To identify why the operation consumes excessive RCUs and causes latency.
2
Identify the performance bottleneck of Scan vs Query.
Scan operations read every item in the table before applying the FilterExpression, consuming RCUs proportional to the table size. Query operations only read items matching the specified partition key.
To choose the correct API operation for efficient retrieval.
3
Determine the necessary table configuration changes.
Create a Global Secondary Index (GSI) with Department as the partition key because the base table partition key cannot be used to query by department directly.
To enable the use of the Query operation on the Department attribute.

Anahtar Kavram

DynamoDB Query vs Scan optimization using Global Secondary Indexes (GSIs)
ÖncekiSayfa 15 / 78Sonraki
Tüm alıştırma soruları — AWS Certified Developer - Associate | Examkin