All AWS exams

Free DOP-C02 practice test: 30 questions with answers

30 original questions for AWS Certified DevOps Engineer - Professional, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.

Free questions
30
Full bank
100 questions
Real exam
75 questions, 180 min

DOP-C02 exam guide: topics, cost and format

All 30 DOP-C02 questions with answers

The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.

SDLC Automation (5 questions)

  1. Question 1

    A team deploys a Lambda function behind an alias. They want 10% of traffic shifted to the new version for 10 minutes, with automatic rollback if a CloudWatch alarm on errors goes into ALARM state during that window. Which approach meets these requirements with the least custom code?

    1. AUpdate the alias weights with a scheduled script that polls CloudWatch error metrics every minute and shifts traffic
    2. BUse CloudFormation change sets with a manual approval step before each alias update and execute the change set from the AWS console
    3. CUse AWS CodeDeploy with a Lambda canary deployment configuration and attach the CloudWatch alarm to the deployment group
    4. DUse Elastic Beanstalk immutable deployments to shift traffic to the new Lambda version by swapping environment CNAMEs after health checks pass
    Show answer and explanation
    Correct answer: C

    CodeDeploy supports Lambda canary and linear traffic shifting between versions through an alias, and it rolls back automatically when a linked CloudWatch alarm fires. A custom script or manual approval does not provide automatic alarm-driven rollback, and Elastic Beanstalk does not manage Lambda aliases this way.

  2. Question 2

    A company has a microservices application in which each service has its own repository. The team wants builds to run only when the relevant service changes, and all pipelines should share one definition. What is the most appropriate design?

    1. AA separate pipeline per service, each triggered by changes to its own source, generated from a shared CloudFormation template
    2. BA single CodeBuild project with hardcoded source paths in one buildspec, started by an operator each time and no stage promotes artifacts
    3. COne monolithic pipeline that builds every service in one stage, rebuilding unchanged services with each commit to the shared main branch
    4. DA Lambda function that calls CodeBuild from an S3 event on every upload and it starts a build without checking which service changed
    Show answer and explanation
    Correct answer: A

    Per-service pipelines triggered by their own source changes keep builds targeted and independent, and a shared template keeps them consistent. A monolithic pipeline rebuilds unchanged services, and a manual CodeBuild project does not provide automated delivery.

  3. Question 3

    A team wants blue/green deployments for an Amazon ECS service behind an Application Load Balancer, with automatic rollback if the new tasks fail. Which service should they use?

    1. AAWS CodeDeploy with the ECS compute platform and a blue/green deployment configuration
    2. BElastic Beanstalk rolling updates with a batch size of one and no traffic shifting between groups
    3. CAWS OpsWorks Stacks with Chef recipes to configure ECS cluster instances
    4. DCloudFormation UpdatePolicy with AutoScalingRollingUpdate on the ECS service resource with MaxBatchSize 1
    Show answer and explanation
    Correct answer: A

    CodeDeploy supports blue/green deployments on the ECS compute platform, with traffic shifting and automatic rollback on failure. Rolling updates in Elastic Beanstalk or CloudFormation modify tasks in place, and OpsWorks is not used for ECS.

  4. Question 4

    A DevOps team is designing a deployment pipeline for a containerized application. Which TWO practices reduce the risk of a faulty build reaching production? (Choose two.)

    1. ARun automated unit and integration tests in CodeBuild before an approval gate
    2. BRebuild the image separately in production from the latest base image tag
    3. CPromote the same immutable container image through each environment instead of rebuilding it
    4. DDeploy directly from a developer laptop to production to save pipeline time
    5. ETag every image as latest so that rollbacks are unnecessary
    Show answer and explanation
    Correct answer: A, C

    Promoting a single immutable artifact guarantees that what was tested is what is deployed, and automated tests before the gate catch defects early. Rebuilding per environment and using latest tags break reproducibility, and deploying from laptops bypasses controls.

  5. Question 5

    A pipeline deploys to a staging account, runs integration tests, and then needs a human approval before deploying to a production account. The pipeline must deploy without storing long-lived keys. What is the best approach?

    1. AHave the pipeline assume a cross-account IAM role in production whose trust policy allows the pipeline account
    2. BShare the production root user credentials with the approver and store them in the pipeline config
    3. CCopy the production credentials into a CodeBuild environment variable for every build run
    4. DCreate an IAM user in the production account and store its access key in the pipeline with PowerUserAccess
    Show answer and explanation
    Correct answer: A

    Cross-account role assumption gives the pipeline temporary credentials scoped to a deployment role, which avoids long-lived secrets. Storing access keys or sharing root credentials creates a security risk that cannot be audited cleanly.

Security and Compliance (5 questions)

  1. Question 6

    A CodeBuild project needs a database password at build time. The password must be rotated automatically every 30 days and must never appear in the buildspec file or in build logs. Which solution satisfies these requirements?

    1. AStore the password as a plaintext environment variable in the CodeBuild project with no rotation schedule
    2. BStore it in a Systems Manager String parameter and echo it in the install phase for debugging, then write it into the build logs
    3. CCommit an encrypted file to the repository and decrypt it in the install phase using a shared KMS key policy
    4. DStore the password in AWS Secrets Manager with rotation enabled and reference it from the CodeBuild environment variables
    Show answer and explanation
    Correct answer: D

    Secrets Manager stores the credential, rotates it on a schedule, and CodeBuild can reference the secret directly so the value is not hard-coded in the project. Plaintext variables and echoing values into logs expose the secret, and a committed encrypted file still stores the credential in source control.

  2. Question 7

    An organization wants to ensure that no IAM principal in any member account can create resources outside the eu-west-1 Region, regardless of the permissions granted locally. Which mechanism should be used?

    1. AAn IAM role in each account with a trust policy that restricts Regions and a session duration of one hour in each member account
    2. BAn IAM permissions boundary attached to each user and role, which caps the identity-based policies those principals can grant
    3. CA service control policy attached to the root or an OU that denies actions when aws:RequestedRegion is not eu-west-1
    4. DA Config conformance pack that deletes resources created in other Regions as soon as Config detects them through a remediation action
    Show answer and explanation
    Correct answer: C

    Service control policies set the maximum permissions for accounts in an organization and can deny actions based on the requested Region condition key, regardless of local IAM policies. Permissions boundaries work per principal inside one account, and trust policies control who can assume a role rather than what resources are created.

  3. Question 8

    An application on EC2 must call Amazon S3 and DynamoDB. The security team requires that no long-term access keys exist on the instances and that permissions are limited to one bucket and one table. What should the DevOps engineer implement?

    1. AStore an IAM user access key in the instance user data and rotate it manually each quarter
    2. BCreate a shared IAM user that every instance uses and its key is stored in the template
    3. CEmbed credentials in the application configuration file and encrypt the file with a dedicated customer managed KMS key
    4. DAttach an IAM role with least-privilege policies for that bucket and table through an instance profile
    Show answer and explanation
    Correct answer: D

    An instance profile supplies temporary credentials through the instance metadata service, which avoids long-term keys, and a least-privilege policy limits the scope to the named resources. Storing access keys in user data or encrypted config files still creates long-lived secrets that can leak.

  4. Question 9

    A company wants to detect and prevent accidental public exposure of its S3 buckets. Which TWO actions should the DevOps engineer take? (Choose two.)

    1. AUse Amazon Macie to discover buckets with sensitive data and public access settings
    2. BDisable server-side encryption to simplify access for all clients
    3. CEnable S3 Block Public Access at the account level
    4. DSet the bucket policy Principal to star with a condition on a source IP range
    5. EMake all objects public-read so that AWS Config can evaluate them
    Show answer and explanation
    Correct answer: A, C

    Block Public Access at the account level stops public policies and ACLs from taking effect, and Macie identifies buckets that are publicly accessible or hold sensitive data. A public principal with an IP condition still exposes data, disabling encryption weakens protection, and making objects public works against the goal.

  5. Question 10

    A Lambda function runs in a private subnet with no internet route and must retrieve a secret from AWS Secrets Manager. The team wants traffic to stay on the AWS network. What should they add?

    1. AAn S3 gateway endpoint for the subnet
    2. BA NAT gateway in a public subnet with a default route from the private subnet
    3. CAn internet gateway attached to the private subnet route table
    4. DAn interface VPC endpoint for Secrets Manager
    Show answer and explanation
    Correct answer: A

    An interface endpoint for Secrets Manager gives the function private connectivity to the service without internet egress. An internet gateway or NAT would send traffic outside the VPC toward public endpoints, and an S3 gateway endpoint only serves S3.

Configuration Management and IaC (5 questions)

  1. Question 11

    A CloudFormation stack that creates an RDS instance is updated and a change would force the database to be replaced. The team wants the old database preserved if it is replaced or the stack is deleted. Which resource attributes should be set?

    1. ADeletionPolicy set to Delete and UpdateReplacePolicy set to Delete
    2. BTermination protection enabled on the stack and no resource attributes
    3. CA stack policy that denies all updates and DeletionPolicy set to Delete
    4. DUpdateReplacePolicy set to Retain and DeletionPolicy set to Snapshot
    Show answer and explanation
    Correct answer: D

    UpdateReplacePolicy controls what happens to the old physical resource when an update forces replacement, and DeletionPolicy controls it on stack deletion. Retain or Snapshot keeps the data, whereas Delete destroys it, and stack-level protections do not change per-resource behaviour.

  2. Question 12

    A team uses AWS CDK in TypeScript and wants to see exactly which resources would be created, changed, or deleted in an environment before deploying. Which command should they run?

    1. Acdk bootstrap
    2. Bcdk synth
    3. Ccdk diff
    4. Dcdk destroy --dry-run
    Show answer and explanation
    Correct answer: C

    cdk diff compares the synthesized template with the currently deployed stack and reports the planned changes. cdk synth only produces the CloudFormation template, cdk bootstrap prepares the environment, and cdk destroy has no dry-run option.

  3. Question 13

    A company must ensure that every EC2 instance launched in its accounts carries a specific cost-center tag, and that launches without it are blocked. The control must apply to all accounts. Which approach is correct?

    1. AUse an SCP that denies ec2:RunInstances unless the required tag is present in the request
    2. BUse a Config rule that tags instances after they launch and sets a default cost-center value
    3. CUse a Lambda function triggered by CloudTrail to delete untagged instances hourly and notify the owning team
    4. DTag the AMI and rely on tags being inherited by new instances from the launch template
    Show answer and explanation
    Correct answer: A

    An SCP with a condition on the request tags for RunInstances is a preventive control that blocks untagged launches across accounts. Config and Lambda remediation are detective and act after the fact, and AMIs do not propagate tags to new instances.

  4. Question 14

    A team stores its CloudFormation templates in version control and wants to prevent unreviewed changes from reaching production. Which TWO controls should they add? (Choose two.)

    1. ARun cfn-guard or cfn-nag in the pipeline and fail the build on policy violations
    2. BAllow engineers to edit production stacks directly in the console for speed
    3. CDelete the change set review step to shorten deployments
    4. DRequire a pull request review with automated cfn-lint checks before merge
    5. EKeep the production template only in a local developer folder
    Show answer and explanation
    Correct answer: A, D

    Automated policy checks in the pipeline catch violations before deployment, and required peer review with linting catches errors before merge. Direct console edits and removing change set review bypass controls, and keeping templates only on laptops removes version history.

  5. Question 15

    A CloudFormation template needs to reference an output value exported by a stack in another account-level stack in the same Region. Which intrinsic function should be used?

    1. AFn::Sub
    2. BFn::ImportValue
    3. CFn::GetAtt
    4. DFn::Select
    Show answer and explanation
    Correct answer: A

    Fn::ImportValue reads a value that another stack has exported under a shared name in the same Region and account. Fn::GetAtt reads an attribute of a resource in the same template, Fn::Sub performs string substitution, and Fn::Select picks an item from a list.

Resilient Cloud Solutions (5 questions)

  1. Question 16

    An application runs in an Auto Scaling group across three Availability Zones behind an Application Load Balancer. During a zonal outage, users report slow responses because the remaining instances are saturated before scaling catches up. Which configuration change most directly reduces this impact?

    1. AMove the load balancer to a single Availability Zone to simplify routing and register targets in one subnet behind a shared route table
    2. BAdd a target tracking scaling policy on average CPU or request count per target with a sensible warm-up setting
    3. CReduce the health check grace period to zero seconds so new instances are evaluated immediately and replaced faster during an outage
    4. DDisable cross-zone load balancing so traffic stays in the zone where the request arrived and pin each target to its local zone
    Show answer and explanation
    Correct answer: B

    Target tracking keeps capacity aligned with load so the surviving zones absorb traffic sooner. Reducing the health check grace period to zero causes instability, and disabling cross-zone load balancing can leave some zones overloaded during an outage.

  2. Question 17

    A team must be able to restore an Amazon DynamoDB table to the state it had at any second within the last 35 days, for example after an application bug corrupted data. Which feature should be enabled?

    1. AEBS snapshots of the instances that write to the table
    2. BAWS Backup daily backup plan with a 24-hour retention
    3. CS3 versioning on an export of the table
    4. DDynamoDB point-in-time recovery
    Show answer and explanation
    Correct answer: D

    DynamoDB point-in-time recovery maintains continuous backups for 35 days and allows restoring to any second in that window. A daily backup plan cannot restore to an arbitrary second, and exports or instance snapshots do not capture the table state in the same way.

  3. Question 18

    A stateless web tier must keep serving requests when one Availability Zone is impaired. Which design element matters most for this goal?

    1. ASpreading instances across at least two Availability Zones behind a load balancer with health checks
    2. BPlacing every instance in one subnet with a large CIDR block and no secondary subnet nearby
    3. CA single large instance with an EBS volume that can be reattached to a new instance and a manual recovery runbook
    4. DIncreasing the instance size in one Availability Zone with a larger root volume
    Show answer and explanation
    Correct answer: A

    Distributing instances across zones behind a load balancer that routes away from unhealthy targets is the core pattern for zonal resilience. A single instance or single-zone design creates a single point of failure regardless of how large the instance is.

  4. Question 19

    A stateless API must tolerate the failure of an entire Availability Zone while keeping data durable. Which TWO actions contribute to this? (Choose two.)

    1. AStore uploaded files on the local instance store of each instance
    2. BEnable Multi-AZ deployment for the managed relational database
    3. CPin all traffic to one instance with sticky sessions
    4. DStore objects in Amazon S3, which keeps data redundantly across multiple Availability Zones
    5. EKeep session data on a single EBS volume in one Availability Zone
    Show answer and explanation
    Correct answer: B, D

    Multi-AZ RDS maintains a synchronous standby in another zone, and S3 stores objects redundantly across zones. Instance store data is lost when an instance fails, and single-zone or sticky single-instance designs remove resilience.

  5. Question 20

    An active-passive web application must send users to a standby Region only when the primary endpoint's health check fails. Which Route 53 routing policy should be used?

    1. ALatency-based routing
    2. BGeolocation routing based on the user's country
    3. CWeighted routing with a weight of zero on the primary
    4. DFailover routing with a health check on the primary record
    Show answer and explanation
    Correct answer: D

    Failover routing returns the primary record while its health check passes and switches to the secondary record when it fails. Latency and geolocation choose by user location, and weighted routing splits traffic rather than failing over.

Monitoring and Logging (5 questions)

  1. Question 21

    A DevOps engineer needs to alert on p99 latency for an API served through API Gateway. The latency must be shown in a single dashboard widget without exporting logs. Which CloudWatch capability should be used?

    1. AThe Latency metric in the AWS/ApiGateway namespace with the p99 extended statistic
    2. BCloudTrail data events for API Gateway queried with Athena via S3
    3. CAPI Gateway execution logs queried with Logs Insights and exported
    4. DA metric filter on the access log group that counts requests per status code and route
    Show answer and explanation
    Correct answer: A

    API Gateway publishes a Latency metric to CloudWatch, and CloudWatch can display percentile statistics such as p99 on that metric directly. A metric filter counts log lines rather than computing percentiles from timings, and CloudTrail records API calls rather than request latency.

  2. Question 22

    An application writes logs to CloudWatch Logs. The operations team wants an alarm when more than 20 log lines containing error code 503 appear within five minutes, without changing the application code. Which combination should be used?

    1. AA metric filter on the log group that matches the 503 pattern, with a CloudWatch alarm on the resulting metric
    2. BA subscription filter that sends the logs to Kinesis Data Firehose
    3. CA Logs Insights query scheduled to run once a day and reviewed each morning
    4. DAn Amazon EventBridge rule that matches the log group ARN
    Show answer and explanation
    Correct answer: B

    A metric filter converts matching log events into a custom metric, and an alarm on that metric gives the threshold and notification without code changes. Subscription filters forward log data rather than alerting, and a daily query is not a near real-time alert.

  3. Question 23

    A team wants to trace requests across several microservices running on ECS to find which downstream call causes latency spikes. Which AWS service is designed for this?

    1. AAWS Config
    2. BAmazon Macie
    3. CAWS X-Ray
    4. DAmazon CloudWatch Synthetics
    Show answer and explanation
    Correct answer: C

    AWS X-Ray collects traces across distributed services and shows service maps and latency per segment. CloudWatch Synthetics runs canary tests, AWS Config tracks resource configuration, and Macie discovers sensitive data in S3.

  4. Question 24

    An operations team needs to find which SQL statements and wait events are driving load on an Amazon RDS database during a slowdown, without installing agents on the database. Which feature should they use?

    1. AAWS Config conformance packs
    2. BAmazon RDS Performance Insights
    3. CAWS Trusted Advisor checks
    4. DAWS Artifact SOC reports for audits
    Show answer and explanation
    Correct answer: B

    Performance Insights breaks database load down by wait events and SQL statements and is available directly in the RDS console. Trusted Advisor, Config conformance packs and Artifact do not show database load.

  5. Question 25

    A team wants memory utilization and disk space of their EC2 instances in CloudWatch, which are not published by default. Which component should be installed on the instances?

    1. AAWS Systems Manager Session Manager plugin
    2. BCloudWatch agent
    3. CAWS X-Ray daemon
    4. DVPC Flow Logs
    Show answer and explanation
    Correct answer: B

    Memory and disk usage are OS-level metrics that the hypervisor cannot see, so the CloudWatch agent must be installed and configured to publish them. The X-Ray daemon sends traces, the Session Manager plugin opens shells, and Flow Logs record network traffic.

Incident and Event Response (5 questions)

  1. Question 26

    An EC2 instance in an Auto Scaling group has a crashed process and is being marked unhealthy. The team wants to keep the instance intact for forensic analysis while it is removed from service. Which step should be taken?

    1. ATerminate the instance and rely on the Auto Scaling replacement to restore capacity quickly after failure
    2. BSet the group minimum size to zero and wait for the instance to drain its active connections
    3. CDelete the launch template version the instance was created from, which unregisters it from the group
    4. DPut the instance into Standby state so it is removed from service but remains running
    Show answer and explanation
    Correct answer: D

    Standby removes an instance from service while keeping it running, so the evidence stays available for investigation. Terminating the instance destroys the evidence, and deleting a launch template version does not affect a running instance.

  2. Question 27

    A developer changed a security group and broke connectivity to a production database. The team wants to be notified in near real time of such changes and to know which IAM principal made them. Which combination of services gives both?

    1. AAmazon Inspector findings and AWS Trusted Advisor weekly checks for EC2 and ECR images
    2. BAWS Config rule for security group changes with an SNS notification, plus CloudTrail for the caller identity
    3. CVPC Flow Logs reviewed manually each morning by an analyst who filters rejected traffic to spot changes in connectivity
    4. DAWS Config recording only, with no rules or notifications, and the history is kept in an encrypted S3 bucket for seven years
    Show answer and explanation
    Correct answer: B

    AWS Config records configuration changes and can evaluate rules that notify through SNS, while CloudTrail records the IAM principal behind each API call. Inspector assesses vulnerabilities, Trusted Advisor checks are periodic, and Flow Logs show traffic rather than who changed the rules.

  3. Question 28

    A CloudWatch alarm for an Auto Scaling group must trigger an automated runbook that restarts a failed service on the affected instance. Which pattern should be used?

    1. AAn SNS topic that a person reads and then runs the runbook by hand from the Systems Manager console once the page is acknowledged
    2. BAn alarm or EventBridge rule that starts a Systems Manager Automation runbook, which records its execution history
    3. CA cron job on each instance that restarts the service every hour without checking its state
    4. DDisabling the alarm and relying on Auto Scaling health checks alone until the unhealthy service is manually noticed by the operations team
    Show answer and explanation
    Correct answer: B

    Alarms and EventBridge rules can start Systems Manager Automation runbooks, which execute remediation steps automatically and keep an execution history. Manual runs and unconditional hourly restarts do not respond to the actual failure, and disabling the alarm removes the signal.

  4. Question 29

    After a production outage, the team must find which API calls changed a Lambda function's configuration in the previous six hours, including the caller. Which service provides this information?

    1. AAmazon CloudWatch Lambda Invocations metric for the function alias
    2. BAWS X-Ray service map showing latency per traced request path
    3. CAWS CloudTrail event history or a trail delivered to S3 and queried with Athena
    4. DAWS Compute Optimizer recommendations for EC2 and Lambda rightsizing
    Show answer and explanation
    Correct answer: C

    CloudTrail records management API calls such as UpdateFunctionConfiguration with the caller identity and time. Invocation metrics and X-Ray traces describe runtime behaviour, and Compute Optimizer produces sizing recommendations.

  5. Question 30

    A team wants an automated action whenever any CodePipeline stage fails. Which EventBridge pattern should they match?

    1. ASource aws.health with detail-type Scheduled Change
    2. BSource aws.codepipeline with detail-type CodePipeline Stage Execution State Change and state FAILED
    3. CSource aws.ec2 with detail-type EC2 Instance State-change Notification
    4. DSource aws.s3 with detail-type Object Created
    Show answer and explanation
    Correct answer: D

    CodePipeline publishes stage execution state change events under the aws.codepipeline source, and the FAILED state identifies failures. The other patterns come from unrelated services.

Want more DOP-C02 questions?

The full bank has 100 questions with answers and explanations, as a PDF, an online practice exam, or both.

Full question bank · 100 questions
$89$124

Both formats together. The best value.

Instant access after payment, with 90 days of updates. Checkout is on our store, AIExamCerts.