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 seconds to respond, so the developer configures the Lambda function's timeout to 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.)
- Increase the visibility timeout of the SQS queue to at least seconds to prevent message processing overlaps.Cevap
- 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
- CDecrease the SQS queue's visibility timeout to seconds to allow other Lambda instances to immediately retry failed invoice generations.
- DStore the AWS access keys in the Lambda function's environment variables and initialize the SQS SDK client by passing these keys directly into the client constructor.
- EExtend the Lambda function's timeout to minutes and cache the processed invoice IDs in a global variable in the execution context to prevent duplicates.
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 seconds (six times the Lambda function's timeout of 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
Anahtar Kavram
Configuring SQS visibility timeout to match Lambda execution limits and implementing IAM-based SDK authentication.
Tahmini Süre:1m 30s