Skip to content

DVA-C03 · Domain 3: Testing and Deployment · 22% of the exam

Task 3.1: Prepare application artifacts to be deployed to AWS.

Getting a build ready to ship: dependencies, configuration files and container images inside packages, building, tagging and expiring images in Amazon ECR, code repositories, per-environment configuration with AppConfig, Parameter Store and Secrets Manager, and API Gateway stage URLs and endpoints.

Study it

  • Packaging: dependencies, .zip archives, layers and container images

    Partly covered by: Images, Layers & Multi-Stage Builds

  • Container images in Amazon ECR: building, tagging and lifecycle policies

    Partly covered by: Images, Layers & Multi-Stage Builds

  • Configuration per environment: AWS AppConfig, Parameter Store, Secrets Manager and environment variables

    Partly covered by: ConfigMaps, Secrets & Env

  • Repositories and artifact stores: Git, CodeArtifact and Amazon ECR

    Lesson coming

  • API Gateway stages, stage URLs, endpoints 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

An order service running on Amazon ECS and two AWS Lambda functions share about 40 small configuration values per environment, such as feature switches and service endpoints. One endpoint value must be encrypted at rest. No value needs rotation. The developer wants names like /prod/orders/..., IAM permissions per path, and the lowest cost. What should the developer use?

  1. AOne AWS Secrets Manager secret for each configuration value
  2. BEnvironment variables on each function and task, encrypted with a customer managed key
  3. CAdvanced-tier parameters with a parameter policy on every value
  4. DStandard parameters under /prod/orders/, with a SecureString endpoint
Show the answer and why
  • AOne AWS Secrets Manager secret for each configuration value

    Incorrect

    Secrets Manager charges per secret per month and is built for credentials that need rotation, which none of these values do.

  • BEnvironment variables on each function and task, encrypted with a customer managed key

    Incorrect

    A Lambda function's environment variables are limited to 4 KB in total, and each copy belongs to one function or task, so there is no shared hierarchy to grant access to by path.

  • CAdvanced-tier parameters with a parameter policy on every value

    Incorrect

    The advanced tier is charged per parameter and per API interaction. Values this small fit the standard tier, which has no additional charge.

  • DStandard parameters under /prod/orders/, with a SecureString endpoint

    Correct

    Parameter Store offers hierarchical names that IAM policies can target by path, SecureString encryption with AWS KMS, and standard parameters at no additional charge.

Static configuration goes in Parameter Store (SecureString when it must be encrypted); Secrets Manager is for secrets that need rotation.

Question 2 · choose 1

A Python AWS Lambda function needs machine learning libraries that take about 1.2 GB once unpacked. Deploying it as a .zip archive fails because of the package size. The team wants to keep running the code on Lambda. How should the developer package the function?

  1. AAs a container image in Amazon ECR, built from an AWS base image for Lambda
  2. BAs a smaller .zip with the libraries split across five Lambda layers
  3. CAs the same .zip archive, uploaded through Amazon S3 instead of directly
  4. DAs the same .zip archive, with the function's memory raised to 10,240 MB
Show the answer and why
  • AAs a container image in Amazon ECR, built from an AWS base image for Lambda

    Correct

    A container image can be up to 10 GB uncompressed, including all of its layers, which fits the libraries.

  • BAs a smaller .zip with the libraries split across five Lambda layers

    Incorrect

    The 250 MB unzipped limit covers the deployment package together with its layers, so splitting the libraries into layers does not help.

  • CAs the same .zip archive, uploaded through Amazon S3 instead of directly

    Incorrect

    Uploading through S3 avoids the 50 MB limit for direct uploads, but the 250 MB limit on the unzipped contents still applies.

  • DAs the same .zip archive, with the function's memory raised to 10,240 MB

    Incorrect

    Memory sets the function's runtime memory and CPU. It does not change the size limits of the deployment package.

.zip packages, layers included, are limited to 250 MB unzipped; container images allow up to 10 GB.

Question 3 · choose 1

A new checkout feature is already deployed to an Amazon ECS service but is turned off. The team wants to turn it on without redeploying the service, check that the configuration is valid JSON before it goes out, expose it to callers gradually over 30 minutes, and roll back automatically if a CloudWatch alarm fires. Which approach meets these requirements?

  1. AA Parameter Store parameter that the service reads on every request
  2. BAn AWS AppConfig feature flag with a validator, a linear strategy and an alarm
  3. CA Secrets Manager secret that holds the flag, rotated every 30 minutes
  4. DA JSON file in a versioned S3 bucket, restored to an older version on problems
Show the answer and why
  • AA Parameter Store parameter that the service reads on every request

    Incorrect

    A parameter update takes effect on the next read, with no validation, gradual rollout or automatic revert.

  • BAn AWS AppConfig feature flag with a validator, a linear strategy and an alarm

    Correct

    AppConfig validates configuration before deployment, rolls it out gradually with a deployment strategy, and rolls back automatically when a monitored CloudWatch alarm goes into alarm.

  • CA Secrets Manager secret that holds the flag, rotated every 30 minutes

    Incorrect

    Secrets Manager rotation updates credentials on a schedule. It does not validate configuration or expose a change gradually.

  • DA JSON file in a versioned S3 bucket, restored to an older version on problems

    Incorrect

    Versioning lets someone restore an earlier version, but validation, gradual exposure and alarm-driven rollback would all be custom work.

Feature flags with validators, deployment strategies and alarm-based rollback are what AWS AppConfig adds on top of plain configuration storage.

Question 4 · choose 1

A team publishes private npm packages and also depends on public packages from npmjs.com. Builds in AWS CodeBuild must install both kinds from a single registry endpoint, and the public packages they use should be fetched once and then kept in AWS so that later builds do not depend on npmjs.com. What should the developer set up?

  1. AAn Amazon ECR pull through cache rule that syncs npmjs.com
  2. BA Lambda layer that holds the npm packages, attached to the build project
  3. CA CodeArtifact repository whose upstream has an external connection to npmjs.com
  4. DA CodeArtifact repository without an external connection, filled by hand with public packages
Show the answer and why
  • AAn Amazon ECR pull through cache rule that syncs npmjs.com

    Incorrect

    Pull through cache rules sync container image registries such as Amazon ECR Public, Quay and Docker Hub. npmjs.com is not a supported upstream.

  • BA Lambda layer that holds the npm packages, attached to the build project

    Incorrect

    Layers add code and dependencies to Lambda functions. They are not a package registry that npm can install from.

  • CA CodeArtifact repository whose upstream has an external connection to npmjs.com

    Correct

    With an external connection, CodeArtifact fetches public packages on request and stores them, and the build runs the CodeArtifact login command so npm uses the repository endpoint.

  • DA CodeArtifact repository without an external connection, filled by hand with public packages

    Incorrect

    This keeps one endpoint, but every public package would have to be published manually, which an external connection does on demand.

CodeArtifact serves private packages and caches public ones through an external connection, behind one endpoint that CodeBuild logs in to.

Question 5 · choose 1

In an AWS SAM project, a developer deploys a Python function that imports the requests library, which is listed in the function's requirements.txt. The deployed function fails with an import error because the library is missing from the package. Which step did the developer skip before sam deploy?

  1. Asam build, which prepares the code and its dependencies in .aws-sam
  2. Bsam validate, which checks the template for errors
  3. Csam local invoke, which runs the function once locally with a sample event
  4. Dsam logs, which shows the function's CloudWatch logs
Show the answer and why
  • Asam build, which prepares the code and its dependencies in .aws-sam

    Correct

    sam build creates the .aws-sam directory with the function code and the dependencies from its manifest file, ready to deploy.

  • Bsam validate, which checks the template for errors

    Incorrect

    Validation checks the template; it does not download or package dependencies.

  • Csam local invoke, which runs the function once locally with a sample event

    Incorrect

    Local invocation runs code for testing; it does not add libraries to the deployment package.

  • Dsam logs, which shows the function's CloudWatch logs

    Incorrect

    Logs show the error after the fact; they do not package dependencies.

Run sam build before deploying so that dependencies listed in manifest files are packaged with the code.

Question 6 · choose 1

A team packages a Python AWS Lambda function as a container image. The image is built from a generic Python base image from a public registry, and Lambda cannot run it because nothing in the image talks to the Lambda runtime. What should the developer do?

  1. AUse an AWS base image for Lambda, or add the runtime interface client
  2. BPush the image to Docker Hub instead of Amazon ECR
  3. CRaise the function's memory so that the container can start
  4. DRepackage the code and libraries as a .zip file archive larger than 250 MB unzipped
Show the answer and why
  • AUse an AWS base image for Lambda, or add the runtime interface client

    Correct

    AWS base images include a runtime interface client; other base images need one added to work with Lambda.

  • BPush the image to Docker Hub instead of Amazon ECR

    Incorrect

    Lambda creates functions from images in Amazon ECR, and the registry is not what is missing.

  • CRaise the function's memory so that the container can start

    Incorrect

    Memory does not add the missing component that talks to the Lambda runtime.

  • DRepackage the code and libraries as a .zip file archive larger than 250 MB unzipped

    Incorrect

    The unzipped .zip deployment package is limited to 250 MB, so this is not possible.

Container images for Lambda need a runtime interface client; AWS base images include one.

Question 7 · choose 1

A Python AWS Lambda function is deployed as a container image built from an AWS base image for Lambda. At startup, the code downloads a small rules file and writes it with a local cache to /app/cache, a directory that the Dockerfile creates. The image works with docker run on a laptop, but in Lambda each write fails with a "Read-only file system" error. The cache does not need to outlive the execution environment. What should the developer do?

  1. AAdd USER root to the Dockerfile so that the function can write anywhere
  2. BRun chmod 777 on /app/cache in the Dockerfile
  3. CChange the code to write those files under /tmp
  4. DMount an Amazon EFS file system at /app/cache for the function
Show the answer and why
  • AAdd USER root to the Dockerfile so that the function can write anywhere

    Incorrect

    Lambda runs the image with its own least-privileged default user, and the container must work on a read-only file system whatever user it runs as.

  • BRun chmod 777 on /app/cache in the Dockerfile

    Incorrect

    File permissions do not matter here. Lambda mounts the image's file system read-only, so no user can write to /app/cache.

  • CChange the code to write those files under /tmp

    Correct

    A Lambda container image must be able to run on a read-only file system. Function code can write only to the /tmp directory.

  • DMount an Amazon EFS file system at /app/cache for the function

    Incorrect

    An EFS local mount path for Lambda must start with /mnt/, and a shared network file system is more than a per-environment cache needs.

Lambda runs container images on a read-only file system. Code that writes temporary files, such as caches or downloaded data, must use /tmp.

Question 8 · choose 1

A team shares an internal Python library and its dependencies with several AWS Lambda functions through a Lambda layer, so that the library is not bundled into each function's package. The layer's .zip file holds the library's folder and its dependency folders at the root of the archive. Each function that adds the layer fails with an import error for the library. What should the developer do?

  1. ASet the layer's compatible runtimes list to match the functions' Python version
  2. BRebuild the layer .zip with the packages inside a top-level python directory
  3. CMove the layer to the first position in each function's layer order
  4. DAdd the library to each function's requirements.txt as well as the layer
Show the answer and why
  • ASet the layer's compatible runtimes list to match the functions' Python version

    Incorrect

    Compatible runtimes describe which runtimes the layer is meant for. They do not change where the files land in /opt or what Python can import.

  • BRebuild the layer .zip with the packages inside a top-level python directory

    Correct

    Lambda extracts layers into /opt, and for Python the path already includes /opt/python and /opt/python/lib/python3.x/site-packages. Code at the root of the archive is not on the import path.

  • CMove the layer to the first position in each function's layer order

    Incorrect

    Layer order matters when layers contain the same files. Wherever the layer sits, its files at the root of /opt are still not on the path.

  • DAdd the library to each function's requirements.txt as well as the layer

    Incorrect

    Bundling the library into each package would make the import work, but it is exactly the duplication that the layer is meant to remove.

Layer content must sit in the runtime-specific folder that Lambda puts on the path. For Python that is python/ or python/lib/python3.x/site-packages inside the layer archive.

Practice domain 3 →Practice all domains →