A developer is building a Lambda function that reads from an Amazon DynamoDB table. The table name is currently hard-coded in the function, but the table name may change in the future. The developer wants to avoid modifying the Lambda code when the table name changes. Which solution is the MOST efficient?
Choose an answer
Tap an option to check your answer.
Correct answer: Define the DynamoDB table name as an environment variable for the Lambda function and read it using the language's standard environment-variable methods..
Why this is the answer
Defining the DynamoDB table name as an environment variable is the most efficient solution. Lambda environment variables are designed for exactly this purpose: storing configuration settings that can change without requiring code modification. The function can easily access these variables using standard language features (e.g., process.env.TABLENAME in Node.js, os.environ['TABLENAME'] in Python). Storing the table name in /tmp is incorrect because /tmp is ephemeral storage and its contents are not guaranteed to persist across invocations, nor is it a standard way to pass configuration. Placing it in a Lambda layer would require updating and deploying the layer every time the table name changes, which is less efficient than updating an environment variable. Declaring a global variable inside the Lambda function code still hard-codes the value within the deployment package, requiring a code update and redeployment if the table name changes.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed