AWS Developer Associate · Domain 3 of 4 · 24% of the exam

AWS Developer Associate Domain 3: Deployment

48 free practice questions for Deployment in the AWS Certified Developer – Associate (DVA-C02) exam. Try each question first, then open "Show answer" for the correct option and explanation.

Deployment practice questions

  1. Question 1. What line marks a CloudFormation template as an AWS SAM template?

    1. AWSTemplateFormatVersion: 2010-09-09
    2. Resources: AWS::Serverless::Function
    3. Transform: AWS::Serverless-2016-10-31
    4. Metadata: AWS::SAM::Interface
    Show answer

    Answer: C. Transform: AWS::Serverless-2016-10-31

    The SAM transform expands resources such as AWS::Serverless::Function into standard CloudFormation.

  2. Question 2. Which SAM CLI command packages code, uploads artifacts, and deploys the stack?

    1. sam init
    2. sam local invoke
    3. sam deploy
    4. sam logs
    Show answer

    Answer: C. sam deploy

    sam build prepares artifacts, and sam deploy uploads them and creates or updates the CloudFormation stack.

  3. Question 3. A developer wants to run a Lambda function locally with a sample event before deploying. Which command fits?

    1. sam deploy --guided
    2. aws lambda invoke on $LATEST
    3. sam local invoke with an event file
    4. cdk synth with the event file
    Show answer

    Answer: C. sam local invoke with an event file

    sam local runs the function in a local container that mimics the Lambda runtime.

  4. Question 4. In a SAM template, which feature grants a function common permissions, such as DynamoDB CRUD on one table, with little policy writing?

    1. An inline policy attached to an IAM user
    2. SAM policy templates such as DynamoDBCrudPolicy
    3. A Lambda layer that contains credentials
    4. A CloudFormation stack policy on the stack
    Show answer

    Answer: B. SAM policy templates such as DynamoDBCrudPolicy

    Policy templates generate least-privilege policies scoped to the resource you name.

  5. Question 5. Which SAM setting makes each deployment of a function shift traffic gradually with CodeDeploy?

    1. ReservedConcurrentExecutions on the function
    2. Layers with a version number
    3. AutoPublishAlias with a DeploymentPreference
    4. Environment variables per stage
    Show answer

    Answer: C. AutoPublishAlias with a DeploymentPreference

    SAM publishes a new version, updates the alias, and uses CodeDeploy to shift traffic.

  6. Question 6. Which Lambda deployment configuration sends 10% of traffic to the new version for 5 minutes, then the rest?

    1. Linear10PercentEvery1Minute
    2. AllAtOnce
    3. Canary10Percent5Minutes
    4. Linear10PercentEvery10Minutes
    Show answer

    Answer: C. Canary10Percent5Minutes

    Canary shifts in two steps. Linear shifts equal increments at set intervals.

  7. Question 7. During a CodeDeploy Lambda deployment, which hook runs a validation function before any traffic moves to the new version?

    1. AfterAllowTraffic
    2. ApplicationStop
    3. BeforeAllowTraffic
    4. ValidateService
    Show answer

    Answer: C. BeforeAllowTraffic

    If the hook function reports failure, CodeDeploy stops and rolls back.

  8. Question 8. A Lambda canary deployment should roll back automatically if errors rise. What should be linked to the deployment?

    1. A larger reserved concurrency on the function
    2. An SQS dead-letter queue on the function
    3. CloudWatch alarms on the new version's errors
    4. An S3 lifecycle rule on the artifact bucket
    Show answer

    Answer: C. CloudWatch alarms on the new version's errors

    CodeDeploy watches the alarms during traffic shifting and rolls back if one fires.

  9. Question 9. Which file tells CodeBuild which commands to run in each build phase?

    1. appspec.yml
    2. template.yaml
    3. buildspec.yml
    4. Dockerrun.aws.json
    Show answer

    Answer: C. buildspec.yml

    The buildspec defines phases such as install, pre_build, build, and post_build, plus artifacts.

  10. Question 10. Which file tells CodeDeploy how to deploy to EC2 instances and which scripts to run at each lifecycle event?

    1. buildspec.yml
    2. appspec.yml
    3. samconfig.toml
    4. package.json
    Show answer

    Answer: B. appspec.yml

    The AppSpec file maps files to destinations and scripts to hooks such as BeforeInstall and ValidateService.

  11. Question 11. For an EC2 in-place deployment, in which order do these CodeDeploy hooks run?

    1. BeforeInstall, ApplicationStop, ApplicationStart, AfterInstall, ValidateService
    2. ValidateService, ApplicationStart, AfterInstall, BeforeInstall, ApplicationStop
    3. ApplicationStop, BeforeInstall, AfterInstall, ApplicationStart, ValidateService
    4. ApplicationStart, BeforeInstall, AfterInstall, ApplicationStop, ValidateService
    Show answer

    Answer: C. ApplicationStop, BeforeInstall, AfterInstall, ApplicationStart, ValidateService

    The old app is stopped, files are installed, the new app is started, and then it's validated.

  12. Question 12. What must be running on EC2 instances for CodeDeploy to deploy to them?

    1. The CloudWatch agent only
    2. An SSM document per deployment
    3. A Lambda layer on the instance
    4. The CodeDeploy agent
    Show answer

    Answer: D. The CodeDeploy agent

    The agent polls CodeDeploy and runs the AppSpec hooks. Instances also need an instance profile.

  13. Question 13. Where does a CodeBuild project store dependencies to speed up later builds?

    1. The buildspec's env section
    2. The CodePipeline artifact store only
    3. A local or S3 cache configured in the project
    4. An ECR lifecycle policy
    Show answer

    Answer: C. A local or S3 cache configured in the project

    Caching paths such as the package manager's directory avoids downloading dependencies every build.

  14. Question 14. How should a CodeBuild project read a database password during the build?

    1. Reference Secrets Manager or Parameter Store in the buildspec env section
    2. Hard-code it in buildspec.yml
    3. Pass it as a plain-text environment variable in the console
    4. Commit it to the source repository
    Show answer

    Answer: A. Reference Secrets Manager or Parameter Store in the buildspec env section

    The env section can pull secrets-manager and parameter-store values at build time.

  15. Question 15. A release needs sign-off from a manager before deploying to production. What should be added to CodePipeline?

    1. A second source stage
    2. A CodeBuild test action after production
    3. A manual approval action before the production stage
    4. An S3 lifecycle rule on the artifact bucket
    Show answer

    Answer: C. A manual approval action before the production stage

    Manual approval pauses the pipeline and can notify reviewers through SNS.

  16. Question 16. Which Elastic Beanstalk deployment policy deploys to all instances at once, with a brief outage?

    1. Rolling with additional batch
    2. Immutable
    3. Traffic splitting
    4. All at once
    Show answer

    Answer: D. All at once

    All at once is fastest but has downtime and a slow rollback.

  17. Question 17. Which Elastic Beanstalk policy keeps full capacity during a deployment by adding a new batch of instances first?

    1. Rolling, one batch at a time
    2. All at once, on every instance
    3. Rolling with additional batch
    4. In-place update with a restart
    Show answer

    Answer: C. Rolling with additional batch

    Rolling reduces capacity while each batch updates. The additional batch keeps capacity at 100%.

  18. Question 18. Which Elastic Beanstalk policy deploys to a fresh set of instances in a new Auto Scaling group, making rollback quick?

    1. Rolling
    2. Immutable
    3. All at once
    4. Rolling with additional batch
    Show answer

    Answer: B. Immutable

    Rollback means terminating the new instances, with no changes to the originals.

  19. Question 19. How is a blue/green deployment done with Elastic Beanstalk?

    1. Use the all-at-once policy twice in a row
    2. Change the instance type in place on the environment
    3. Enable traffic splitting on a single-instance environment
    4. Deploy to a new environment, then swap environment URLs
    Show answer

    Answer: D. Deploy to a new environment, then swap environment URLs

    Swapping URLs switches traffic. The old environment stays available for rollback.

  20. Question 20. Where are custom Elastic Beanstalk configuration files, such as extra packages or options, placed in the source bundle?

    1. A buildspec.yml file at the root
    2. The .ebextensions folder, as .config files
    3. An appspec.yml file at the root
    4. The /opt directory of each instance
    Show answer

    Answer: B. The .ebextensions folder, as .config files

    .ebextensions files can set option settings, install packages, and run commands.

  21. Question 21. Which CloudFormation feature previews how a stack update will change resources before it runs?

    1. A stack policy
    2. Drift detection
    3. A change set
    4. A nested stack
    Show answer

    Answer: C. A change set

    Change sets list resources that will be added, modified, or replaced.

  22. Question 22. One CloudFormation stack must use the VPC ID created by another stack. What should be used?

    1. A hard-coded VPC ID written into the second template
    2. A nested stack in the second template that recreates the VPC
    3. A Mappings section in the second template listing the VPC ID
    4. An Export in the first stack and Fn::ImportValue in the second
    Show answer

    Answer: D. An Export in the first stack and Fn::ImportValue in the second

    Exported outputs can be imported by other stacks in the same account and Region.

  23. Question 23. Which intrinsic function returns an attribute of a resource, such as a function's ARN?

    1. Ref
    2. Fn::Sub
    3. Fn::GetAtt
    4. Fn::FindInMap
    Show answer

    Answer: C. Fn::GetAtt

    Ref usually returns the resource's name or ID. GetAtt returns specific attributes.

  24. Question 24. A DynamoDB table in a stack must keep its data if the stack is deleted. What should be set?

    1. A stack policy that denies updates
    2. DeletionPolicy: Retain on the table
    3. Termination protection on the table
    4. A condition on the table resource
    Show answer

    Answer: B. DeletionPolicy: Retain on the table

    Retain keeps the resource when the stack is deleted. Snapshot is available for some resource types.

  25. Question 25. A CloudFormation template must create a larger instance in production than in development. Which feature fits?

    1. Parameters or Mappings combined with Conditions
    2. A separate AWS account for every size
    3. Drift detection on the stack
    4. Stack policies per environment
    Show answer

    Answer: A. Parameters or Mappings combined with Conditions

    Parameters and Mappings select values, and Conditions include or change resources per environment.

  26. Question 26. What does CloudFormation do by default if a resource fails to create during a stack creation?

    1. Keep the successful resources and stop
    2. Roll back and delete the resources it created
    3. Retry the failed resource forever
    4. Delete the template from S3
    Show answer

    Answer: B. Roll back and delete the resources it created

    Rollback on failure is the default. It can be disabled to troubleshoot.

  27. Question 27. Which AWS CDK command produces the CloudFormation template from the app code?

    1. cdk synth
    2. cdk bootstrap
    3. cdk diff
    4. cdk destroy
    Show answer

    Answer: A. cdk synth

    cdk synth generates templates. cdk deploy synthesizes and deploys them.

  28. Question 28. Before the first CDK deployment in an account and Region, what must be run?

    1. cdk bootstrap
    2. cdk init
    3. cdk watch
    4. cdk doctor
    Show answer

    Answer: A. cdk bootstrap

    Bootstrapping creates resources such as an S3 bucket and roles that CDK uses to deploy assets.

  29. Question 29. A container image built in CodeBuild must be pushed to Amazon ECR. What must happen first?

    1. Make the ECR repository public for the build
    2. Log in to ECR with a token from get-login-password
    3. Create an IAM user just for the Docker client
    4. Enable image scanning on push for the repository
    Show answer

    Answer: B. Log in to ECR with a token from get-login-password

    docker login uses the ECR authorization token. The CodeBuild role needs ECR push permissions.

  30. Question 30. An ECS service must shift traffic to a new task set gradually with automatic rollback. What should be used?

    1. The ECS rolling update with minimum 0%
    2. A manual task definition change in the console
    3. CodeDeploy blue/green deployment for ECS
    4. Elastic Beanstalk all-at-once deployment
    Show answer

    Answer: C. CodeDeploy blue/green deployment for ECS

    CodeDeploy shifts traffic between target groups using canary, linear, or all-at-once settings.

  31. Question 31. A new feature must be turned on for users without redeploying code, and turned off quickly if it misbehaves. What fits?

    1. A new Lambda version for each change
    2. A CloudFormation stack update each time
    3. Feature flags in AWS AppConfig
    4. Editing environment variables on every function
    Show answer

    Answer: C. Feature flags in AWS AppConfig

    AppConfig deploys configuration gradually, validates it, and can roll back on alarms.

  32. Question 32. An API Gateway REST API change must be tested on 10% of production traffic first. What should be used?

    1. A new usage plan with 10% quota
    2. A canary release on the stage
    3. A second custom domain name
    4. A mock integration for the new version
    Show answer

    Answer: B. A canary release on the stage

    Canary settings route a percentage of stage traffic to a new deployment before promotion.

  33. Question 33. A developer changes an API Gateway REST API's resources. Why don't clients see the change?

    1. The cache must be deleted from S3
    2. CORS must be enabled again
    3. The API must be deployed to a stage
    4. The Lambda function must be republished
    Show answer

    Answer: C. The API must be deployed to a stage

    Changes take effect only after a new deployment is created for a stage.

  34. Question 34. Which service hosts a React single-page app with CI/CD from a Git branch and preview environments?

    1. AWS Elastic Beanstalk with Docker
    2. Amazon EC2 with CodeDeploy
    3. AWS Batch
    4. AWS Amplify Hosting
    Show answer

    Answer: D. AWS Amplify Hosting

    Amplify Hosting builds and deploys web apps from Git and supports branch previews.

  35. Question 35. Which pipeline stage order is typical for a CodePipeline release?

    1. Deploy, Build, Source, Test
    2. Build, Source, Deploy, Test
    3. Source, Build, Test, Deploy
    4. Test, Deploy, Build, Source
    Show answer

    Answer: C. Source, Build, Test, Deploy

    Each stage consumes the previous stage's output artifacts.

  36. Question 36. How do CodePipeline stages pass build outputs to deployment?

    1. Through environment variables on the EC2 instances
    2. Through output artifacts stored in the pipeline's S3 artifact store
    3. Through a shared EFS file system only
    4. Through CloudFormation stack exports
    Show answer

    Answer: B. Through output artifacts stored in the pipeline's S3 artifact store

    Actions declare input and output artifacts, which CodePipeline stores in S3.

  37. Question 37. Unit tests should fail the build when a test fails. Where should they run?

    1. In CodeDeploy's ApplicationStart lifecycle hook
    2. In a CodeBuild action, where a non-zero exit fails it
    3. In the CodePipeline source stage before the build
    4. In the pipeline's S3 artifact bucket after deploy
    Show answer

    Answer: B. In a CodeBuild action, where a non-zero exit fails it

    CodeBuild also supports test reports for viewing results.

  38. Question 38. A company wants the same CloudFormation stack deployed to many accounts and Regions. What should be used?

    1. Nested stacks
    2. Change sets
    3. CloudFormation StackSets
    4. Cross-stack references
    Show answer

    Answer: C. CloudFormation StackSets

    StackSets deploy a template to target accounts and Regions from one administrator account.

  39. Question 39. How can a Lambda function's configuration differ between dev and prod when deployed with SAM from one template?

    1. Maintain a copy of the template per environment
    2. Edit the function in the console after deploying
    3. Hard-code both values and choose one at runtime
    4. Use template parameters with a per-environment samconfig.toml
    Show answer

    Answer: D. Use template parameters with a per-environment samconfig.toml

    samconfig.toml stores deploy settings, including parameter overrides, for each environment.

  40. Question 40. Which CloudFormation helper script installs packages and writes files on an EC2 instance from template metadata?

    1. cfn-signal
    2. cfn-init
    3. cfn-hup
    4. cfn-lint
    Show answer

    Answer: B. cfn-init

    cfn-signal reports success to a CreationPolicy, and cfn-hup detects metadata changes.

  41. Question 41. An Auto Scaling group in a stack should be marked complete only after its instances finish setup. What should be used?

    1. A DeletionPolicy of Retain on the Auto Scaling group
    2. A CreationPolicy with cfn-signal from the instances
    3. A DependsOn attribute pointing at a stack output
    4. A stack policy that protects the Auto Scaling group
    Show answer

    Answer: B. A CreationPolicy with cfn-signal from the instances

    CloudFormation waits for the required number of success signals before completing.

  42. Question 42. A developer changed a resource outside CloudFormation. How can this be found?

    1. Drift detection
    2. Change sets
    3. Stack policies
    4. Template validation
    Show answer

    Answer: A. Drift detection

    Drift detection compares actual resource configuration with the template.

  43. Question 43. Which Lambda deployment practice ensures the code running in production is exactly the code that was tested?

    1. Promote the same published version from test to production
    2. Rebuild the package separately for each environment
    3. Point production at $LATEST
    4. Edit the code in the console before release
    Show answer

    Answer: A. Promote the same published version from test to production

    Versions are immutable, so moving an alias to a tested version avoids differences between builds.

  44. Question 44. Where should environment-specific values, such as a table name, be passed to a Lambda function?

    1. Hard-coded strings in each function's code
    2. The function's resource-based policy
    3. Environment variables set by the deployment template
    4. The function's description field
    Show answer

    Answer: C. Environment variables set by the deployment template

    Deployment tooling sets the values per stage, so the same code runs everywhere.

  45. Question 45. Which Elastic Beanstalk option sends a percentage of traffic to new instances for a test period before full deployment?

    1. Rolling
    2. All at once
    3. Traffic splitting
    4. Rolling with additional batch
    Show answer

    Answer: C. Traffic splitting

    Traffic splitting is a canary-style policy that rolls back if the new instances are unhealthy.

  46. Question 46. What does a Dockerfile's multi-stage build help with for Lambda container images?

    1. Smaller final images that exclude build tools
    2. Running several functions in one image
    3. Skipping the push to Amazon ECR
    4. Increasing the Lambda timeout past 15 minutes
    Show answer

    Answer: A. Smaller final images that exclude build tools

    Only the final stage's files are kept, which speeds pulls and reduces attack surface.

  47. Question 47. A Lambda function must use a new version of a shared layer. What must be done?

    1. Nothing; functions always use the latest layer
    2. Update the function to reference the new layer version
    3. Delete the old layer version first
    4. Increase the function's memory
    Show answer

    Answer: B. Update the function to reference the new layer version

    Layer versions are immutable, and functions reference a specific version ARN.

  48. Question 48. A team wants to test infrastructure changes safely in isolated copies of the stack. What is a good practice?

    1. Share one stack and edit its resources by hand
    2. Test changes only in the production account
    3. Deploy each branch or developer to a separate stack name
    4. Disable rollback on all stacks while testing
    Show answer

    Answer: C. Deploy each branch or developer to a separate stack name

    Parameterized stack names let many copies of the same template run side by side.

AWS, Amazon Web Services, and AWS Certified are trademarks of Amazon.com, Inc. or its affiliates. These questions are original study material, not questions from the real exam.