A developer is configuring an AWS Lambda function that reads data from an Amazon DynamoDB table. Currently, the function initializes the AWS SDK client inside the handler function on every invocation, and the DynamoDB table name is hardcoded in the function code. Which two actions should the developer take to improve performance and adhere to AWS development best practices? (Select two.)
- Initialize the AWS SDK client outside of the Lambda handler functionCevap
- Store the DynamoDB table name as a Lambda environment variable and retrieve it in the codeCevap
- CIncrease the Lambda function timeout configuration to decrease the frequency of cold starts
- DEmbed IAM access keys directly in the Lambda function's deployment package
- EConfigure the Lambda function to run inside a private VPC subnet to reduce execution environment setup time
Cevap
Initialize the AWS SDK client outside the handler function and store the DynamoDB table name in a Lambda environment variable.
Moving the client instantiation outside of the handler function takes advantage of execution context reuse, so subsequent requests do not pay the penalty of initializing the SDK. Storing configuration details in environment variables allows changes without modifying source code.
Adım Adım Çözüm
Anahtar Kavram
AWS Lambda execution context reuse and environment variables
Tahmini Süre:1m 0s