A developer is running a Lambda function that uses the 'requests' library. The error shown in the exhibit occurs when invoking the function. Which step should the developer take to fix this?
To successfully use the `requests` library in an AWS Lambda function, it must be included as part of the deployment package. This typically involves installing `requests` and its dependencies into a local directory, then zipping that directory along with the function's handler code. Alternatively, for shared dependencies across multiple functions, a Lambda Layer can be created and attached, which is a best practice for managing common libraries efficiently.
Why this answer
The 'requests' library is not included in the AWS Lambda Python runtime by default. To use it, the developer must package the library as a dependency layer or include it in the deployment package. Option B correctly identifies this approach, ensuring the library is available at runtime.
Exam trap
The trap here is that candidates assume AWS Lambda runtimes include popular third-party libraries like 'requests', but in reality only the standard library is provided, so dependencies must be bundled manually.
How to eliminate wrong answers
Option A is wrong because no AWS Lambda Python runtime (including Python 3.9) includes the 'requests' library by default; it must be bundled manually. Option C is wrong because switching to 'urllib' is a workaround, not a fix for the missing dependency, and may require significant code changes. Option D is wrong because the Lambda console does not support installing libraries via pip; dependencies must be packaged locally or via a Lambda layer.