Tüm alıştırma soruları

1542 soru

Soru 1521Soru

An application team wants to minimize unnecessary backend processing by validating client requests directly at the API Gateway layer before invoking a downstream AWS Lambda function. The REST API must verify that client requests contain a valid JSON payload matching a specific schema, and automatically reject invalid requests with an HTTP 400400 Bad Request error. Which two configuration steps should the developer perform in Amazon API Gateway to achieve this? (Select TWO.)

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

Cevabı ve açıklamayı göster

Cevap: Create a Model in the API Gateway console that defines the JSON Schema of the expected request payload.; In the Method Request settings, select a Request Validator that validates the request body, and associate the request body content type with the created Model.

Cevap

To perform request validation in API Gateway, the developer must create a Model that defines the expected JSON Schema of the payload and configure the Method Request settings by selecting a Request Validator for the request body while mapping the content type to the created Model.
To perform request body validation in API Gateway before invoking a backend Lambda function, the developer must define the structure of the request payload using a Model (defined via JSON Schema) and enable request validation in the Method Request settings by selecting a Request Validator (e.g., 'Validate body') and associating the content type (e.g., 'application/json') with that Model. This ensures that malformed requests are rejected immediately at the API Gateway level, saving backend resources.

Adım Adım Çözüm

1
Define the schema model
A Model is created in API Gateway containing the JSON Schema defining required fields and types.
API Gateway needs a schema definition to know what fields and structure to enforce on the incoming request.
2
Configure method request validator
The Request Validator is set to 'Validate body' in the Method Request settings.
This instructs API Gateway to intercept and inspect the incoming payload body against the specified validator rules.
3
Map content type to the model
The request body content type (e.g., 'application/json') is mapped to the newly created Model.
This tells API Gateway which model to use when validating payloads of that specific content type.

Anahtar Kavram

Request Validation using API Gateway Models and Request Validators
Tahmini Süre:2m 0s
Soru 1522Soru

A developer is configuring an application running on an Amazon EC2 instance in Account B (444455556666444455556666) to read objects from an Amazon S3 bucket named `data-bucket` located in Account A (111122223333111122223333). The EC2 instance uses an IAM instance profile with an IAM role named `ReaderRole`.

The developer has attached the following IAM policy to `ReaderRole` in Account B:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::data-bucket/*"
}
]
}

However, the application receives an AccessDenied error when attempting to download objects from `data-bucket`.

Which action should the developer take to resolve this error?

Cevabı ve açıklamayı göster

Cevap: Add a bucket policy to data-bucket in Account A that grants s3:GetObject permissions to the principal arn:aws:iam::444455556666:role/ReaderRole.

Cevap

Add a bucket policy to the S3 bucket in Account A that explicitly allows the IAM role from Account B to access the objects.
For cross-account S3 access, permissions must be granted in two locations: the identity-based IAM policy in the trusted account (Account B) must allow the action, and the resource-based S3 bucket policy in the trusting account (Account A) must trust the caller's identity. Because the identity-based policy is already correctly configured in Account B, adding the bucket policy in Account A that references the caller's IAM role ARN resolves the authorization gap.

Adım Adım Çözüm

1
Analyze cross-account permissions requirements.
Determine that cross-account S3 access requires authorization from both the identity-based policy in the caller's account (Account B) and the resource-based policy in the resource owner's account (Account A).
By default, cross-account access is denied unless both accounts explicitly grant permission.
2
Draft a bucket policy for the S3 bucket in Account A.
Identify that the principal in the bucket policy must target the specific IAM role ARN (arn:aws:iam::444455556666:role/ReaderRole) rather than the instance profile or the entire account.
Specifying the IAM role ARN follows the principle of least privilege, restricting access only to the container/instance running the application.
3
Apply the bucket policy in Account A.
The bucket policy is applied, linking the IAM role to the S3 resource permission, resolving the AccessDenied error.
With both policies permitting the action, the IAM evaluation engine successfully authorizes the request.

Anahtar Kavram

Cross-Account IAM Resource Authorization
Soru 1523Soru

A developer is designing a fleet management system that tracks delivery drone telemetry. Telemetry data is ingested into an Amazon DynamoDB table with the following schema:

* Base Table: `DroneTelemetry`
* Partition Key: `DroneID` (String)
* Sort Key: `ReadingTimestamp` (Number, Unix epoch time)
* Attributes: `BatteryLevel` (Number), `Latitude` (Number), `Longitude` (Number), `Status` (String)

The developer needs to implement the following requirements:
1. Retrieve all telemetry data for a specific drone within the last 33 hours to plot its flight path.
2. Periodically identify drones that currently have a `Status` of `'Critical'` across the entire fleet.

Which two strategies should the developer implement to meet these requirements with optimal performance and minimum Read Capacity Unit (RCU) consumption? (Choose two.)

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

Cevabı ve açıklamayı göster

Cevap: Perform a Query operation on the base table using a key condition expression specifying the DroneID and a range condition on the ReadingTimestamp.; Create a Global Secondary Index (GSI) with Status as the partition key and ReadingTimestamp as the sort key, then perform a Query operation on the GSI.

Cevap

The correct strategy is to perform a Query operation on the base table using a key condition expression specifying the DroneID and a range condition on the ReadingTimestamp to fetch the drone's telemetry, and to create a Global Secondary Index (GSI) with Status as the partition key to perform a Query operation to retrieve drones with a critical status.
The correct strategy combines a direct Query operation on the base table with a GSI-based Query. A base table Query is optimal because it specifies the exact partition key (DroneID) and filters using the sort key (ReadingTimestamp). For the status check, a GSI with Status as the partition key allows the application to query only the matching records, which eliminates the need to scan the entire dataset and saves substantial read capacity.

Adım Adım Çözüm

1
Analyze the query requirement for drone flight paths.
The query targets a specific partition key (DroneID) and a range of the sort key (ReadingTimestamp).
Performing a Query operation on the base table directly uses the primary key attributes, which returns matches efficiently without scanning irrelevant data.
2
Analyze the query requirement for identifying critical drones.
Since the status attribute is not part of the primary key of the base table, a GSI is required to avoid a Scan operation.
Creating a GSI with Status as the partition key enables querying the status attribute directly, which restricts the scanned items only to those matching the partition key value.
3
Evaluate and eliminate incorrect approaches.
Identify Scan operations, incorrect scaling solutions, and security violations.
Scan operations read the entire table and waste read capacity. Scaling provisioned throughput does not fix hot partition throttling. Hardcoding credentials violates security best practices.

Anahtar Kavram

Optimizing read operations in DynamoDB using base table Query operations and Global Secondary Indexes (GSIs) to avoid costly Scan operations.
Soru 1524Soru

A developer is designing a decoupled backend architecture for a banking application to process real-time transaction events. The application requires that transaction events are processed in the strict order they occur, and duplicate transactions must be prevented. The developer configures an Amazon SNS FIFO topic to receive transaction events. The developer wants to fan out these events to two different backend consumer services: a ledger service and a fraud detection service. To support this, the developer creates an Amazon SQS FIFO queue named LedgerQueue.fifo and an Amazon SQS Standard queue named FraudQueue. When attempting to subscribe both queues to the SNS FIFO topic, the subscription for FraudQueue fails. How can the developer resolve this subscription failure while maintaining the application's strict ordering and duplication requirements?

Cevabı ve açıklamayı göster

Cevap: Convert the fraud detection queue to an Amazon SQS FIFO queue, rename it to FraudQueue.fifo, and subscribe it to the Amazon SNS FIFO topic.

Cevap

Convert the fraud detection queue to an Amazon SQS FIFO queue, rename it to FraudQueue.fifo, and subscribe it to the Amazon SNS FIFO topic.
Amazon SNS FIFO topics can only deliver messages to Amazon SQS FIFO queues to maintain end-to-end message ordering and deduplication. Therefore, the standard SQS queue must be converted to a FIFO queue with the .fifo suffix in order to successfully subscribe to the SNS FIFO topic.

Adım Adım Çözüm

1
Analyze the subscription error between Amazon SNS FIFO and SQS queues.
Identify that the standard SQS queue (FraudQueue) is incompatible with the SNS FIFO topic.
AWS restricts SNS FIFO topic subscriptions to SQS FIFO queues only to guarantee end-to-end FIFO delivery.
2
Select the correct SQS queue type to support the required integration.
Determine that FraudQueue must be re-created as a FIFO queue with the .fifo suffix.
FIFO SQS queues support strict ordering and deduplication, satisfying both application requirements and SNS FIFO topic requirements.
3
Subscribe both FIFO SQS queues to the SNS FIFO topic.
LedgerQueue.fifo and FraudQueue.fifo are successfully subscribed to the SNS FIFO topic.
Both endpoints are now SQS FIFO queues, which is a supported configuration for SNS FIFO delivery.

Anahtar Kavram

Amazon SNS FIFO and Amazon SQS FIFO integration constraints
Tahmini Süre:1m 30s
Soru 1525Soru

A developer is configuring an Amazon API Gateway REST API that integrates with an external HTTP backend service. The client sends a GET request containing a query string parameter named `id`. The backend service requires a POST request with a JSON payload in the format `{"customerId": "value"}`. Which configuration should the developer implement in API Gateway to meet these requirements?

Cevabı ve açıklamayı göster

Cevap: Set the integration type to HTTP, set the integration method to POST, and configure an integration request mapping template for the application/json content type that extracts the ID using $input.params('id').

Cevap

Set the integration type to HTTP, set the integration method to POST, and configure an integration request mapping template for the application/json content type that extracts the ID using the input params utility.
To transform an incoming GET request with a query parameter into a POST request with a JSON payload for an HTTP backend, the developer must use a custom HTTP integration. Under the integration request settings, the integration method is set to POST, and a mapping template for the application/json content type is defined. The VTL utility `$input.params('id')` is used to dynamically extract the query parameter value and insert it into the JSON request body.

Adım Adım Çözüm

1
Determine the integration type requirements based on the backend communication pattern.
Since request transformation (converting GET query parameter to POST JSON body) is required for an external HTTP endpoint, a custom HTTP integration (non-proxy) must be selected.
Proxy integrations do not support request mapping templates.
2
Configure the integration request settings in API Gateway.
Set the integration method to POST to match the backend expectation.
This overrides the client's HTTP method for the backend invocation.
3
Create a mapping template for the application/json content type under Integration Request.
Define the VTL template mapping the customer ID: `{"customerId": "$input.params('id')"}`.
The utility function extracts the parameter from the request parameters (query string, path, or headers) and outputs it into the JSON payload body.

Anahtar Kavram

API Gateway integration request mapping templates allow developers to transform incoming client requests (e.g., query strings, headers) into the specific format and HTTP method required by a backend service.
Soru 1526Soru

A company is deploying a serverless microservice that requires access to an Amazon RDS database. The database credentials must be rotated every 30 days. The design requires that the microservice retrieves these credentials securely, minimizes latency during invocations, and minimizes Secrets Manager API call costs. Which two actions should be taken to meet these requirements? (Select two.)

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

Cevabı ve açıklamayı göster

Cevap: Store the database credentials in AWS Secrets Manager and configure automatic rotation.; Retrieve and cache the credentials in a global variable outside of the Lambda handler function to reuse them across subsequent warm invocations.

Cevap

Store the database credentials in AWS Secrets Manager with automatic rotation, and retrieve and cache the credentials in a global variable outside of the Lambda handler function.
Storing the credentials in AWS Secrets Manager allows native integration with Amazon RDS for automated rotation. Retrieving the secret outside the handler function allows the Lambda execution context to cache the credentials in memory, meaning subsequent invocations (warm starts) do not need to make costly and high-latency API calls to Secrets Manager.

Adım Adım Çözüm

1
Store the database credentials securely in AWS Secrets Manager, which natively supports automatic rotation for Amazon RDS databases using a Lambda rotation helper.
Secrets are encrypted at rest and can be rotated automatically without application downtime.
This fulfills the requirement of secure storage and automatic rotation.
2
In the Lambda function code, write the API call to retrieve the secret outside of the handler function, storing the result in a global or static variable.
The secret is fetched once during the function's cold start (initialization phase) and remains in memory for subsequent warm invocations.
This minimizes the number of API calls to Secrets Manager, lowering costs and reducing latency by reusing the execution context.

Anahtar Kavram

AWS Lambda execution context reuse can be leveraged to cache static configuration and credentials retrieved from AWS Secrets Manager, optimizing performance and reducing external API call costs.
Soru 1527Soru

A developer is configuring a Lambda function named `DataProcessor` in AWS Account A (111122223333111122223333) to write records to an Amazon DynamoDB table in AWS Account B (444455556666444455556666). The Lambda function's execution role is named `LambdaExecutionRole`.

To facilitate cross-account access, the developer creates an IAM role named `CrossAccountDynamoDbRole` in Account B with a permission policy that allows writing to the DynamoDB table. The trust policy for `CrossAccountDynamoDbRole` in Account B is configured as follows:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:role/LambdaExecutionRole"
},
"Action": "sts:AssumeRole"
}
]
}

Which TWO additional actions must the developer take to enable the Lambda function to write to the DynamoDB table? (Select TWO.)

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

Cevabı ve açıklamayı göster

Cevap: Attach a permission policy to the Lambda execution role in Account A that allows the sts:AssumeRole action on the ARN of the IAM role in Account B.; Modify the Lambda function code to call the sts:AssumeRole API operation to retrieve temporary credentials, and use those credentials to instantiate the DynamoDB client.

Cevap

Attach a permission policy to the Lambda execution role in Account A that allows the sts:AssumeRole action on the IAM role in Account B, and modify the Lambda function code to retrieve temporary credentials using the sts:AssumeRole API operation to initialize the DynamoDB client.
To successfully establish cross-account access via role assumption, a developer must configure both sides of the relationship: the trusting account (Account B) must allow the trusted entity (the Lambda execution role in Account A) to assume the role, and the trusted entity must have permissions to perform the assumption action. Finally, the application code must actively assume the role to acquire temporary credentials for accessing the target resource.

Adım Adım Çözüm

1
Configure the identity-based policy in Account A.
Attached a policy to the Lambda execution role that grants permission to assume the cross-account role.
Before an IAM role can be assumed, the caller (Lambda execution role) must be explicitly granted the sts:AssumeRole permission in its identity-based policy.
2
Implement role assumption in the Lambda function code.
The Lambda function uses the AWS SDK to call the sts:AssumeRole API.
Retrieving temporary security credentials for the target role allows the application to authenticate using an identity from the target account (Account B).
3
Initialize the DynamoDB client with temporary credentials.
The DynamoDB client is instantiated using the temporary Access Key ID, Secret Access Key, and Session Token.
This ensures that subsequent PutItem API requests to the DynamoDB table in Account B are authorized under the permissions of the assumed role.

Anahtar Kavram

Cross-account IAM role assumption
Soru 1528Soru

An AWS Lambda function in Account A (111111111111111111111111) uses its execution role, `LambdaExecutionRole`, to retrieve parameters from AWS Systems Manager Parameter Store in Account B (222222222222222222222222). To perform this task, the function's code executes an AWS STS `AssumeRole` API call targeting an IAM role in Account B named `ParameterReaderRole`. Although `LambdaExecutionRole` is granted permissions to perform `sts:AssumeRole` on the target resource, the invocation fails with an `AccessDenied` error. The trust policy for `ParameterReaderRole` is configured as follows:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}

How should the developer modify the trust policy of `ParameterReaderRole` to resolve this issue?

Cevabı ve açıklamayı göster

Cevap: Change the Principal block in the trust policy of ParameterReaderRole to reference the Lambda function's execution role ARN: "AWS": "arn:aws:iam::111111111111:role/LambdaExecutionRole".

Cevap

Change the Principal block in the trust policy of ParameterReaderRole to reference the Lambda function's execution role ARN: "AWS": "arn:aws:iam::111111111111:role/LambdaExecutionRole".
The correct answer is the option proposing to change the Principal block to reference the Lambda function's execution role ARN. When a Lambda function runs code that calls `sts:AssumeRole`, the identity making the request is the function's execution role. Therefore, the trust policy of the target role in Account B must explicitly specify that execution role as a trusted principal to allow the cross-account role assumption to succeed.

Adım Adım Çözüm

1
Identify the caller initiating the sts:AssumeRole API call.
The caller is the Lambda function running under the credentials of its execution role: arn:aws:iam::111111111111:role/LambdaExecutionRole.
When a Lambda function executes code to assume a role, the execution role is the IAM identity that performs the action.
2
Analyze the existing trust policy of the destination IAM role (ParameterReaderRole) in Account B.
The trust policy currently trusts the service principal 'lambda.amazonaws.com'.
This configuration allows the Lambda service itself to assume the role (e.g., as a function execution role), but does not trust the execution role of a specific function in another account.
3
Modify the trust policy principal to match the caller.
The principal block is updated to trust the ARN of the Lambda execution role in Account A.
To establish a cross-account trust relationship, the trust policy in the target account must explicitly list the trusted IAM entity (the execution role) from the source account as the principal.

Anahtar Kavram

Cross-Account IAM Role Assumption and Trust Policies
Tahmini Süre:1m 30s
Soru 1529Soru

A developer is building a serverless web application using Amazon API Gateway and an AWS Lambda function with a Lambda proxy integration. During testing, client HTTP requests receive an HTTP 502 Bad Gateway error. The CloudWatch logs show that the Lambda function completed its execution successfully and returned the application data as a plain JSON string. How can the developer resolve this issue?

Cevabı ve açıklamayı göster

Cevap: Modify the Lambda function response to return a JSON object containing a statusCode integer and a stringified JSON payload in the body field.

Cevap

Modify the Lambda function response to return a JSON object containing a statusCode integer and a stringified JSON payload in the body field.
The correct solution is to modify the Lambda function's response. In Amazon API Gateway Lambda proxy integration, API Gateway expects the backend Lambda function to return a response in a specific JSON format. This format must include the statusCode integer field and the response payload as a stringified JSON within the body field. If the Lambda function returns a plain JSON string directly, API Gateway cannot map it to an HTTP response and fails with a 502 Bad Gateway error.

Adım Adım Çözüm

1
Analyze the 502 Bad Gateway error message and the successful Lambda execution logs.
Identify that the Lambda function execution succeeded but API Gateway failed to parse the returned payload.
A 502 Bad Gateway error with successful execution logs indicates that the communication between API Gateway and Lambda succeeded, but the response format from Lambda is incompatible with the integration type.
2
Check the integration type configured in API Gateway.
Confirm that Lambda proxy integration is enabled.
Lambda proxy integration mandates a strict response format from the backend, whereas custom integration allows returning raw payloads mapped via templates.
3
Update the Lambda function code to return a JSON object conforming to the proxy integration response contract.
The function now returns an object with a statusCode integer and a stringified payload in the body key.
This format allows API Gateway to successfully parse the response and construct the final HTTP response for the client.

Anahtar Kavram

API Gateway Lambda Proxy Integration Response Format

Alternatif Yöntem

If modifying the Lambda function code is not possible or desired, the developer can change the API Gateway integration type from Lambda proxy integration to Lambda custom integration. This allows API Gateway to accept the plain JSON payload and map it to an HTTP response using Integration Response mapping templates.
Tahmini Süre:1m 30s
Soru 1530Soru

A developer is building a fleet management system that tracks real-time vehicle locations. The telemetry data is stored in an Amazon DynamoDB table with `VehicleID` as the partition key and `Timestamp` as the sort key. The developer needs to retrieve the location data for a specific vehicle over the past 2424 hours. Which of the following approaches should the developer use to retrieve this data with the lowest latency and minimal Read Capacity Unit (RCU) consumption?

Cevabı ve açıklamayı göster

Cevap: Perform a Query operation on the table with a key condition expression specifying the VehicleID and a range comparison on the Timestamp.

Cevap

Perform a Query operation on the table with a key condition expression specifying the VehicleID and a range comparison on the Timestamp.
Performing a Query operation on the table with a key condition expression specifying the partition key (VehicleID) and a range comparison on the sort key (Timestamp) is the most efficient method. DynamoDB queries target only the physical partition where the specific partition key's items reside and read the sorted items sequentially, consuming Read Capacity Units (RCUs) proportional only to the returned items.

Adım Adım Çözüm

1
Analyze the access pattern and the primary key schema.
The access pattern requires retrieving data for a specific vehicle (VehicleID) over a time range (Timestamp). The table is already structured with VehicleID as the partition key and Timestamp as the sort key.
Identifying the alignment between the query requirements and the table's key schema helps determine the most direct retrieval operation.
2
Compare DynamoDB read operations (Query vs. Scan).
A Query operation can target a single partition using the partition key and filter the sort key. A Scan operation examines every partition and item in the table.
Selecting Query over Scan ensures that only relevant items are read, reducing cost (RCUs) and latency.
3
Formulate the Query operation parameters.
Use the KeyConditionExpression parameter with VehicleID = :v_id AND #ts BETWEEN :t1 AND :t2.
This targets the correct partition and uses the sort key to return only the telemetry data from the desired 24-hour window.

Anahtar Kavram

DynamoDB Query vs Scan efficiency and primary key design.
Tahmini Süre:1m 30s
Soru 1531Soru

A developer is configuring a serverless application where an Amazon Simple Queue Service (Amazon SQS) queue triggers an AWS Lambda function to process messages. During integration testing, the developer notices that some messages are being processed multiple times by different Lambda invocations, even though the Lambda function eventually runs successfully. The Lambda function is currently configured with an execution timeout of 15 seconds15\text{ seconds}. Which two actions should the developer take to resolve this issue? (Select two.)

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

Cevabı ve açıklamayı göster

Cevap: Increase the visibility timeout of the Amazon SQS queue to at least 90 seconds90\text{ seconds}.; Ensure the Lambda function's execution timeout is configured to be greater than the maximum time required to process the batch of messages.

Cevap

To resolve the duplicate processing issue, the developer must increase the SQS visibility timeout to at least 6 times the Lambda function's timeout (90 seconds90\text{ seconds}) and ensure the Lambda function's execution timeout is configured to be greater than the maximum time required to process the batch of messages.
To prevent duplicate processing of SQS messages by Lambda, the SQS queue's visibility timeout must be set to at least 6 times the Lambda function's timeout. With a 15 seconds15\text{ seconds} Lambda timeout, the visibility timeout must be at least 90 seconds90\text{ seconds} (15 seconds×615 \text{ seconds} \times 6). Additionally, the Lambda execution timeout itself must be configured to be greater than the maximum time needed to process a batch of messages to prevent premature termination.

Adım Adım Çözüm

1
Analyze the relationship between the SQS visibility timeout and the Lambda execution timeout.
Identify that if the SQS visibility timeout is shorter than the Lambda execution time (or not scaled correctly), SQS will make the message visible again before the Lambda function completes, leading to duplicate invocations.
This determines why messages are being reprocessed while the original invocation is still running.
2
Configure the SQS visibility timeout based on the Lambda timeout.
Increase the SQS visibility timeout to at least 6 times the Lambda timeout (15 seconds×6=90 seconds15\text{ seconds} \times 6 = 90\text{ seconds}).
This satisfies the AWS recommended best practice and prevents concurrent duplicate processing of messages that are still active.
3
Review and adjust the Lambda function timeout.
Ensure the Lambda function timeout is greater than the maximum batch processing time.
This prevents premature function termination, which would otherwise result in a failed execution and subsequent message reprocessing.

Anahtar Kavram

Integrating Amazon SQS with AWS Lambda event source mapping and managing visibility timeout and execution timeout relationships.
Soru 1532Soru

A developer is building a medical monitoring application that stores periodic heart rate readings from wearable sensors in an Amazon DynamoDB table. The table uses `DeviceID` as the partition key and `Timestamp` as the sort key. The developer needs to retrieve all heart rate readings for a specific device that are greater than 100 bpm100\text{ bpm} within a specific 2424-hour window. Which two actions should the developer take to achieve this requirement?

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

Cevabı ve açıklamayı göster

Cevap: Perform a `Query` operation on the table using the `DeviceID` and `Timestamp` in the key condition expression.; Use a `FilterExpression` in the `Query` operation to return only the records with a heart rate greater than 100 bpm100\text{ bpm}.

Cevap

To retrieve the heart rate data efficiently, the developer should perform a `Query` operation on the table using the `DeviceID` and `Timestamp` in the key condition expression, and use a `FilterExpression` in the `Query` operation to return only the records with a heart rate greater than 100 bpm100\text{ bpm}.
To retrieve data efficiently from DynamoDB, the developer should use the `Query` operation. By specifying the partition key (`DeviceID`) and the sort key (`Timestamp`) in the key condition expression, the query only reads the items that belong to that specific device and time window. Because heart rate is a non-key attribute, a filter expression is used to discard items that do not meet the criteria (greater than 100 bpm100\text{ bpm}) before the response is returned to the client, which reduces network utilization.

Adım Adım Çözüm

1
Identify the primary keys of the table.
The table has `DeviceID` as the partition key and `Timestamp` as the sort key.
This allows targeting a specific device and time range directly.
2
Select the appropriate API operation.
A `Query` operation is selected instead of a `Scan` operation.
A `Query` operation reads only the required partition and sort key range, while a `Scan` operation reads all items in the table, wasting Read Capacity Units (RCUs).
3
Determine how to filter non-key attributes.
Use a `FilterExpression` in the query to restrict the response to items where the heart rate is greater than 100 bpm100\text{ bpm}.
Since heart rate is not a key attribute, it cannot be in the key condition expression, but a filter expression will discard non-matching items on the server side to reduce network data transfer.

Anahtar Kavram

Optimizing DynamoDB retrieval using Query operations and FilterExpressions instead of full table Scans, and following secure credential management.
Soru 1533Soru

A developer is building a high-throughput transaction ledger consumer that runs as a containerized service on Amazon ECS. The service polls messages from an Amazon SQS FIFO queue, processes the transactions, and writes the results to an external database.

The queue is configured with a default visibility timeout of 3030 seconds. Under heavy load, the database response times slow down, and processing a batch of messages can take up to 5050 seconds. Consequently, transaction records are being duplicated in the database because messages are returning to the queue before processing is complete. Additionally, the ECS task is experiencing performance degradation due to client initialization overhead.

Which of the following actions should the developer take to resolve the duplication issues and optimize client performance? (Select TWO.)

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

Cevabı ve açıklamayı göster

Cevap: Increase the default visibility timeout of the SQS queue to at least 6060 seconds to ensure messages remain invisible to other consumers until processing is completed.; Instantiate the SQS client and database connection pools outside the message processing loop to reuse them across multiple execution cycles.

Cevap

The correct actions are to increase the default visibility timeout of the SQS queue to at least 6060 seconds and to instantiate the SQS client outside the message processing loop.
Increasing the queue's default visibility timeout to at least 6060 seconds ensures the message remains hidden from other consumers while the 5050-second processing completes. Instantiating the client and connection pool outside the main processing loop allows the application to reuse connections across multiple message polls, avoiding CPU and network overhead.

Adım Adım Çözüm

1
Analyze the cause of message duplication.
The message processing time of 5050 seconds exceeds the visibility timeout of 3030 seconds, meaning messages return to the queue before the worker finishes processing.
This identifies the configuration parameter that must be changed to prevent concurrent duplicate deliveries.
2
Calculate and apply the correct SQS visibility timeout.
Increase the visibility timeout to at least 6060 seconds to exceed the maximum processing duration of 5050 seconds.
The visibility timeout must be set to a value greater than the maximum expected message processing time.
3
Resolve the performance degradation in the ECS container.
Move the SQS client and database pool initialization outside the message processing loop.
Reusing clients across polling iterations avoids repeated connection setup and credential retrieval overhead.

Anahtar Kavram

Configuring SQS visibility timeout based on consumer processing time and optimizing AWS SDK client reuse.
Tahmini Süre:2m 0s
Soru 1534Soru

A developer is building a movie ticket booking platform. The ticket reservation details are stored in an Amazon DynamoDB table with ReservationIDReservationID as the partition key. To generate real-time metrics, the application must frequently retrieve all reservations associated with a specific ShowIDShowID. The query must be highly performant and cost-effective as the database grows.

Which solution meets these requirements with the lowest latency and resource consumption?

Cevabı ve açıklamayı göster

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

Cevap

Create a Global Secondary Index (GSI) with the target query attribute as the partition key, and perform a Query operation on the GSI.
Creating a Global Secondary Index (GSI) with the target query attribute as the partition key is the correct approach. It enables the application to use the Query API instead of Scan, ensuring that only the items associated with the target attribute value are read. This consumes minimal Read Capacity Units (RCUs) and executes with low, predictable latency regardless of the table's overall size.

Adım Adım Çözüm

1
Analyze the table primary key structure and retrieval requirements.
The base table uses a simple primary key with a partition key of ReservationIDReservationID. Querying by ShowIDShowID directly on the base table is not supported because ShowIDShowID is a non-key attribute.
DynamoDB only allows Query operations on the primary key attributes (partition key and optional sort key) of the table or an index.
2
Determine the optimal indexing strategy for the non-key attribute.
Create a Global Secondary Index (GSI) with ShowIDShowID as the partition key.
Since the partition key of the base table is different from the search attribute, a GSI is required to allow direct querying on the new partition key.
3
Select the correct API operation for retrieval.
Perform a Query operation against the GSI using the specific ShowIDShowID.
A Query operation is much more efficient than a Scan because it only reads the items matching the key value, reducing Read Capacity Unit (RCU) consumption and latency.

Anahtar Kavram

Using Global Secondary Indexes (GSIs) and Query operations to efficiently retrieve data from Amazon DynamoDB tables on non-primary key attributes.
Soru 1535Soru

A developer is configuring an AWS Lambda function to process messages from an Amazon SQS standard queue. The Lambda function has a timeout of 20 seconds. The SQS queue has a default visibility timeout of 20 seconds. During testing, the developer observes that some messages are processed more than once by different Lambda executions. Which configuration change should the developer make to resolve this issue?

Cevabı ve açıklamayı göster

Cevap: Increase the default visibility timeout of the SQS queue to 120 seconds.

Cevap

Increase the default visibility timeout of the SQS queue to 120 seconds.
Increasing the SQS visibility timeout to 120 seconds (which is 6 times the Lambda function's timeout of 20 seconds) ensures that a message remains invisible to other consumers long enough for the Lambda function to finish processing, retry if necessary, and delete the message from the queue.

Adım Adım Çözüm

1
Identify the current configuration of the Lambda function and the SQS queue.
Lambda timeout is 20 seconds, and SQS visibility timeout is 20 seconds.
To determine the relationship between function execution duration and message visibility.
2
Apply AWS best practices for SQS queue visibility timeout when integrated with Lambda.
The SQS visibility timeout should be set to at least 6 times the Lambda function timeout.
This recommendation prevents duplicate message processing by ensuring that if a batch fails or is retried, the message does not become visible to other instances too quickly.
3
Calculate the recommended visibility timeout and update the queue configuration.
20 seconds multiplied by 6 equals 120 seconds.
To set the queue's default visibility timeout to 120 seconds.

Anahtar Kavram

Integrating Amazon SQS with AWS Lambda requires setting the queue's visibility timeout to at least 6 times the Lambda function's timeout to prevent duplicate processing.
Tahmini Süre:1m 30s
Soru 1536Soru

An e-commerce order fulfillment system uses an Amazon SQS standard queue to trigger an AWS Lambda function for invoice generation. The third-party invoicing API can take up to 2525 seconds to respond, so the developer configures the Lambda function's timeout to 3030 seconds. During high-traffic periods, customers report receiving duplicate invoices for a single order. Additionally, the developer must ensure that the Lambda function can authenticate with SQS securely without storing access keys in the codebase.

Which two actions should the developer take to resolve the duplication issue and ensure secure credentials management? (Select TWO.)

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

Cevabı ve açıklamayı göster

Cevap: Increase the visibility timeout of the SQS queue to at least 180180 seconds to prevent message processing overlaps.; Assign an IAM execution role with permissions to access the SQS queue to the Lambda function, and initialize the SQS SDK client without specifying hardcoded credentials.

Cevap

The developer should increase the SQS queue's visibility timeout to at least 180 seconds and configure the Lambda function with an IAM execution role, initializing the SDK client without hardcoded credentials.
Increasing the SQS visibility timeout to at least 180180 seconds (six times the Lambda function's timeout of 3030 seconds) ensures that the message remains hidden from other consumers for the entire duration of the Lambda function's execution. Using an IAM execution role assigned to the Lambda function allows the AWS SDK to retrieve temporary security credentials from the instance metadata service automatically, preventing credentials from being hardcoded.

Adım Adım Çözüm

1
Determine the optimal SQS visibility timeout to prevent duplicates during processing.
Identify that the SQS visibility timeout must be set to at least 66 times the Lambda function timeout plus any batch window. Since the Lambda timeout is 3030 seconds, the visibility timeout should be at least 180180 seconds.
This prevents messages from becoming visible to other pollers while the Lambda function is still executing.
2
Implement a secure credential management strategy for the SQS consumer client.
Configure an IAM role with SQS access permissions and assign it as the Lambda function's execution role, then instantiate the SQS client using default credentials.
This eliminates the need to store AWS access keys in the codebase or configuration environment variables.

Anahtar Kavram

Configuring SQS visibility timeout to match Lambda execution limits and implementing IAM-based SDK authentication.
Tahmini Süre:1m 30s
Soru 1537Soru

A developer is implementing a web analytics pipeline where user interaction events are sent to a custom Amazon EventBridge event bus. The developer configures an EventBridge rule to route these events to an Amazon Kinesis Data Stream for real-time analytics. The stream has 10 active shards to handle the expected volume. The developer wants to ensure that all events for any given user session are processed in chronological order by the consumer application, while also distributing the write load evenly across all shards to prevent write throttling.

Which target configuration in EventBridge meets these requirements?

Cevabı ve açıklamayı göster

Cevap: Configure the target with a PartitionKeyPath pointing to the user session ID field ($.detail.sessionId) in the event payload.

Cevap

Configure the target with a PartitionKeyPath pointing to the user session ID field ($.detail.sessionId) in the event payload.
Configuring the EventBridge target with a PartitionKeyPath pointing to the user session ID ensures that all events from a given session share the same partition key. Kinesis Data Streams maps records with the same partition key to the same shard, preserving the order of execution. Because there are many unique user sessions (high cardinality), the traffic is distributed evenly across all shards, preventing throttling.

Adım Adım Çözüm

1
Analyze the requirements for stream ingestion and processing.
The solution requires two things: preserving chronological ordering of events within a user session, and distributing events evenly across Kinesis shards.
Understanding these twin constraints is necessary to choose the correct partition key configuration.
2
Determine the mechanism for ordering and load distribution in Kinesis Data Streams.
Kinesis determines the destination shard by hashing the partition key of each record. Records with the same partition key are sent to the same shard and processed in order.
This shows that the partition key must represent the logical grouping that requires ordering (the user session).
3
Evaluate the cardinality of potential partition keys.
A high-cardinality key like user session ID distributes events evenly across 10 shards. A low-cardinality key or static string causes hot shards. A timestamp fails to guarantee that all events of a specific session land on the same shard.
Selecting the high-cardinality session ID via PartitionKeyPath meets both the scaling and ordering requirements.

Anahtar Kavram

Selecting high-entropy partition keys using PartitionKeyPath on EventBridge targets is crucial for Kinesis Data Streams to achieve balanced shard utilization and maintain order.
Soru 1538Soru

A developer is building a collaborative project management application where team members can assign tasks to each other. The application stores task details in an Amazon DynamoDB table with `ProjectIDProjectID` as the partition key and `TaskIDTaskID` as the sort key.

The developer needs to implement two requirements:
1. Retrieve all tasks within a specific project that have a status of 'In Progress'.
2. Retrieve all tasks across all projects assigned to a specific team member using their `AssigneeIDAssigneeID`.

Additionally, the developer must initialize the AWS SDK DynamoDB client securely within an AWS Lambda function that executes these queries.

Which two actions should the developer take to meet these requirements efficiently and securely? (Select two.)

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

Cevabı ve açıklamayı göster

Cevap: Perform a `Query` operation on the base table using a `KeyConditionExpression` on `ProjectIDProjectID` and a `FilterExpression` on the status attribute.; Create a Global Secondary Index (GSI) with `AssigneeIDAssigneeID` as the partition key, and perform a `Query` operation against this GSI.

Cevap

To retrieve tasks by project status, perform a Query operation on the base table with a KeyConditionExpression on the partition key and a FilterExpression on the status. To retrieve tasks by assignee across all projects, create a Global Secondary Index with the assignee ID as the partition key and perform a Query against it. Additionally, initialize the DynamoDB client without hardcoding credentials, allowing it to use the Lambda execution role.
The correct approach is to use a Query operation on the base table for project-specific queries since the partition key is known. To query across different partitions (projects) by assignee, a Global Secondary Index is required because it allows a different partition key. For security, the DynamoDB client should rely on the Lambda function's IAM execution role instead of hardcoded credentials.

Adım Adım Çözüm

1
Analyze the query pattern for project tasks.
Querying by `ProjectIDProjectID` uses the base table's partition key, so a `Query` operation with a `KeyConditionExpression` and a `FilterExpression` is the most efficient choice.
This avoids scanning the entire table and limits the read to a single partition.
2
Analyze the query pattern for assignee tasks across all projects.
Since the query needs to span multiple projects (different partition keys), a Global Secondary Index (GSI) must be created with `AssigneeIDAssigneeID` as the partition key.
Local Secondary Indexes require the same partition key as the base table, so only a GSI can query across different projects.
3
Evaluate security best practices for SDK client initialization in AWS Lambda.
Initialize the client using the default credential provider chain, which automatically uses the Lambda function's IAM execution role.
This avoids hardcoding credentials in the code, which is a severe security vulnerability.

Anahtar Kavram

Data Store Operations with Amazon DynamoDB
Soru 1539Soru

A developer is building a serverless application where an AWS Lambda function writes records to a legacy on-premises database. The database can handle a maximum of 10 concurrent connections. During peak hours, traffic spikes cause the Lambda function to scale, which overloads the database and causes connections to drop. How should the developer configure the Lambda function to prevent overloading the database?

Cevabı ve açıklamayı göster

Cevap: Set the reserved concurrency limit of the Lambda function to 10.

Cevap

Configure the Lambda function's reserved concurrency limit to 10 to restrict the maximum number of concurrent execution environments.
Setting the reserved concurrency limit of the Lambda function to 10 restricts the maximum number of concurrent instances of the function that can execute at any given time. This effectively limits the maximum number of concurrent database connections to 10, preventing the function from overloading the legacy database.

Adım Adım Çözüm

1
Analyze the database's connection limits and Lambda's automatic scaling behavior.
Identify that rapid horizontal scaling of Lambda functions during traffic spikes results in too many concurrent connection attempts, crashing the database.
By default, Lambda scales to meet demand, which can easily exceed the limits of downstream traditional or legacy systems.
2
Evaluate configuration methods to control the concurrent scaling of AWS Lambda.
Determine that reserved concurrency caps the maximum number of concurrent instances allowed to execute for a specific function.
Restricting the concurrent executions directly limits the maximum number of active database connections the function can establish.
3
Apply the configuration changes by setting the reserved concurrency limit to 10.
The Lambda function is constrained to a maximum of 10 concurrent executions, ensuring the legacy database connections never exceed 10.
This implements a hard limit on scale-out concurrency to match the downstream dependency constraints.

Anahtar Kavram

Managing AWS Lambda scaling and database connection pooling using Reserved Concurrency.

Alternatif Yöntem

Use Amazon RDS Proxy to manage and pool database connections, allowing the Lambda function to scale without overloading the database.
Tahmini Süre:1m 30s
Soru 1540Soru

A developer is configuring an AWS Lambda function to process real-time financial transactions from an Amazon Kinesis Data Stream. The function must validate each transaction by invoking a third-party payment gateway's public API endpoint over the internet, and then save the transaction status to an Amazon RDS database located in a private subnet of a VPC.

The developer configures the Lambda function to run inside the same VPC and private subnet as the RDS database. During testing, the developer observes that the Lambda function is successfully triggered by the Kinesis stream but consistently times out after 15 seconds without executing the API call or database write.

What is the root cause of this issue and how should it be resolved?

Cevabı ve açıklamayı göster

Cevap: The Lambda function lacks internet access because it is deployed in a private VPC subnet without a route to a NAT Gateway. The developer must add a NAT Gateway in a public subnet and update the private subnet's route table to route external traffic to the NAT Gateway.

Cevap

The Lambda function lacks internet access because it is deployed in a private VPC subnet without a route to a NAT Gateway. The developer must add a NAT Gateway in a public subnet and update the private subnet's route table to route external traffic to the NAT Gateway.
When a Lambda function is configured to connect to a VPC, it is assigned an ENI to communicate with VPC resources like RDS. However, it loses its default public internet connectivity. To allow the function to call a third-party API over the internet, a NAT Gateway must be configured in a public subnet of the VPC, and the route table of the Lambda function's private subnet must have a route pointing 0.0.0.0/0 to the NAT Gateway.

Adım Adım Çözüm

1
Analyze the network path required for the Lambda function's operations.
The Lambda function needs to connect to a private RDS instance (inside the VPC) and a public third-party API endpoint (outside the VPC).
This establishes that both internal VPC and external internet routing are required.
2
Determine the impact of VPC configuration on Lambda outbound connectivity.
Configuring a Lambda function to run inside a private VPC subnet enables local VPC access but removes default outbound internet access.
By default, Lambda functions in a VPC do not have access to the internet unless routed through a NAT Gateway or using VPC endpoints.
3
Select the correct networking components to enable outbound internet access from the private subnet.
A NAT Gateway must be deployed in a public subnet, and the route table for the private subnet must route 0.0.0.0/0 traffic to the NAT Gateway.
This allows the Lambda function to reach the public third-party API endpoint while retaining its connection to the private RDS database.

Anahtar Kavram

VPC Networking for AWS Lambda when consuming Kinesis Data Streams and accessing public APIs
ÖncekiSayfa 77 / 78Sonraki