Courseiva

DVA-C02 Development with AWS Services Practice Question

A developer is writing a Lambda function in Node.js that reads a secret from AWS Secrets Manager on every invocation. The function runs frequently, and the developer wants to minimize both latency and the number of Secrets Manager API calls. Which approach should the developer take?

⚠ Common exam trap

The trap here is assuming that any code inside the Lambda handler runs only once per function, when in fact the handler runs on every invocation while global scope persists across warm starts.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Call GetSecretValue inside the handler and cache the value in a variable declared in the global scope of the module.

Declaring the secret variable in the global scope and populating it inside the handler lets warm Lambda execution environments reuse the value across invocations. This minimizes Secrets Manager GetSecretValue calls and latency while preserving correct behavior on cold starts, when the variable is repopulated.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Call GetSecretValue inside the handler and cache the value in a variable declared in the global scope of the module.

    Why this is correct

    Variables declared outside the handler persist across warm invocations of the same execution environment. Fetching the secret once and reusing the cached value reduces Secrets Manager calls and avoids repeated network latency on subsequent warm invocations while still working correctly on cold starts.

  • ✗

    Call GetSecretValue inside the handler on every invocation and enable AWS X-Ray tracing to reduce the API call latency.

    Why it's wrong here

    X-Ray traces requests for observability; it does not accelerate or cache Secrets Manager calls. Calling GetSecretValue on every invocation still incurs API latency and request charges, so this does not meet the goal of reducing the number of Secrets Manager calls.

  • ✗

    Call GetSecretValue in the handler but set the AWS SDK maxRetries to 0 to reduce the number of API calls.

    Why it's wrong here

    Setting maxRetries to 0 disables SDK retry behavior; it does not reduce the initial call count. The function still calls Secrets Manager on every invocation, so latency and API usage remain high, and transient throttling errors become more likely.

  • ✗

    Store the secret as a Lambda environment variable and remove all Secrets Manager permissions from the function role.

    Why it's wrong here

    Environment variables are static, visible in the function configuration, and not automatically rotated. Embedding the secret there eliminates Secrets Manager benefits such as rotation and fine-grained access, and it does not reflect updates without redeploying the function.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

One of 1,135 original DVA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.