DOP-C02 practice questions and answers
All 15 questions from Practice Test 1 for AWS Certified DevOps Engineer – Professional, with the correct answer and a full explanation for each — including why the other options are wrong. Free to read, no signup.
What this set covers
Questions are weighted to match the official DOP-C02 exam guide. The real exam is 75 (65 scored) questions in 180 minutes with a pass mark of 750 / 1000.
- SDLC Automation4 q · 22%
- Configuration Management and IaC3 q · 17%
- Resilient Cloud Solutions2 q · 15%
- Monitoring and Logging2 q · 15%
- Incident and Event Response2 q · 14%
- Security and Compliance2 q · 17%
A payments company runs a container workload on Amazon ECS behind an Application Load Balancer. Deployments must send no traffic to a new task set until it passes health checks, must be able to shift traffic gradually, and must return to the previous version automatically within minutes if the 5xx rate rises. The team does not want to write custom rollback scripts. Which approach meets these requirements?
- AUse an ECS rolling update deployment with a minimum healthy percent of 100, and add a pipeline stage that redeploys the previous task definition when an operator reports errors.
- BUse AWS CodeDeploy with an ECS blue/green deployment group, a canary or linear traffic-shifting configuration, and a CloudWatch alarm registered on the deployment group for automatic rollback.✓
- CRegister two ECS services with the load balancer and switch the weighted target group manually after smoke tests pass.
- DDeploy with a CloudFormation change set and rely on stack rollback when the update fails.
Correct answer: B — Use AWS CodeDeploy with an ECS blue/green deployment group, a canary or linear traffic-shifting configuration, and a CloudWatch alarm registered on the deployment group for automatic rollback.
CodeDeploy blue/green for ECS creates a replacement task set, runs it behind a test listener, shifts production traffic in canary or linear steps, and rolls back automatically when an associated CloudWatch alarm goes into ALARM. Rolling updates replace tasks in place with no traffic-shifting control and no alarm-driven rollback. Manual target group weights and operator-reported errors fail the 'automatic, within minutes' requirement. CloudFormation rollback only triggers when the stack update itself fails — a healthy deploy that returns 5xx to users is a successful stack update as far as CloudFormation is concerned.
Blue/green deployments with CodeDeploy and ECSA central tooling account (Account T) hosts an AWS CodePipeline pipeline that must deploy a CloudFormation stack into a production account (Account P). Artifacts are stored in Amazon S3 and encrypted. Which combination of configuration steps is required? (Select THREE.)
- AIn Account T, create a customer managed AWS KMS key whose key policy allows the pipeline service role and Account P to use it, and an artifact S3 bucket whose policy grants Account P read access.✓
- BIn Account P, create a cross-account IAM role that Account T can assume, and add sts:AssumeRole for that role to the pipeline service role in Account T.✓
- CIn Account P, create a CloudFormation service role with the permissions needed by the resources in the stack, and reference the Account P resources in the pipeline's deploy action in Account T.✓
- DIn Account P, create the artifact S3 bucket and grant Account T write access to it.
- EIn Account T, create the CloudFormation service role for the stack and pass it to the deploy action in Account P.
- FUse an AWS managed KMS key for the artifact bucket so both accounts can decrypt artifacts without extra policy work.
Correct answer: A, B, C — In Account T, create a customer managed AWS KMS key whose key policy allows the pipeline service role and Account P to use it, and an artifact S3 bucket whose policy grants Account P read access. · In Account P, create a cross-account IAM role that Account T can assume, and add sts:AssumeRole for that role to the pipeline service role in Account T. · In Account P, create a CloudFormation service role with the permissions needed by the resources in the stack, and reference the Account P resources in the pipeline's deploy action in Account T.
Cross-account CodePipeline has three moving parts. First, artifacts live in the pipeline account and are encrypted with a customer managed KMS key — an AWS managed key cannot be shared across accounts, which is why option F fails. Second, the pipeline assumes a role that exists in the target account, so the role lives in Account P and the AssumeRole permission lives on the pipeline role in Account T. Third, CloudFormation acts inside the target account, so the service role for the stack must exist in Account P; a role in Account T cannot be passed to CloudFormation in Account P.
Create a pipeline that uses resources in another accountAn AWS CodeBuild project runs integration tests that must query an Amazon RDS instance in private subnets and pull dependencies from Amazon S3 and Amazon ECR. Security policy forbids adding a NAT gateway or any internet route to those subnets. What should the DevOps engineer configure?
- AConfigure the CodeBuild project with the VPC, private subnets and a security group allowed by the database, and add VPC endpoints for S3, ECR API, ECR Docker and CloudWatch Logs.✓
- BAdd the CodeBuild public IP ranges to the database security group and run the project outside the VPC.
- CRun the tests on an EC2 instance launched by the pipeline, then terminate it in a post-build step.
- DPeer the CodeBuild service VPC with the application VPC and add routes to the database subnets.
Correct answer: A — Configure the CodeBuild project with the VPC, private subnets and a security group allowed by the database, and add VPC endpoints for S3, ECR API, ECR Docker and CloudWatch Logs.
A CodeBuild project can be attached to your VPC, which places the build ENI in your subnets so it can reach the database privately. Without internet access, the build still needs to reach AWS services, and that is what the gateway endpoint for S3 and the interface endpoints for ECR and CloudWatch Logs provide. CodeBuild does not publish stable public IP ranges you can allow-list per project, spinning up EC2 instances rebuilds a service you already have, and you cannot peer with the CodeBuild service VPC.
Use CodeBuild with Amazon VPCA serverless API built with AWS Lambda behind Amazon API Gateway is deployed by publishing a new function version and repointing the alias in a shell script. Failures are noticed only when customers complain. The team wants deployments where a small share of traffic hits the new code first, automated checks run before and after traffic moves, and a rollback happens without a human. Which solution requires the least custom code?
- ADefine the function in AWS SAM with AutoPublishAlias and a CodeDeploy canary DeploymentPreference, add PreTraffic and PostTraffic hook functions, and attach CloudWatch alarms to the deployment.✓
- BKeep the shell script but publish a new version first and add a CloudWatch alarm that emails the on-call engineer to run the rollback script.
- CDeploy the new version behind a second API Gateway stage and move the CloudFront origin once smoke tests pass.
- DUse a CloudFormation change set with pre-traffic and post-traffic test functions defined in the change set.
Correct answer: A — Define the function in AWS SAM with AutoPublishAlias and a CodeDeploy canary DeploymentPreference, add PreTraffic and PostTraffic hook functions, and attach CloudWatch alarms to the deployment.
SAM's DeploymentPreference wires the function alias to CodeDeploy, which shifts alias weights in canary or linear steps, runs the PreTraffic and PostTraffic hooks, and rolls back automatically when a listed CloudWatch alarm fires. Emailing the on-call engineer keeps a human in the rollback path. A second stage plus a CloudFront origin swap is an all-or-nothing cutover with a slow DNS/cache tail. CloudFormation change sets have no traffic hooks at all — that option only sounds plausible.
Gradual deployments for serverless applicationsA media company operating under AWS Organizations must deploy an identical logging and guardrail stack into every account in the Workloads organizational unit, in four Regions. New accounts join the OU every month and must receive the stack without anyone running a deployment. Which approach meets the requirement with the least ongoing effort?
- AUse CloudFormation StackSets with service-managed permissions, target the Workloads OU, enable automatic deployment, and list the four Regions.✓
- BUse CloudFormation StackSets with self-managed permissions and add each new account's execution role by hand after it is created.
- CWrite a script that assumes a role in each account and runs create-stack with the --regions parameter for all four Regions.
- DCreate a CloudFormation change set in the management account that launches stack instances in every member account.
Correct answer: A — Use CloudFormation StackSets with service-managed permissions, target the Workloads OU, enable automatic deployment, and list the four Regions.
Service-managed StackSets integrate with Organizations: you target an OU, and automatic deployment creates stack instances in accounts that join it and removes them from accounts that leave. Self-managed permissions require you to create the administration and execution roles per account, which is the manual work being avoided. There is no --regions parameter on create-stack — it takes a single --region. Change sets preview updates to one stack; they do not deploy across accounts.
StackSets with AWS OrganizationsAn AWS Config rule named cloudformation-stack-drift-detection-check reports a production stack as NON_COMPLIANT with the message that CloudFormation failed to detect drift. The CloudFormation console shows the same stack as IN_SYNC. The stack also includes a custom resource backed by a Lambda function, and the team wants drift reporting for it. Which two statements explain what the team is seeing? (Select TWO.)
- AThe Config rule calls the CloudFormation DetectStackDrift API, and the rule defaults to NON_COMPLIANT when those calls are throttled.✓
- BCloudFormation does not support drift detection for custom resources.✓
- CDrift detection fails because the role in the cloudformationRoleArn parameter is missing permissions, which always produces this message.
- DDrift is only evaluated for properties that are explicitly set, so setting every property on the custom resource will include it in drift results.
- EThe finding is a known false positive and can be ignored until the stack is next updated.
Correct answer: A, B — The Config rule calls the CloudFormation DetectStackDrift API, and the rule defaults to NON_COMPLIANT when those calls are throttled. · CloudFormation does not support drift detection for custom resources.
Two separate things are happening. The Config rule depends on DetectStackDrift, and when those API calls are throttled the rule falls back to NON_COMPLIANT even though the stack is genuinely in sync. Separately, custom resources are not a supported resource type for drift detection, so no amount of configuration will produce drift results for them. A permissions problem produces a different, explicit message about the CloudFormation role. It is true that drift only covers explicitly set properties, but that does not bring unsupported resource types into scope, and treating the finding as noise to ignore hides real throttling.
cloudformation-stack-drift-detection-checkA CloudFormation stack manages an Amazon RDS database and an S3 bucket that holds customer documents. During a recent update, a property change replaced the database and the team nearly lost data. Going forward, an update must never delete or replace those two resources, and deleting the stack must leave them in place. What should the DevOps engineer add to the template?
- ADeletionPolicy: Retain and UpdateReplacePolicy: Retain on both resources.✓
- BDeletionPolicy: Snapshot on both resources only.
- CA CreationPolicy with a resource signal timeout on both resources.
- DEnable termination protection on the stack.
Correct answer: A — DeletionPolicy: Retain and UpdateReplacePolicy: Retain on both resources.
DeletionPolicy covers stack deletion and UpdateReplacePolicy covers the case where an update would replace a resource — you need both attributes to protect data through either path. Snapshot is valid for RDS but not for S3 buckets, and it still removes the live resource. CreationPolicy waits for signals during creation and has nothing to do with deletion. Termination protection blocks deleting the whole stack but does nothing about a replacement during an update.
UpdateReplacePolicy attributeAn application uses a single-instance Amazon Aurora MySQL cluster and connects through the instance endpoint. A maintenance window is scheduled, and the team must keep interruption to a minimum without changing application code that opens a large number of short-lived connections. Which combination of changes best meets this?
- AAdd an Aurora Replica in another Availability Zone and point the application at the cluster endpoint, and put Amazon RDS Proxy in front of the cluster.✓
- BIncrease the instance size before the maintenance window and keep the instance endpoint.
- CCreate a manual snapshot before the window and restore it if the instance becomes unavailable.
- DMove the application to the reader endpoint for the duration of the maintenance window.
Correct answer: A — Add an Aurora Replica in another Availability Zone and point the application at the cluster endpoint, and put Amazon RDS Proxy in front of the cluster.
The instance endpoint always points at one specific instance, so it cannot follow a failover. Adding a replica in a second AZ gives Aurora somewhere to fail over to, and the cluster endpoint always resolves to the current writer. RDS Proxy holds a warm connection pool and keeps client connections open during the failover, which is exactly what an app that churns short-lived connections needs. A bigger instance does not survive a failover, snapshot restore is measured in minutes to hours, and the reader endpoint cannot accept writes.
Amazon RDS Proxy and failoverEC2 instances in an Auto Scaling group write application logs to a local volume and ship them to Amazon S3 every five minutes. During scale-in events, the last few minutes of logs are lost because the instance terminates before the upload finishes. What is the correct way to fix this?
- AAdd an Auto Scaling lifecycle hook for instance termination that puts the instance in Terminating:Wait, run the final upload from a script or SSM Automation, then call CompleteLifecycleAction.✓
- BEnable instance scale-in protection on all instances in the group.
- CIncrease the Auto Scaling group's health check grace period.
- DSet the group's termination policy to OldestInstance.
Correct answer: A — Add an Auto Scaling lifecycle hook for instance termination that puts the instance in Terminating:Wait, run the final upload from a script or SSM Automation, then call CompleteLifecycleAction.
A termination lifecycle hook pauses the instance in Terminating:Wait, which is the supported window for flushing logs, draining connections or deregistering. The hook completes when your automation calls CompleteLifecycleAction or the timeout expires. Scale-in protection blocks scale-in entirely rather than making it safe. The health check grace period only delays health checks after launch. The termination policy chooses which instance goes, not how long it takes to go.
Amazon EC2 Auto Scaling lifecycle hooksA third-party appliance writes structured events to an Amazon CloudWatch Logs log group. The security team must receive an email within a few minutes whenever an event with severity CRITICAL appears, and they do not want a new log processing service to run and maintain. Which solution meets this requirement?
- ACreate a metric filter on the log group that matches CRITICAL, publish it as a custom metric, and create a CloudWatch alarm on that metric with an Amazon SNS topic the security team subscribes to.✓
- BCreate a CloudWatch metric stream to Amazon Data Firehose with a Lambda consumer that inspects records and publishes to Amazon SNS.
- CEnable CloudWatch Lambda Insights on the log group and configure it to notify an SNS topic when CRITICAL events are found.
- DEnable VPC Flow Logs for the appliance subnet and alarm on rejected traffic.
Correct answer: A — Create a metric filter on the log group that matches CRITICAL, publish it as a custom metric, and create a CloudWatch alarm on that metric with an Amazon SNS topic the security team subscribes to.
Metric filters turn matching log lines into a numeric metric that a standard CloudWatch alarm can watch, and the alarm action publishes to SNS — no servers, no code. Metric streams carry metrics, not log events, so they cannot search log text for a keyword. Lambda Insights is performance monitoring for Lambda functions and has no log-keyword alerting. Flow logs describe network traffic and say nothing about appliance severity levels.
Creating metrics from log events using filtersA platform team supports 60 AWS accounts. During incidents, engineers waste time signing in to each account to read CloudWatch logs and metrics. The team wants engineers to search logs and view metrics from many accounts in one place, with the least custom infrastructure. What should the DevOps engineer implement?
- AConfigure CloudWatch cross-account observability: set up a monitoring account and link the source accounts so their logs, metrics and traces are visible centrally.✓
- BCreate a CloudWatch Logs subscription filter in each account that streams to a central Amazon Data Firehose delivery stream and store the data in Amazon S3 for Athena queries.
- CGrant every engineer a cross-account IAM role in all 60 accounts and document a runbook for switching roles.
- DExport log groups to Amazon S3 on a daily schedule and build a QuickSight dashboard.
Correct answer: A — Configure CloudWatch cross-account observability: set up a monitoring account and link the source accounts so their logs, metrics and traces are visible centrally.
Cross-account observability is built for exactly this: link source accounts to a monitoring account and engineers query logs, metrics and X-Ray traces across all of them from one console, with no pipeline to run. Firehose to S3 plus Athena works but is a data pipeline you now own, and it loses the live console experience. Role switching keeps the per-account clicking. Daily exports are far too slow for incident response.
CloudWatch cross-account observabilityA company wants an automatic first response when Amazon GuardDuty reports a high-severity finding for an EC2 instance: the instance must be isolated from the network, a snapshot of its volumes taken for forensics, and the security channel notified. No human should have to start the process. Which design meets the requirement?
- ACreate an Amazon EventBridge rule matching GuardDuty findings with severity 7.0 or higher that starts an AWS Step Functions workflow to replace the instance's security groups with a quarantine group, create EBS snapshots, and publish to Amazon SNS.✓
- BEnable GuardDuty auto-remediation in the GuardDuty console and select the isolate-instance action.
- CCreate a CloudWatch alarm on the GuardDuty finding count that triggers an SNS notification to the security channel.
- DSchedule an AWS Lambda function every five minutes to call GetFindings and act on anything new.
Correct answer: A — Create an Amazon EventBridge rule matching GuardDuty findings with severity 7.0 or higher that starts an AWS Step Functions workflow to replace the instance's security groups with a quarantine group, create EBS snapshots, and publish to Amazon SNS.
GuardDuty publishes findings as EventBridge events, and an EventBridge rule can filter on severity and invoke Step Functions or Lambda — that gives you an ordered, retryable workflow for quarantine, snapshot and notify. GuardDuty has no built-in auto-remediation actions to switch on. An alarm on finding counts notifies but never isolates anything. Polling GetFindings adds delay and duplicate-handling logic for an event source that already pushes.
Creating custom responses to GuardDuty findings with EventBridgeAn audit found several Amazon S3 buckets with public access enabled. The company wants any bucket that becomes publicly readable to be corrected automatically within minutes, and it wants a record of what was changed. Which solution should the DevOps engineer build?
- AEnable the AWS Config managed rule s3-bucket-public-read-prohibited and attach an automatic remediation action that runs the AWS-DisableS3BucketPublicReadWrite Systems Manager Automation runbook.✓
- BRun a nightly Lambda function that lists all buckets and removes public ACLs.
- CApply a service control policy that denies s3:PutBucketAcl in every account.
- DTurn on S3 server access logging on all buckets and review the logs weekly.
Correct answer: A — Enable the AWS Config managed rule s3-bucket-public-read-prohibited and attach an automatic remediation action that runs the AWS-DisableS3BucketPublicReadWrite Systems Manager Automation runbook.
A Config managed rule detects the non-compliant bucket, and Config remediation runs an SSM Automation runbook to fix it, with the compliance timeline and Automation execution history serving as the audit record. A nightly job leaves buckets exposed for up to a day. An SCP denying PutBucketAcl outright blocks legitimate work and does nothing about buckets that are already public. Access logging records reads; it does not fix permissions.
Remediating noncompliant resources with AWS ConfigA company must continuously find software vulnerabilities and unintended network exposure on its EC2 fleet and container images in Amazon ECR, and it must keep an audit trail of who signed in to the instances. Which combination meets these requirements?
- AEnable Amazon Inspector for EC2 and ECR scanning with the SSM Agent installed on instances, and install the CloudWatch agent to ship the operating system authentication logs to CloudWatch Logs.✓
- BEnable Amazon GuardDuty and rely on its findings for vulnerability reports, and enable AWS CloudTrail data events for the instances.
- CEnable AWS Config with managed rules for approved AMIs, and use VPC Flow Logs for the sign-in audit trail.
- DRun Amazon ECR basic image scanning only, and enable AWS Trusted Advisor security checks.
Correct answer: A — Enable Amazon Inspector for EC2 and ECR scanning with the SSM Agent installed on instances, and install the CloudWatch agent to ship the operating system authentication logs to CloudWatch Logs.
Amazon Inspector is the vulnerability management service: it scans EC2 instances (using the SSM Agent for inventory) and ECR images continuously, and reports network reachability. Sign-in activity lives in the OS logs, so the CloudWatch agent is what gets it into CloudWatch Logs — CloudTrail records AWS API calls, not SSH logins. GuardDuty is threat detection, not vulnerability scanning. Config rules check configuration, flow logs show traffic not identities, and ECR basic scanning covers only OS packages in images.
What is Amazon Inspector?A CodeBuild project currently reads a database password from a plaintext environment variable defined in the buildspec file. Security requires that the credential never appear in the build definition or build logs, and that it rotate every 30 days without a pipeline change. What should the DevOps engineer do?
- AStore the credential in AWS Secrets Manager with rotation enabled, reference it in the buildspec with the secrets-manager environment variable type, and grant the CodeBuild service role secretsmanager:GetSecretValue and kms:Decrypt.✓
- BMove the password into a CodeBuild environment variable of type PLAINTEXT and mark the build logs as private.
- CCommit the password to a file in the repository and restrict repository access to the DevOps team.
- DStore the password in an S3 object and download it in the install phase with the AWS CLI.
Correct answer: A — Store the credential in AWS Secrets Manager with rotation enabled, reference it in the buildspec with the secrets-manager environment variable type, and grant the CodeBuild service role secretsmanager:GetSecretValue and kms:Decrypt.
CodeBuild resolves environment variables of type SECRETS_MANAGER at build time and masks them in logs, and Secrets Manager rotation replaces the value on a schedule with no change to the buildspec. A PLAINTEXT variable is exactly what the requirement forbids, and private logs do not remove the value from the build definition. Committing secrets to Git leaves them in history forever. Fetching from S3 is a hand-rolled secret store with no rotation and no log masking.
CodeBuild environment variables in build specsReady to try it under exam conditions?
Reading answers is not the same as recalling them with a clock running. Take the same 15 questions as a timed mock exam — 35 minutes, no feedback until you submit, then a score broken down by exam domain so you know what to study.
Start the timed DOP-C02 test →