Skip to content
BytePatterns

DVA-C02 · Domain 3: Deployment · 24% of the exam

Task 3.2: Test applications in development environments

Testing before production: invoking deployed code, integration tests and mocks for external dependencies, API Gateway stages as test endpoints, deploying a stack to a separate environment with AWS SAM, and testing event-driven flows.

Study it

  • AWS SAM: templates, local testing and deploying to another environment

    Lesson coming

  • Test events, integration tests and mocks

    Lesson coming

  • API Gateway stages, stage variables and custom domains

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the AWS documentation page that proves it.

Question 1 · choose 1

A front-end team needs to start testing against GET /orders/{id}, but the backend service that will serve it has not been built. Both teams have agreed on the response format. The developer wants a deployed API endpoint that returns a fixed sample order now, without deploying any backend code. What should the developer configure?

  1. AA Lambda proxy integration whose function returns a hard-coded sample order
  2. BAn HTTP API route with a mock integration that returns the sample
  3. CA REST API method with a mock integration that returns the sample
  4. DAPI caching on the stage, loaded once with the sample order
Show the answer and why
  • AA Lambda proxy integration whose function returns a hard-coded sample order

    Incorrect

    This would work, but it deploys backend code, the function, which the requirement rules out.

  • BAn HTTP API route with a mock integration that returns the sample

    Incorrect

    Mock integrations are a REST API feature. HTTP APIs do not support them.

  • CA REST API method with a mock integration that returns the sample

    Correct

    A mock integration lets API Gateway generate the response itself, with no backend, which unblocks teams that depend on the API.

  • DAPI caching on the stage, loaded once with the sample order

    Incorrect

    API caching stores responses that come back from the endpoint for a TTL, so there must be an endpoint to call in the first place.

REST API mock integrations return responses defined in API Gateway, which is a common way to test clients before the backend exists.

Question 2 · choose 1

An AWS SAM application is deployed to a dev stack with sam deploy. The developer must now deploy the same template to a separate staging stack with its own stack name and parameter values, such as a larger memory size. Developers and the release pipeline must be able to repeat the staging deployment with one short command. What should the developer do?

  1. ADefine staging in samconfig.toml and run sam deploy --config-env staging
  2. BRun sam sync --watch against a stack named for staging
  3. CRun sam deploy --guided for each release and type in the staging values
  4. DRun sam local invoke with a file of staging environment variables
Show the answer and why
  • ADefine staging in samconfig.toml and run sam deploy --config-env staging

    Correct

    The configuration file holds named environments with their own values, such as the stack name and parameter overrides, and --config-env picks which environment's values sam deploy uses.

  • BRun sam sync --watch against a stack named for staging

    Incorrect

    sam sync is a rapid workflow recommended for development environments; for other environments AWS recommends sam deploy or a CI/CD pipeline.

  • CRun sam deploy --guided for each release and type in the staging values

    Incorrect

    --guided walks a person through interactive prompts. A pipeline cannot answer them, and retyping values on every release is error-prone.

  • DRun sam local invoke with a file of staging environment variables

    Incorrect

    sam local invoke runs one invocation of a function locally. It does not deploy anything to AWS.

samconfig.toml environments keep per-environment deploy settings, so the same template deploys to dev, staging or prod with --config-env.

Question 3 · choose 1

A developer has written an event pattern for a new Amazon EventBridge rule and has a few sample event JSON documents: some should match and some should not. Before creating the rule, the developer wants a quick automated check of which samples the pattern matches, without sending any event to an event bus or invoking any target. What should the developer use?

  1. AAn archive on the bus, replayed to the new rule with yesterday's events
  2. BThe TestEventPattern API, called with the pattern and each sample event
  3. CPutEvents calls that send the samples to a test bus with the rule attached
  4. Dsam local invoke with each sample event passed to the target function
Show the answer and why
  • AAn archive on the bus, replayed to the new rule with yesterday's events

    Incorrect

    A replay resends archived events to the event bus, where matching rules deliver them to their targets, and the rule must already exist.

  • BThe TestEventPattern API, called with the pattern and each sample event

    Correct

    TestEventPattern tests whether a given event pattern matches a provided event and returns a true or false result, without touching any bus.

  • CPutEvents calls that send the samples to a test bus with the rule attached

    Incorrect

    PutEvents sends events to EventBridge so that rules can match them. That sends events to a bus, which the developer wants to avoid.

  • Dsam local invoke with each sample event passed to the target function

    Incorrect

    sam local invoke runs a function locally with an event. It tests the function's code, not whether EventBridge would match the event.

TestEventPattern is the unit test for an event pattern; it checks matching logic without events reaching a bus or a target.

Question 4 · choose 1

A developer is chasing a logic bug in an AWS Lambda function of an AWS SAM application and wants to set breakpoints, inspect variables and step through the code in an IDE on the laptop, using a sample event. What should the developer do?

  1. AAdd print statements and redeploy the function after each change
  2. BTurn on AWS X-Ray active tracing for the function
  3. CRun sam local invoke with a debug port (-d) and attach the IDE
  4. DRun sam sync --watch and debug the function in the console
Show the answer and why
  • AAdd print statements and redeploy the function after each change

    Incorrect

    This works slowly through the cloud and gives no breakpoints or step-through debugging.

  • BTurn on AWS X-Ray active tracing for the function

    Incorrect

    Tracing records timing of requests in the cloud; it does not stop at breakpoints in the code.

  • CRun sam local invoke with a debug port (-d) and attach the IDE

    Correct

    sam local invoke and start-api accept --debug-port (-d) so that a debugger can attach for local step-through debugging.

  • DRun sam sync --watch and debug the function in the console

    Incorrect

    sam sync updates the cloud copy quickly but does not provide a local step-through debugger.

AWS SAM supports local step-through debugging with debug ports and IDE toolkits.

Question 5 · choose 1

An integration test suite calls AWS Lambda functions with the AWS SDK's Invoke operation. The developer wants to run the same suite on a laptop against the functions defined in an AWS SAM template, by pointing the SDK client at a local endpoint. Which command provides that endpoint?

  1. Asam local start-api
  2. Bsam local invoke
  3. Csam local generate-event
  4. Dsam local start-lambda
Show the answer and why
  • Asam local start-api

    Incorrect

    start-api serves the API's HTTP routes, not the Lambda Invoke API that the SDK calls.

  • Bsam local invoke

    Incorrect

    local invoke runs one function once from the command line; it does not keep an endpoint running for SDK calls.

  • Csam local generate-event

    Incorrect

    generate-event creates sample event payloads; it does not run any function.

  • Dsam local start-lambda

    Correct

    start-lambda starts a local endpoint that emulates AWS Lambda, so SDK Invoke calls can run against local functions.

Use start-lambda for SDK or CLI invocations and start-api for HTTP routes when testing locally.

Question 6 · choose 1

Deployments of an AWS SAM application often fail late because of template mistakes, such as invalid property values, that a quick check could have caught. The developer wants to catch these errors on the laptop before deploying. What should the developer run?

  1. Asam validate with the --lint option
  2. Bsam deploy with --no-execute-changeset
  3. Csam logs for the last failed deployment
  4. Dsam delete followed by a fresh sam deploy
Show the answer and why
  • Asam validate with the --lint option

    Correct

    sam validate checks the template, and --lint runs cfn-lint for deeper validation of CloudFormation properties.

  • Bsam deploy with --no-execute-changeset

    Incorrect

    This still contacts CloudFormation in the cloud to create a change set; it is not a local check.

  • Csam logs for the last failed deployment

    Incorrect

    sam logs reads function logs; it does not check templates before a deployment.

  • Dsam delete followed by a fresh sam deploy

    Incorrect

    Deleting and redeploying repeats the slow failure instead of catching the errors early.

Lint templates locally with sam validate --lint to find mistakes before they reach CloudFormation.

Question 7 · choose 1

While testing a new feature in a development account, a developer sends requests to an AWS Lambda function and wants to watch its new log events, filtered to lines that contain a request ID, as they arrive in CloudWatch Logs. What should the developer use?

  1. AA metric filter on the log group with an alarm
  2. BAn export of the log group to Amazon S3
  3. CCloudWatch Logs Live Tail with a filter on the request ID
  4. DA CloudWatch dashboard that graphs the function's Errors metric
Show the answer and why
  • AA metric filter on the log group with an alarm

    Incorrect

    Metric filters turn log patterns into metrics; they do not show the log lines as they arrive.

  • BAn export of the log group to Amazon S3

    Incorrect

    Exports copy stored logs for later analysis, not a live view.

  • CCloudWatch Logs Live Tail with a filter on the request ID

    Correct

    Live Tail streams new log events as they are ingested, with filtering and highlighting in near real time.

  • DA CloudWatch dashboard that graphs the function's Errors metric

    Incorrect

    A dashboard shows metrics, not the content of individual log events.

Live Tail is the quick way to watch logs while testing changes.

Question 8 · choose 1

A contractor uses a locked-down laptop on which the AWS CLI cannot be installed. The contractor needs to run AWS CLI commands to test resources in the development account and is already signed in to the AWS Management Console. What should the contractor use?

  1. AAn IAM user's access keys typed into a web-based terminal
  2. BAWS CloudShell from the console
  3. CAn Amazon EC2 instance with a public IP address and SSH
  4. DThe AWS Tools for PowerShell, installed on the laptop instead of the CLI
Show the answer and why
  • AAn IAM user's access keys typed into a web-based terminal

    Incorrect

    This creates long-term credentials that are not needed when CloudShell already provides credentials.

  • BAWS CloudShell from the console

    Correct

    CloudShell is a browser-based, pre-authenticated shell with the AWS CLI that uses the console sign-in credentials.

  • CAn Amazon EC2 instance with a public IP address and SSH

    Incorrect

    This needs an SSH client, a key pair and credentials on the instance, which is more setup than needed.

  • DThe AWS Tools for PowerShell, installed on the laptop instead of the CLI

    Incorrect

    This is also software to install on the laptop, which the locked-down device does not allow.

CloudShell gives a ready shell with the CLI and the console user's credentials, directly in the browser.

Practise domain 3 →Practise all domains →