A security scan finds a third-party API key hardcoded in a function's source code. What is the best remediation?
Show the answer
Correct answerB. Retrieve the key from a secrets manager at runtime using the execution role
AWhy not this: Repository encryption does not stop developers or anyone with code access from reading the key.
BWhy this is right: A secrets manager with role-based retrieval keeps the key out of code and configuration.
CWhy not this: Plaintext environment variables are visible to anyone who can read the function configuration.
DWhy not this: Rotation shortens exposure but the key stays in code and in version history.
A secrets manager keeps the key out of code and configuration, and the function's execution role controls who can retrieve it at runtime. A plaintext environment variable is tempting but still exposes the secret to anyone who can read the function configuration.