Courseiva

CCNA Sdlc Automation Questions

75 of 316 questions · Page 3/5 · Sdlc Automation topic · Answers revealed

151
Multi-Selecthard

A company uses AWS CodePipeline to deploy a critical application. The pipeline has a manual approval step before deployment. Which TWO actions should be taken to improve security and auditability? (Choose two.)

Select 2 answers
A.Enable AWS CloudTrail to log all approval actions.
B.Remove the approval step and rely on post-deployment monitoring.
C.Integrate with AWS IAM to require multi-factor authentication (MFA) for approvers.
D.Replace the manual approval with an automated approval based on test results.
E.Use a shared IAM user for all approvers to simplify management.
AnswersA, C

Enabling AWS CloudTrail records the PutApprovalResult API calls made through CodePipeline when an approver clicks Approve or Reject. CloudTrail logs the IAM principal or federated user identity, the timestamp, the source IP address, and the decision, providing an immutable audit trail that satisfies compliance and forensic needs. This is the correct answer because the company's explicit requirement is to know who approved the deployment and when.

Why this answer

Enabling AWS CloudTrail to log all approval actions provides a detailed, immutable audit trail of who approved or rejected a pipeline stage, when it happened, and from which IP address. This is essential for compliance and forensic analysis, as CloudTrail captures the `Approval` API calls made by CodePipeline, including the `approve` and `reject` actions, along with the IAM user or role identity. Without CloudTrail, there is no native logging of manual approval events, making it impossible to prove accountability.

Exam trap

The trap here is that candidates often think automated approvals (Option D) are always more secure, but the question specifically asks for improving security and auditability of a manual approval step, and removing human oversight actually reduces security for critical deployments.

152
MCQmedium

A company uses AWS CodePipeline with a multi-branch strategy. Developers push to feature branches, which should trigger a pipeline that runs unit tests and then deploys to a staging environment. However, the pipeline only triggers on the main branch. What should be done to enable pipeline execution for feature branches?

A.Change the source provider from Amazon S3 to AWS CodeCommit.
B.Increase the polling frequency in the source stage to detect new branches.
C.Create a separate pipeline for each feature branch.
D.Update the source stage to use 'Webhook' as the change detection method and specify a branch pattern.
AnswerD

Configuring the source stage to use Webhook change detection with a branch pattern, such as refs/heads/feature/*, makes the pipeline automatically respond to pushes on matching feature branches. This allows a single pipeline to serve multiple branches by filtering events based on the branch reference, without manual per-branch pipelines. The webhook sends an event to CodePipeline only when the push matches the pattern, enabling efficient and dynamic multi-branch execution.

Why this answer

AWS CodePipeline can use a webhook (e.g., from GitHub or CodeCommit) to detect changes on any branch. By configuring the source stage with 'Webhook' as the change detection method and specifying a branch pattern (e.g., 'feature/*'), the pipeline will automatically trigger on pushes to matching feature branches, not just the main branch.

Exam trap

The trap here is that candidates often assume polling or changing the source provider will automatically detect new branches, but AWS CodePipeline's polling only monitors the configured branch reference (e.g., 'refs/heads/main'), not all branches, and changing the source provider does not alter this behavior.

How to eliminate wrong answers

Option A is wrong because changing the source provider from Amazon S3 to AWS CodeCommit does not inherently enable multi-branch triggering; both providers require proper change detection configuration (e.g., webhook or polling) to trigger on non-default branches. Option B is wrong because increasing polling frequency only affects how often CodePipeline checks for changes on the configured branch (typically main), but it does not enable detection of new branches or trigger on branches other than the one specified in the source stage. Option C is wrong because creating a separate pipeline for each feature branch is unnecessary and violates the multi-branch strategy; a single pipeline with a webhook and branch pattern can handle all feature branches dynamically.

153
Multi-Selectmedium

Which TWO actions are best practices when designing a CI/CD pipeline for a containerized application on Amazon ECS? (Choose two.)

Select 2 answers
A.Run a full integration test suite on every commit to the repository.
B.Separate the build stage from the deploy stage in the pipeline.
C.Build the Docker image in the deploy stage to ensure consistency.
D.Use a rolling update with a fixed number of tasks for deployment.
E.Use a blue/green deployment strategy for the ECS service.
AnswersB, E

Separating the build stage from the deploy stage ensures that a single immutable artifact—such as a Docker image or packaged JAR—is produced once and then promoted through environments (dev, staging, prod) without rebuilding. This eliminates configuration drift and makes the pipeline auditable, because the exact artifact tested can be deployed to production. It also enables independent validation and safe rollback: if a deployment fails, you can redeploy the previous artifact rather than re-running a build that may produce different output.

Why this answer

Separating the build stage from the deploy stage in a CI/CD pipeline for Amazon ECS ensures that the Docker image is built, tested, and validated independently before being promoted to production. This decoupling allows you to reuse the same immutable artifact across multiple environments (e.g., dev, staging, prod), reducing the risk of environment-specific build inconsistencies and enabling rollback to a known good image.

Exam trap

The trap here is that candidates often confuse 'rolling update' (a deployment configuration) with 'blue/green deployment' (a deployment strategy), and they may incorrectly select Option D because they think it provides the same safety guarantees as blue/green, but rolling updates with a fixed number of tasks lack the atomic traffic shift and instant rollback capabilities that blue/green offers.

154
Multi-Selecthard

A company is migrating to a microservices architecture on Amazon ECS with AWS Fargate. They want to automate the deployment process using AWS CodePipeline. The pipeline should build a Docker image, push it to Amazon ECR, and deploy the updated service to ECS. Which THREE components are required in the pipeline? (Choose 3.)

Select 3 answers
A.Deploy stage with AWS CodeDeploy to ECS.
B.Build stage with AWS CodeBuild to build the Docker image and push to ECR.
C.Manual approval stage.
D.Source stage with AWS CodeCommit or Amazon S3 as source.
E.Test stage with AWS CodeBuild to run unit tests.
AnswersA, B, D

The Deploy stage is mandatory because it uses AWS CodeDeploy's ECS deployment type to shift traffic from the old to the new task definition. CodeDeploy references an AppSpec file and the task definition produced during the Build stage, then updates the ECS service with either rolling updates or blue/green traffic shifting. Without this stage, the built and pushed container image would never be run as an active service in ECS.

Why this answer

AWS CodeDeploy is the native deployment service that integrates with Amazon ECS to perform blue/green deployments, rolling updates, and traffic shifting. In a CodePipeline, the Deploy stage uses CodeDeploy to orchestrate the ECS service update, ensuring zero-downtime deployments by managing task set creation and load balancer target group routing.

Exam trap

The trap here is that candidates often think a manual approval or test stage is mandatory for a production pipeline, but the DOP-C02 exam focuses on the minimal required components for a functional CI/CD pipeline, which are source, build, and deploy.

155
MCQeasy

A company uses AWS CodeBuild to run unit tests for a Python application. The buildspec.yml file specifies a build phase that runs 'pytest'. The team wants to ensure that the build fails if any test fails, and that test results are available in the CodeBuild console. Which change should they make to the buildspec.yml?

A.Modify the build phase to run 'pytest --junitxml=results.xml' and add an artifacts section to upload results.xml.
B.Add a 'reports' section to the buildspec.yml that specifies the test report group and the location of the test results file.
C.Add a post_build phase that checks the exit code of the build phase and fails the build if tests failed.
D.Set the 'fail-fast' option to true in the build phase to stop the build immediately if any test fails.
AnswerB

AWS CodeBuild supports test reporting through the 'reports' section in buildspec.yml. By specifying a report group and the path to the test results file (e.g., JUnit XML), CodeBuild can parse and display test results in the console. Additionally, if 'pytest' exits with a non-zero status on failure, the build fails automatically. This change provides visibility into test results and ensures failures are caught.

Why this answer

To make test results available in the CodeBuild console, the buildspec.yml must include a 'reports' section that specifies the report group and the location of the test results file. CodeBuild automatically fails the build if a command in the build phase returns a non-zero exit code, so 'pytest' failures will cause the build to fail. The 'reports' section integrates with CodeBuild's test reporting feature, providing detailed test outcomes.

The other options either describe non-existent features or do not provide the required reporting integration.

Exam trap

The trap here is confusing artifacts with test reports, or assuming that a separate post_build check is needed when the build already fails on non-zero exit codes.

156
MCQeasy

An organization is using AWS CodeDeploy to deploy an application to an Auto Scaling group. The deployment fails because the target group is not configured correctly. Which CodeDeploy component is responsible for registering instances with the load balancer?

A.The CodeDeploy agent configuration
B.The deployment group configuration
C.The AppSpec file hooks section
D.The application revision bundle
AnswerB

The deployment group configuration holds the load balancer or target group settings for the deployment. During an in-place or blue/green deployment, CodeDeploy automatically registers healthy instances with the target group defined in this configuration, and deregisters them before traffic shifts. It is this centrally defined setting, not anything in the application files or on the instance, that governs elastic load balancing integration.

Why this answer

The deployment group configuration in AWS CodeDeploy specifies the target group or load balancer for the deployment. CodeDeploy automatically registers instances in the Auto Scaling group with the specified target group as part of the deployment process. The AppSpec file hooks section defines custom lifecycle event hooks for scripts, but instance registration is handled by the CodeDeploy service based on the deployment group settings, not by hooks.

Exam trap

Candidates often incorrectly attribute instance registration to the AppSpec hooks section because hooks can run custom scripts. However, registration with a load balancer is a built-in function of CodeDeploy that relies on the deployment group configuration, not on user-defined hooks.

How to eliminate wrong answers

Option A is wrong because the CodeDeploy agent configuration is a file on the instance that controls the agent's behavior (e.g., logging, proxy settings) and does not handle load balancer registration. Option B is wrong because the deployment group configuration does specify the target group and load balancer settings, but it is not a component that directly registers instances; it defines the target group ARN and the deregistration delay, while the actual registration is performed by CodeDeploy service based on that configuration. Option D is wrong because the application revision bundle contains the application files and the AppSpec file, but it does not directly handle load balancer registration; it is the source of the deployment artifacts.

157
MCQmedium

An organization uses AWS CodeDeploy for automated deployments to EC2 instances. The deployment is failing with the error 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.' The deployment group has a minimum healthy hosts setting of 75%. The application has 4 instances. What is the MOST likely issue?

A.The AppSpec file references a script that does not exist.
B.The IAM instance profile does not have sufficient permissions.
C.The CodeDeploy agent is not installed on any of the instances.
D.The deployment failed on 2 instances, leaving only 2 healthy.
AnswerD

For a deployment to four instances, a minimum healthy hosts percentage of 75% requires that at least three instances remain available throughout the deployment. When two instances failed, the healthy count dropped to two (50%), which is below the required threshold, so CodeDeploy was forced to abort the deployment and mark it as failed. This is a classic example of the minimum healthy hosts guardrail catching a partial-failure scenario that other, fleet-wide issues would not produce.

Why this answer

With a minimum healthy hosts setting of 75% and 4 instances, at least 3 instances must remain healthy during deployment. If 2 instances fail, only 2 are healthy (50%), which falls below the 75% threshold, causing CodeDeploy to abort the deployment to prevent further impact. This error message directly corresponds to the healthy host count dropping below the configured minimum.

Exam trap

The trap here is that candidates may focus on individual instance failure causes (like missing scripts or permissions) instead of recognizing that the error message explicitly describes a fleet-wide healthy host count violation, making the math of 4 instances with 75% minimum the key diagnostic clue.

How to eliminate wrong answers

Option A is wrong because a missing script in the AppSpec file would cause individual instance failures, but the error message specifically indicates a fleet-wide healthy host count issue, not a script execution error. Option B is wrong because insufficient IAM instance profile permissions would prevent the CodeDeploy agent from pulling revisions or reporting status, typically resulting in a different error like 'AccessDenied' or agent timeout, not a healthy host threshold violation. Option C is wrong because if the CodeDeploy agent were not installed on any instances, the deployment would fail immediately with an 'agent not found' error for each instance, not the specific healthy host count error shown.

158
MCQhard

A company uses AWS CloudFormation to manage infrastructure. They need to implement a CI/CD pipeline that automatically updates CloudFormation stacks when changes are pushed to a CodeCommit repository. The pipeline must use change sets to review changes before execution. Which pipeline configuration meets these requirements?

A.Use a CloudFormation action in CodePipeline with action mode 'CREATE_UPDATE' and include a manual approval step before the action.
B.Use a CloudFormation action with action mode 'CHANGE_SET_REPLACEMENT' and then a separate action with mode 'CHANGE_SET_EXECUTE' after an approval step.
C.Use an AWS Lambda function to create a change set and trigger a manual approval via SNS.
D.Use a CloudFormation action with action mode 'CREATE_UPDATE' and set the 'Review' flag to true.
AnswerB

This is the correct approach for a review-before-execution pipeline. The CHANGE_SET_REPLACEMENT action creates a new change set (or replaces an existing one) that captures the exact resource-level differences between the current stack and the proposed template, but it does not apply any changes. A subsequent manual approval step then gates the pipeline, allowing a human reviewer to inspect the change set in the CloudFormation console or via CLI. Only after approval does the CHANGE_SET_EXECUTE action run, which applies the previously created change set, ensuring that no stack modification occurs without explicit review and approval.

Why this answer

CodePipeline's CloudFormation deployment action supports a 'CHANGE_SET_REPLACEMENT' mode that creates or replaces a change set without executing it, followed by a 'CHANGE_SET_EXECUTE' action that applies the change set after an approval step. This two-step approach allows teams to review infrastructure changes before they are applied, meeting the requirement to use change sets for review before execution.

Exam trap

The trap here is that candidates often assume a manual approval step combined with a 'CREATE_UPDATE' action is sufficient for review, but they miss that change sets are required to preview the actual changes before execution, and 'CREATE_UPDATE' does not generate a change set at all.

Why the other options are wrong

A

CREATE_UPDATE directly applies changes without creating a change set first.

C

This is more complex and not the native CodePipeline CloudFormation action.

D

There is no 'Review' flag; CloudFormation actions do not support reviewing before update in that mode.

159
MCQhard

A DevOps engineer manages a CodePipeline with a CodeCommit source, a CodeBuild test stage, and a manual approval before a production deploy stage. Audit requires that only the specific commit that passed testing can be deployed, and that no new commits pushed to the branch between test and approval can reach production. What should the engineer configure to guarantee this?

A.Configure the source action to use a specific commit ID as the source revision and disable polling so the pipeline only runs for that commit.
B.Add a stage-level condition or gate that fails the pipeline if the source artifact revision differs from the revision recorded at test time.
C.Enable the pipeline's artifact bucket versioning and add a lifecycle rule that expires old artifact versions after 30 days.
D.Keep the same pipeline execution through approval so the approved execution deploys the artifact produced earlier in that same execution.
AnswerD

A single pipeline execution carries its own artifacts from source through deploy. If the approval is part of that execution, the deploy stage consumes the exact artifact built and tested earlier, so commits pushed after the test stage start a new execution that must itself pass testing and approval, leaving the original execution's artifact intact.

Why this answer

The requirement is that the tested artifact, not just the branch, is what reaches production. Within one CodePipeline execution, artifacts are immutable across stages, so approving and continuing that execution deploys the tested revision. A later push starts a separate execution that cannot bypass test and approval, which preserves the audit guarantee without custom comparison logic.

Exam trap

The trap here is treating the source branch as the unit of control, when the deploy stage actually consumes the artifact of the pipeline execution, not the latest branch state.

160
MCQhard

An organization uses AWS CodePipeline with multiple stages: Source, Build, Test, and Deploy. The Test stage runs integration tests that take 30 minutes. The team wants to speed up feedback without skipping tests. Which action should they take?

A.Use a larger build environment for the Test stage.
B.Configure parallel build actions in the Test stage to run tests concurrently.
C.Remove the Test stage and rely on post-deployment testing.
D.Move the Test stage to after deployment.
AnswerB

CodePipeline naturally executes independent actions within a stage in parallel unless you set explicit runOrder values or action dependencies. By configuring multiple build actions, each running a partitioned portion of the test suite (by module, service, or shard), the total test work is spread across concurrent CodeBuild projects. The stage completes when all parallel actions finish, so overall duration approaches the slowest shard's critical path rather than the sum of all tests, directly reducing feedback time.

Why this answer

Running integration tests in parallel within the Test stage reduces the total wall-clock time for the test suite, speeding up feedback without skipping any tests. AWS CodePipeline supports parallel actions within a stage, allowing multiple test suites to execute concurrently, which directly addresses the goal of faster feedback while maintaining test coverage.

Exam trap

The trap here is that candidates often assume 'larger build environment' (Option A) is the universal solution for slow tests, but the DOP-C02 exam tests understanding that parallelism is the correct approach when tests are independent and the goal is to reduce elapsed time without sacrificing coverage.

How to eliminate wrong answers

Option A is wrong because using a larger build environment (e.g., more CPU/memory) does not inherently speed up integration tests that are sequential; it only helps if the tests are CPU-bound or memory-bound, but the bottleneck here is the 30-minute duration, which parallelism addresses. Option C is wrong because removing the Test stage eliminates integration testing entirely, violating the requirement to not skip tests and increasing the risk of deploying faulty code. Option D is wrong because moving the Test stage after deployment defeats the purpose of pre-deployment validation, allowing defects to reach production before detection, which contradicts the goal of faster feedback and safe deployment.

161
MCQmedium

A DevOps engineer is troubleshooting a failed AWS CloudFormation stack update. The stack contains an AWS::Lambda::Function resource. The update failed with the error 'Resource creation cancelled' after a timeout. The engineer wants to view the logs from the Lambda function during the stack update to diagnose the issue. What should the engineer do?

A.Use AWS CodeBuild to build and test the function locally
B.Enable detailed CloudFormation logging in the stack template
C.Access the CloudWatch Logs log group for the Lambda function
D.Review the CloudFormation stack events in the AWS Management Console
AnswerC

AWS Lambda automatically writes all execution logs—including output from print() statements, exception stack traces, and custom log messages—to a dedicated CloudWatch Logs log group named /aws/lambda/<function-name>. When the stack update fails, the Lambda function's runtime error is recorded as a log event, which you can view in the CloudWatch Logs console to pinpoint the root cause. Be sure to check the log stream that matches the exact timestamp of the failed update, and remember that logs are retained based on the log group's retention policy.

Why this answer

AWS Lambda automatically sends function execution logs to Amazon CloudWatch Logs. When a Lambda function is invoked during a CloudFormation stack update (e.g., via a custom resource or a function that runs as part of the update), all stdout, stderr, and logging statements are captured in a log group named /aws/lambda/<function-name>. Accessing this log group allows the engineer to view detailed error messages, stack traces, or timeout-related output that caused the 'Resource creation cancelled' failure.

Exam trap

The trap here is that candidates often confuse CloudFormation stack events (which show resource-level status) with the actual application logs from the Lambda function, leading them to choose Option D instead of recognizing that CloudWatch Logs is the correct source for debugging function execution failures.

How to eliminate wrong answers

Option A is wrong because AWS CodeBuild is a continuous integration service used to build and test code, not to view historical logs from a Lambda function that ran during a CloudFormation stack update; it cannot access CloudWatch Logs retroactively. Option B is wrong because CloudFormation does not have a 'detailed logging' feature that captures Lambda function execution logs; CloudFormation logs only its own orchestration events (e.g., resource creation, update, deletion) in stack events, not the application-level logs from the Lambda function itself. Option D is wrong because reviewing CloudFormation stack events in the AWS Management Console shows only the status and reason for each resource operation (e.g., 'Resource creation cancelled'), but does not include the actual stdout/stderr output or application logs from the Lambda function.

162
MCQmedium

A DevOps engineer needs to implement a CI/CD pipeline that builds a Docker image, scans it for vulnerabilities, and deploys it to Amazon ECS. The scanning must be integrated into the pipeline before the image is pushed to Amazon ECR. Which approach meets these requirements?

A.Enable ECR 'Scan on Push' and configure CodePipeline to deploy only if the scan result is clean.
B.Use CodeBuild to run a vulnerability scanner on the Docker image, then push to ECR only if the scan passes.
C.Use AWS Lambda to scan the image after push and automatically roll back if vulnerabilities are found.
D.Use AWS Security Hub to scan images in ECR and block deployment.
AnswerB

Running a scanner such as Trivy or Anchore inside a CodeBuild stage before the Docker push enforces a shift-left security gate; if the scanner exits with a non-zero code on critical/high vulnerabilities, the build fails and the image never reaches ECR. This keeps the registry free of vulnerable images and ensures only approved artifacts are available for subsequent pipeline stages.

Why this answer

It uses CodeBuild to run a vulnerability scanner on the Docker image before pushing to ECR, ensuring that only images that pass the scan are stored and deployed. This satisfies the requirement to scan before the image is pushed to ECR, which is critical for preventing vulnerable images from entering the registry.

Exam trap

The trap here is that candidates often confuse 'Scan on Push' (post-push) with pre-push scanning, or assume that Security Hub can directly scan and block deployments, when in reality it is an aggregation and correlation service, not a scanning engine.

Why the other options are wrong

A

Scan on Push scans after the image is pushed, not before. The requirement is to scan before push.

C

This scans after push, not before.

D

Security Hub aggregates findings but does not scan images itself; it relies on other services.

163
MCQeasy

A DevOps engineer is setting up a CI/CD pipeline for a microservices architecture. The team uses AWS CodeCommit, CodeBuild, and CodeDeploy. The engineer needs to ensure that the pipeline can automatically roll back the deployment if the health checks fail after deployment. Which action should the engineer take?

A.Use AWS Lambda to monitor health checks and trigger a rollback via the CodeDeploy API.
B.Configure the deployment group to roll back when a CloudWatch alarm is triggered.
C.Set up the deployment group to use blue/green deployment with traffic shifting.
D.Configure the pipeline to have a manual approval step after deployment.
AnswerB

CodeDeploy deployment groups support a built-in automatic rollback option triggered by CloudWatch alarms. When you configure one or more alarms in the deployment group, CodeDeploy monitors them during the deployment (and during traffic shifting for blue/green) and, if any alarm enters the ALARM state, it automatically rolls back the deployment to the last known good revision. This is a native, first-class feature that tightly integrates with Amazon CloudWatch and requires no custom code or external services, making it the recommended and correct way to achieve automated rollback on detected failures.

Why this answer

CodeDeploy natively supports automatic rollbacks triggered by CloudWatch alarms. By configuring the deployment group to monitor a CloudWatch alarm (e.g., based on ELB health check metrics), CodeDeploy will automatically initiate a rollback to the last known good revision if the alarm enters the ALARM state, ensuring health check failures are handled without custom scripting.

Exam trap

The trap here is that candidates often assume custom automation (like Lambda) is required for rollback, overlooking CodeDeploy's built-in CloudWatch alarm integration, which is the simplest and most reliable method for automatic rollback on health check failure.

How to eliminate wrong answers

Option A is wrong because while AWS Lambda can monitor health checks and call the CodeDeploy API, this approach introduces unnecessary complexity and custom code; CodeDeploy already provides built-in automatic rollback via CloudWatch alarms, which is the recommended and simpler solution. Option C is wrong because blue/green deployment with traffic shifting is a deployment strategy, not a rollback mechanism; it does not automatically revert the deployment if health checks fail unless combined with a rollback configuration. Option D is wrong because a manual approval step after deployment only pauses the pipeline for human review; it does not automate the rollback process and relies on manual intervention, which contradicts the requirement for automatic rollback.

164
MCQeasy

A developer wants to automate the creation of a new Amazon ECS service whenever a new Docker image is pushed to Amazon ECR. Which AWS service should be used to orchestrate this workflow?

A.Amazon EventBridge
B.AWS Step Functions
C.Amazon CloudWatch Logs
D.Amazon S3
AnswerA

Amazon EventBridge natively ingests ECR lifecycle events such as an image push or scan, publishing them as event objects. You can define a rule with an event pattern matching the aws.ecr source and ECR Image Action detail-type, then route that event to a Lambda function that calls the ECS CreateService or UpdateService API. This is the correct mechanism because it is event-driven and requires no polling or manual invocation.

Why this answer

Amazon EventBridge can capture ECR image push events (via the 'ECR Image Action' event type) and route them to a target such as an ECS service or a Lambda function that triggers an ECS service update or creation. This serverless event bus natively integrates with ECR and ECS, making it the simplest and most direct service to orchestrate the workflow without custom polling or additional orchestration logic.

Exam trap

The trap here is that candidates often confuse AWS Step Functions as the primary orchestrator for event-driven workflows, but EventBridge is the correct service for reacting to AWS service events like ECR pushes, while Step Functions is for coordinating multi-step processes after the event is received.

How to eliminate wrong answers

Option B (AWS Step Functions) is wrong because Step Functions is a workflow orchestration service that coordinates multiple AWS services, but it is not designed to directly react to ECR push events; you would still need an event source like EventBridge to trigger the Step Function. Option C (Amazon CloudWatch Logs) is wrong because CloudWatch Logs is a log storage and monitoring service, not an event-driven workflow trigger; it cannot initiate ECS service creation. Option D (Amazon S3) is wrong because S3 is an object storage service and does not natively capture ECR push events or trigger ECS service creation; it would require additional custom logic to poll or be notified.

165
Multi-Selectmedium

A company uses AWS CodeBuild to build and test a Node.js application. The buildspec.yml currently runs npm install and npm test. They want to also run a security scan using a third-party tool. Which THREE steps are required to integrate the security scan into the CodeBuild build?

Select 3 answers
A.Ensure the build fails if the scanner finds vulnerabilities by checking the exit code.
B.Create a new 'security' phase in the buildspec.yml.
C.Add a command to run the security scanner in the build phase.
D.Add a command to install the security scanning tool in the pre_build or build phase.
E.Upload the security scanner configuration to an S3 bucket and reference it in the buildspec.
AnswersA, C, D

CodeBuild evaluates each buildspec command's exit code; if the security scanner returns a non-zero exit status when vulnerabilities are found, the build phase will immediately fail. To guarantee this, invoke the scanner as the final command in the build phase or wrap its output so that any findings are translated into a non-zero exit code. Without this explicit exit-code enforcement, a scanner that always exits 0 would allow the pipeline to pass despite critical security findings.

Why this answer

CodeBuild phases (install, pre_build, build, post_build) run shell commands sequentially, and a non-zero exit code from any command causes the build to fail. By checking the exit code of the security scanner (e.g., via `$?` or relying on the tool's default exit behavior), the build will stop and report failure if vulnerabilities are found, enforcing a security gate. This is the standard mechanism to integrate third-party tools without custom scripting.

Exam trap

The trap here is that candidates think they need to create a custom phase (Option B) to run a security scan, but CodeBuild's fixed phases are sufficient—simply add the scanner command to the existing build phase after the test step.

166
MCQhard

Refer to the exhibit. The deployment succeeded but the application fails. What is the MOST likely cause?

A.The CodePipeline deployment action uses the wrong cluster.
B.The new task definition has a misconfigured database connection string or security group.
C.The ECS service is not registered with a target group.
D.The database is not available in the same Availability Zone.
AnswerB

A database connection timeout to the database IP address strongly indicates the new task definition is passing an invalid connection string or is associated with a security group that blocks the database port. The application container is starting and attempting to open a TCP connection, but the destination either rejects or silently drops it — exactly what a bad host, port, or restrictive inbound rule produces. This is an application-level configuration defect in the task definition that does not prevent the task from launching, which is why the deployment can still be marked successful.

Why this answer

The most common cause of a deployment succeeding but the application failing is a misconfiguration in the new task definition, such as an incorrect database connection string or a security group that does not allow traffic to the database. CodePipeline can successfully deploy the new task definition to ECS, but if the application cannot connect to its backend services due to these configuration errors, the application will fail at runtime. This aligns with the scenario where the deployment pipeline reports success but the application itself is non-functional.

Exam trap

The trap here is that candidates often assume a successful deployment means the application is fully functional, but AWS separates the deployment of infrastructure (task definition, service update) from the application's runtime dependencies, so a misconfigured connection string or security group can cause application failure post-deployment.

How to eliminate wrong answers

Option A is wrong because if the CodePipeline deployment action used the wrong cluster, the deployment would likely fail or the task would not run on the intended cluster, but the question states the deployment succeeded, so the cluster must be correct. Option C is wrong because if the ECS service were not registered with a target group, the deployment would still succeed (the task would run), but the service would not receive traffic from the load balancer; however, the question does not mention a load balancer or traffic routing issue, and the application failure is more likely due to a backend connectivity problem. Option D is wrong because database availability in the same Availability Zone is not a strict requirement for ECS tasks; ECS tasks can connect to databases across AZs as long as network connectivity and security group rules allow it, and the failure is more likely due to misconfigured connection strings or security groups.

167
MCQhard

A company uses AWS CodeStar to manage software development projects. The team wants to integrate a third-party issue tracking system with CodeStar. Which AWS service should they use to achieve this integration?

A.Amazon API Gateway
B.Amazon CloudWatch Events
C.AWS CodePipeline webhooks
D.Amazon Simple Notification Service (SNS)
AnswerC

AWS CodePipeline webhooks are the native, built-in mechanism for external systems to trigger pipeline executions via an HTTPS POST request. When you create a webhook, CodePipeline generates a dedicated URL and registers a secret token; the external service, such as an issue tracker or a third-party version control system, includes that token in its HTTP call so CodePipeline can verify the request and map the payload to the appropriate pipeline and input variables. This provides secure, bidirectional integration with external tools, enabling an issue tracker to start a pipeline when a pull request or issue is updated, and is the correct service for this scenario.

Why this answer

AWS CodePipeline webhooks allow you to connect external systems, such as a third-party issue tracking system, to your CodePipeline pipeline. When the external system triggers an event (e.g., an issue status change), the webhook sends an HTTP POST request to a configured endpoint in CodePipeline, which then starts the pipeline. This is the native integration mechanism for CodeStar to receive events from outside AWS.

Exam trap

The trap here is that candidates often confuse the purpose of AWS services like SNS or CloudWatch Events, thinking they can directly receive external HTTP callbacks, but they lack native webhook support for third-party systems, whereas CodePipeline webhooks are specifically designed for this integration.

How to eliminate wrong answers

Option A is wrong because Amazon API Gateway is used to create, publish, and manage RESTful APIs, not to directly integrate third-party issue tracking systems with CodeStar; it would require custom Lambda functions and additional overhead. Option B is wrong because Amazon CloudWatch Events (now Amazon EventBridge) is designed to route AWS service events and custom application events, but it cannot natively receive HTTP callbacks from a third-party issue tracking system without an intermediary like API Gateway. Option D is wrong because Amazon Simple Notification Service (SNS) is a pub/sub messaging service that can send notifications, but it does not provide a direct HTTP endpoint for third-party systems to trigger CodePipeline; it would require additional components to translate the webhook call into an SNS message.

168
Multi-Selecteasy

Which TWO are valid deployment configurations in AWS CodeDeploy? (Choose two.)

Select 2 answers
A.Rolling
B.Linear
C.AllAtOnce
D.Canary10Percent5Minutes
E.BlueGreen
AnswersC, D

AllAtOnce is a predefined CodeDeploy deployment configuration that sets the minimum healthy instances to 0, causing the deployment to update every target instance simultaneously. This configuration is valid and useful when you accept full fleet downtime during deployment, such as in development environments or for infrastructure with elastic load balancer deregistration. It is one of the named configurations you can select directly in the AWS CodeDeploy console or CLI.

Why this answer

In AWS CodeDeploy, the valid deployment configurations are predefined traffic-shifting strategies. 'AllAtOnce' is a valid configuration that deploys the new application revision to all instances simultaneously, making it one of the two correct options. 'Canary10Percent5Minutes' is also a valid configuration that shifts 10% of traffic to the new version for 5 minutes before deploying the remainder, making it the second correct option.

Exam trap

The trap here is that candidates confuse deployment types (like BlueGreen or Rolling) with deployment configurations (like AllAtOnce or Canary10Percent5Minutes), leading them to select 'BlueGreen' or 'Rolling' as valid configurations when they are actually deployment methods or strategies in other AWS services.

169
MCQhard

An organization uses AWS CodePipeline to deploy a serverless application using AWS Lambda and Amazon API Gateway. The pipeline includes a manual approval action. The team wants to ensure that the approval email is sent to multiple approvers and that any one of them can approve or reject. How should the approval action be configured?

A.Specify multiple email addresses in the 'ApproverEmail' field of the approval action.
B.Set the 'Approvers' field in the approval action to a comma-separated list of IAM user ARNs.
C.Add multiple IAM users to the pipeline's service role.
D.Create an Amazon SNS topic with multiple subscribers, and configure the approval action to use that SNS topic ARN.
AnswerD

This is the correct approach because CodePipeline's manual approval action has an 'SNSTopicArn' configuration field that, when set, causes the pipeline to publish an approval notification to the specified SNS topic. Each email address (or other endpoint) subscribed to that topic receives the notification, and any of those subscribers—assuming they have the necessary IAM permissions—can review and approve or reject the action via the AWS console, CLI, or API. This design cleanly supports multiple approvers and also allows you to use other SNS protocols such as SMS or Lambda for custom notification flows.

Why this answer

AWS CodePipeline's manual approval action can be configured to send notifications through an Amazon SNS topic. By creating an SNS topic with multiple subscribers (e.g., email addresses), any one of the subscribers can receive the approval request and take action (approve or reject). This satisfies the requirement for multiple approvers where any single approver can act.

Exam trap

The trap here is that candidates often assume the 'ApproverEmail' field can accept multiple addresses or that IAM-based approvers can be listed directly, but AWS CodePipeline relies on SNS for multi-approver scenarios, not direct email or IAM lists.

How to eliminate wrong answers

Option A is wrong because the 'ApproverEmail' field in the approval action accepts only a single email address, not multiple; specifying multiple addresses would cause a validation error. Option B is wrong because the 'Approvers' field does not exist in the approval action configuration; CodePipeline uses SNS topics for notifications, not IAM user ARNs. Option C is wrong because adding IAM users to the pipeline's service role does not control who receives approval notifications; the service role defines permissions for the pipeline itself, not approval recipients.

170
MCQeasy

A DevOps engineer is setting up a CI/CD pipeline for a Node.js application. The application must be built, tested, and deployed to an Amazon ECS cluster. The team wants to use AWS CodeBuild to run unit tests and package the application as a Docker image, and AWS CodePipeline to orchestrate the workflow. Which artifact type should CodeBuild output to be used by a subsequent CodePipeline action?

A.A Docker image pushed to Amazon ECR.
B.A zip file containing the application source code.
C.A tarball stored in Amazon S3.
D.A JSON file with the image details.
AnswerD

This is correct because the ECS deploy action in CodePipeline consumes an image definitions file, typically named imagedefinitions.json, formatted as a JSON array mapping each ECS container name to its image URI (for example, [{"name":"web","imageUri":"123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:latest"}]). CodeBuild generates this file as a pipeline artifact after pushing the image to ECR, and CodePipeline uses it to create/update the task definition and trigger the deployment. The file must be at the artifact root with the recognized name; any other JSON structure or filename will cause the deploy action to fail.

Why this answer

CodePipeline's ECS deploy action requires an input artifact containing an imagedefinitions.json file that specifies the image URI. CodeBuild should produce this JSON file as its output artifact, not merely push the image to ECR. The subsequent deploy action reads the JSON file to determine which image to use, so the correct artifact type is a JSON file with image details.

Exam trap

The trap is that candidates may think CodeBuild passes the Docker image itself as an artifact, but in reality, the artifact is a configuration file (imagedefinitions.json) that tells the ECS deploy action which image to use.

How to eliminate wrong answers

Option B is wrong because a zip file containing the application source code is not a valid artifact type for an ECS deploy action; the deploy action requires image details, not raw source code. Option C is wrong because a tarball stored in Amazon S3, while it can be an artifact, does not provide the image URI and tag information needed by CodePipeline's ECS deploy action; the deploy action specifically expects an imagedefinitions.json file, not a generic archive. Option D is wrong because a JSON file with image details is actually the correct format, but the option does not specify that it must be named imagedefinitions.json and be part of a build output artifact; without that specific file name and structure, the ECS deploy action will fail to parse the deployment details.

171
MCQeasy

A developer is using AWS CloudFormation to deploy a stack that includes an AWS Lambda function. The Lambda function code is stored in an S3 bucket. The CloudFormation template references the S3 bucket and object key. The developer wants to update the Lambda function code by uploading a new zip file to S3 and then updating the stack. The developer updates the S3 object with a new version, but the stack update does not automatically use the new code. What should the developer do to ensure the stack update uses the new code?

A.Enable S3 event notifications to trigger a CloudFormation stack update when the object is updated.
B.Modify the CloudFormation stack policy to allow updates to the Lambda function.
C.Delete the stack and recreate it with the new code.
D.Upload the new code to a different S3 key or specify a new version ID in the CloudFormation template.
AnswerD

CloudFormation tracks the AWS::Lambda::Function Code property using the literal values of S3Bucket, S3Key, and optionally S3ObjectVersion. Uploading new code to a different S3 key—or to the same key with a new object version ID—makes one of those template properties change, so a stack update sees a diff and refreshes the Lambda function's code. This is the standard practice because CloudFormation does not automatically compare content hashes or ETags; it relies on explicit property changes. If you reuse the same key and do not specify a version (or S3 versioning is disabled), CloudFormation will not detect the update and the function continues running old code.

Why this answer

CloudFormation only detects changes to S3 objects if the S3 key or version changes. By uploading the new code with a different key or specifying a new version ID in the template, CloudFormation will recognize the change and update the Lambda function. Option A is incorrect because S3 event notifications do not automatically trigger stack updates for code changes; they are typically used for other automation.

Option B is incorrect because stack policies control whether resources can be updated, but they do not cause CloudFormation to detect the code change; the template reference itself must indicate a new version. Option C is incorrect because deleting and recreating the stack is unnecessary and disruptive; a simple stack update with a new version ID is sufficient.

172
MCQhard

A company has a monolith application that takes over an hour to build. The DevOps team wants to implement continuous integration using AWS CodeBuild. The build environment requires a large amount of dependencies that are rarely updated. Which strategy will MINIMIZE build time and cost?

A.Enable Amazon S3 cache for the CodeBuild project to reuse dependencies from previous builds.
B.Store the dependencies in an Amazon S3 bucket and download them at the start of each build.
C.Create a custom Docker image that includes all dependencies and use it as the build environment.
D.Use a larger compute type for the CodeBuild project to speed up the build.
AnswerC

Creating a custom Docker image that pre-installs all dependencies means those dependencies already exist inside the image's local file system when the CodeBuild container starts, so there is no download phase at all. The build can proceed directly to compilation, packaging, and testing, making the build time deterministic and dramatically shorter for a monolith. This image should be stored in Amazon ECR and updated whenever the dependency set changes, ensuring the build environment is both fast and consistent.

Why this answer

By pre-baking all rarely-updated dependencies into a custom Docker image, the build environment is ready instantly without any download or installation steps. This eliminates the overhead of fetching dependencies at build time, which is the primary bottleneck for a monolith with a large dependency set, and minimizes both build duration and cost by reducing compute time.

Exam trap

The trap here is that candidates often assume caching (Option A) or downloading from S3 (Option B) is sufficient, but they overlook that for rarely-updated dependencies, pre-building them into a custom image eliminates the dependency installation step entirely, which is the most time-consuming part of the build.

How to eliminate wrong answers

Option A is wrong because Amazon S3 cache in CodeBuild is designed for caching intermediate build artifacts (e.g., compiled objects) to speed up incremental builds, but it does not eliminate the need to download or install dependencies from scratch on a fresh build environment; the cache must be populated and restored, which still incurs network transfer time and storage costs. Option B is wrong because downloading dependencies from an S3 bucket at the start of each build still requires significant network I/O and time, especially for a large dependency set, and does not reduce the build duration as effectively as having them pre-installed in the environment. Option D is wrong because using a larger compute type (e.g., more vCPUs/memory) only accelerates the build steps themselves (compilation, testing) but does not address the bottleneck of installing dependencies; the dependency installation time remains largely unchanged, and larger instances cost more per minute, increasing overall cost without proportional time savings.

173
MCQeasy

A DevOps engineer is setting up a CI/CD pipeline for a microservices application using AWS CodePipeline. The pipeline includes a Test stage that runs integration tests against a staging environment. The engineer wants to ensure that manual approval is required before deploying to production. Which action should be taken?

A.Configure a CodeCommit approval rule template to block the merge.
B.Use CloudWatch Events to send a notification and wait for a custom signal.
C.Set the pipeline to only run on manual invocation.
D.Add a manual approval action in the pipeline stage before production deployment.
AnswerD

A manual approval action pauses the pipeline at the stage boundary, requiring a nominated approver to review and release the change before production deployment proceeds. This directly satisfies the stem's constraint that manual approval is required before deploying to production, without altering the Test stage or build artefacts.

Why this answer

AWS CodePipeline supports a manual approval action that can be added to any stage. By placing this action in the stage immediately before the production deployment, the pipeline will pause and require an authorized user to manually approve the transition, ensuring that integration tests have passed before any production release occurs.

Exam trap

The trap here is that candidates may confuse repository-level approval mechanisms (like CodeCommit approval rules) with pipeline-level deployment approvals, or assume that manual invocation alone satisfies the requirement for a conditional approval step.

How to eliminate wrong answers

Option A is wrong because CodeCommit approval rule templates are used to enforce code review policies on pull requests within the repository, not to control deployment approvals in a pipeline. Option B is wrong because CloudWatch Events can trigger notifications but cannot natively pause a pipeline and wait for a custom signal; implementing such a wait would require a custom Lambda function and additional complexity, whereas CodePipeline provides a built-in manual approval action. Option C is wrong because setting the pipeline to only run on manual invocation would prevent automated triggers (e.g., from code pushes), but it does not add a conditional approval step before production deployment; the entire pipeline would run without any pause for manual review.

174
Multi-Selectmedium

A company is implementing a CI/CD pipeline for a containerized application using AWS CodePipeline, CodeBuild, and Amazon ECS. The pipeline should automatically deploy to a staging environment and then, after manual approval, to production. The production environment uses an ECS service with rolling update deployment. Which TWO actions are necessary to achieve this?

Select 2 answers
A.Use CloudFormation to deploy the ECS service with a rolling update policy.
B.Add a manual approval stage in CodePipeline between staging and production.
C.Set up an ECS task definition with a sidecar container for health checks.
D.Use the ECS-to-CodePipeline deploy action configured for rolling update.
E.Configure CodeBuild to push the Docker image to Amazon ECR.
AnswersB, D

A manual approval action in CodePipeline pauses the pipeline at that stage until an IAM user with approval permissions reviews and approves or rejects the promotion. This is the standard control gate between staging validation and production release, satisfying the requirement for a deliberate go/no-go decision before any prod traffic is changed.

Why this answer

A manual approval stage in CodePipeline allows a human to review and approve the deployment before it proceeds to production, which is a common requirement for controlled rollouts. Option D is correct because the ECS-to-CodePipeline deploy action (using the ECS deploy provider) natively supports rolling update deployments by updating the ECS service with the new task definition, which aligns with the requirement for a rolling update strategy.

Exam trap

The trap here is that candidates often assume CloudFormation is required for any infrastructure change in a pipeline, but CodePipeline's native ECS deploy action directly updates the service without needing CloudFormation, and the rolling update is a built-in behavior of the ECS service itself.

175
MCQhard

A company uses AWS CodeBuild to compile a Java application. The buildspec.yml includes a pre_build phase that runs unit tests and a build phase that packages the application. Recently, builds have been failing intermittently with 'OutOfMemoryError' during the test phase. The build environment is set to 'BUILD_GENERAL1_SMALL'. What is the MOST cost-effective solution?

A.Split the tests into smaller batches using CodeBuild test splitting.
B.Change the build environment to 'BUILD_GENERAL1_MEDIUM' which has more memory.
C.Configure the buildspec to set MAVEN_OPTS='-Xmx512m' to reduce JVM heap usage.
D.Use multiple CodeBuild jobs to run tests in parallel.
AnswerB

Upgrading to BUILD_GENERAL1_MEDIUM is the correct fix because CodeBuild compute tiers directly define the memory and vCPU available to the build environment: GENERAL1_SMALL provides 3 GB, while GENERAL1_MEDIUM provides 7 GB. This increases the total addressable memory for the Maven JVM, native code, and metaspace, directly resolving the OutOfMemoryError without altering the application or its dependencies. It is also cost-effective because you only pay for builds that use the larger compute type, and the price increase is modest compared to the engineering effort of optimizing memory usage.

Why this answer

The 'BUILD_GENERAL1_SMALL' environment provides only 3 GB of memory, which is insufficient for the unit tests, causing intermittent 'OutOfMemoryError'. Upgrading to 'BUILD_GENERAL1_MEDIUM' (7 GB) directly addresses the memory shortage without architectural changes, and it is the most cost-effective solution because it avoids the complexity and additional costs of parallel jobs or test splitting while still resolving the root cause.

Exam trap

The trap here is that candidates often choose to reduce JVM heap (Option C) thinking it will prevent OutOfMemoryError, but in reality reducing heap makes the problem worse; the correct approach is to increase available memory, not cap it further.

How to eliminate wrong answers

Option A is wrong because CodeBuild test splitting distributes tests across multiple concurrent builds, which increases overall compute time and cost, and does not increase the memory available to a single test process—the JVM still runs out of memory within each split batch. Option C is wrong because setting MAVEN_OPTS='-Xmx512m' reduces the maximum heap size, which would likely worsen the OutOfMemoryError by further restricting available memory; the issue is insufficient total memory, not excessive heap allocation. Option D is wrong because running multiple CodeBuild jobs in parallel multiplies the cost and does not fix the memory limit of the individual build environment; each job still runs on a 'BUILD_GENERAL1_SMALL' instance with only 3 GB of memory.

176
MCQmedium

A development team is using AWS CodeCommit to store source code and AWS CodePipeline to automate builds and deployments. The team wants to ensure that builds and tests are triggered only when code is pushed to specific branches, and that manual approval is required before deploying to production. Which CodePipeline configuration should the team implement?

A.Configure the source action to trigger on all branches and add a manual approval step before the build stage.
B.Configure the source action with a branch filter for main, and add a manual approval step before the build stage.
C.Use a branch filter on the build action to run only for the main branch, and add a manual approval step before the deploy stage.
D.Configure the source action with a branch filter for main, and add a manual approval step before the production deployment stage.
AnswerD

The source action's branch filter ensures the pipeline only starts when commits are pushed to main, preventing feature branch work from entering the pipeline. The manual approval step immediately preceding the production deployment stage provides a human gate before the final artifact is deployed, meeting the requirement to require approval for production releases while keeping lower environments automated. This arrangement minimizes unnecessary builds and accurately enforces change management only where needed.

Why this answer

CodePipeline source actions support branch filters that restrict which Git branches trigger the pipeline. By filtering on 'main', only pushes to that branch initiate the pipeline. Adding a manual approval step before the production deployment stage ensures that no code reaches production without explicit human sign-off, meeting both requirements precisely.

Exam trap

The trap here is that candidates may confuse where branch filters can be applied (source action only) and where manual approval should be placed (before the production deploy stage, not before build), leading them to select options that filter incorrectly or place approval at the wrong stage.

How to eliminate wrong answers

Option A is wrong because triggering on all branches would cause builds and tests for every push, including feature branches, which violates the requirement to trigger only on specific branches. Option B is wrong because adding the manual approval step before the build stage would require approval before any build runs, even for non-production branches, and does not align with the requirement for approval before deploying to production. Option C is wrong because branch filters cannot be applied to build actions in CodePipeline; branch filtering is a source action configuration, and placing the approval step before the deploy stage is correct, but the filter placement is invalid.

177
MCQhard

A team uses AWS CodePipeline with a source action from an Amazon S3 bucket. The pipeline triggers on changes to the S3 bucket, but sometimes runs twice for a single commit. What is the most likely cause?

A.CodePipeline has a deduplication setting that is disabled.
B.S3 event notifications for the same object may be delivered more than once.
C.The S3 bucket has versioning enabled.
D.The pipeline is also triggered by a CloudWatch Events rule.
AnswerB

Amazon S3 event notifications are designed with at-least-once delivery semantics, meaning the same s3:ObjectCreated:Put event can be delivered more than once, especially during retries or internal service-side replication. Each delivered notification is seen by CodePipeline as a new source change, so a single object upload can start duplicate pipeline executions. Versioning is irrelevant to this behavior because the duplicate is a delivery-level retry, not a new object version.

Why this answer

Amazon S3 event notifications are designed for at-least-once delivery, meaning the same event (e.g., an object PUT) can be delivered multiple times. When CodePipeline uses S3 as a source, it relies on these notifications to trigger the pipeline. If S3 sends duplicate notifications for the same object version, CodePipeline will start a new execution for each notification, causing the pipeline to run twice for a single commit.

Exam trap

The trap here is that candidates may assume S3 event notifications are exactly-once, leading them to incorrectly suspect versioning or a missing deduplication setting, rather than recognizing S3's inherent at-least-once delivery behavior.

How to eliminate wrong answers

Option A is wrong because CodePipeline does not have a configurable deduplication setting; deduplication is handled by the source event mechanism, not a pipeline-level toggle. Option C is wrong because S3 versioning, when enabled, creates distinct object versions for each PUT, and CodePipeline triggers on changes to the bucket (including new versions), but versioning alone does not cause duplicate notifications—it actually helps differentiate versions. Option D is wrong because if a CloudWatch Events rule were also triggering the pipeline, it would be an additional trigger source, but the question states the pipeline triggers on S3 bucket changes, and the most likely cause of duplicate runs is duplicate S3 event notifications, not an extra rule.

178
MCQmedium

A development team uses AWS CodeBuild to compile a Java application. The build takes 15 minutes on average, but recently it started taking over 30 minutes. The buildspec.yml file is unchanged. What is the most likely cause?

A.The cache for the build project was cleared, forcing a full dependency download.
B.The build environment was changed from a Linux to a Windows environment.
C.The build project's compute type was downgraded to a smaller instance.
D.The buildspec.yml file was updated to include more build commands.
AnswerA

Clearing a CodeBuild project's cache removes previously downloaded dependency artifacts, such as those stored in the local Maven repository (~/.m2) or in an S3 cache bucket. On the next build, Maven must reach out to remote repositories to re-download every JAR it needs, adding significant network and I/O time on top of the compile itself. Because the buildspec commands are unchanged, the only impact is that dependency resolution is no longer incremental, directly explaining the increased build duration.

Why this answer

The most likely cause is that the build project's cache was cleared, forcing a full dependency download. CodeBuild can cache dependencies (e.g., Maven local repository) to speed up builds. If the cache is invalidated or cleared, the build must re-download all dependencies from the internet, significantly increasing build time from 15 minutes to over 30 minutes, even though the buildspec.yml is unchanged.

Exam trap

The trap here is that candidates may assume a compute type downgrade is the cause, but the sudden change in build time without any configuration change points to cache invalidation, not a gradual performance degradation.

How to eliminate wrong answers

Option B is wrong because changing from a Linux to a Windows environment would require a different buildspec.yml or runtime configuration, and the question states the buildspec.yml is unchanged. Option C is wrong because downgrading the compute type (e.g., from BUILD_GENERAL1_LARGE to BUILD_GENERAL1_SMALL) would cause a consistent increase in build time for all builds, not a sudden change after a period of normal 15-minute builds. Option D is wrong because the question explicitly states the buildspec.yml file is unchanged, so no additional build commands were added.

179
MCQhard

An organization uses AWS CodeDeploy to deploy a web application to an Auto Scaling group. The deployment fails with the error 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.' The engineer reviews the deployment logs and finds that the AppSpec file is correctly formatted and the scripts run successfully on some instances. What is the MOST likely cause?

A.The CodeDeploy agent is not installed on some instances.
B.The target group is not configured to route traffic to the instances.
C.The health check grace period for the Auto Scaling group is too short.
D.The IAM role assigned to the EC2 instances does not have sufficient permissions.
AnswerC

The health check grace period for the Auto Scaling group is too short. When an Auto Scaling group launches a new instance, it waits for the health check grace period before evaluating the instance's EC2 health status. If this period expires before CodeDeploy has installed and started the application, the ASG may consider the instance unhealthy and terminate it, interrupting the deployment. This causes the deployment to fail on those instances, even though the CodeDeploy agent and IAM permissions are fine. The correct fix is to increase the ASG health check grace period to cover the full deployment duration, including bootstrapping and application startup.

Why this answer

The error indicates that instances are failing the deployment health check after the AppSpec scripts run successfully. When the health check grace period for the Auto Scaling group is too short, instances may be marked unhealthy before the application has fully started and passed the target group health checks, causing CodeDeploy to consider them failed. This is the most likely cause because the scripts succeed on some instances but the overall deployment fails due to insufficient healthy instances.

Exam trap

The trap here is that candidates often confuse deployment script success with overall deployment health, not realizing that CodeDeploy relies on the target group's health checks (configured via the Auto Scaling group's health check grace period) to determine if an instance is healthy after deployment.

How to eliminate wrong answers

Option A is wrong because if the CodeDeploy agent were not installed on some instances, the deployment logs would show agent connection errors or missing agent events, not successful script execution on those instances. Option B is wrong because the target group not routing traffic would cause health check failures, but the error message specifically mentions 'too few healthy instances' which is a health check issue, not a routing configuration issue; CodeDeploy relies on the target group health checks to determine instance health. Option D is wrong because insufficient IAM permissions would cause the scripts to fail with access denied errors or the agent to fail to download the revision, not succeed on some instances and fail overall due to health checks.

180
MCQmedium

A company uses AWS CodePipeline with a source stage from Amazon S3. The pipeline triggers on changes to the S3 bucket. However, the pipeline does not trigger when a new object is uploaded. What is the MOST likely cause?

A.The S3 bucket policy denies the CodePipeline service role.
B.The S3 bucket is in a different AWS Region than the pipeline.
C.The S3 bucket does not have versioning enabled.
D.The S3 bucket does not have an event notification configured to invoke the pipeline.
AnswerD

CodePipeline automatically starts an S3 source only when the bucket is configured with an event notification that sends object-created events to the pipeline's trigger. Typically, this is implemented via an Amazon S3 event notification targeting an Amazon EventBridge rule, or via a CloudWatch Events rule that filters on the bucket's PUT operations. Without that configuration, uploading a new file to the bucket does not cause the pipeline to initiate, leaving it in a 'Succeeded' or previous state until a manual release is triggered. This exactly matches the reported symptom.

Why this answer

CodePipeline does not automatically monitor S3 buckets for new objects. To trigger a pipeline on S3 events, you must explicitly configure an S3 event notification (e.g., s3:ObjectCreated:Put) that sends the event to CloudWatch Events or directly to CodePipeline via Amazon EventBridge. Without this notification, the pipeline will not start when a new object is uploaded.

Exam trap

The trap here is that candidates often assume CodePipeline automatically polls S3 for changes (like GitHub webhooks), but in reality, S3 requires an explicit event notification configuration to trigger the pipeline, and the exam tests this distinction between polling-based and event-driven triggers.

How to eliminate wrong answers

Option A is wrong because the S3 bucket policy denying the CodePipeline service role would cause permission errors (e.g., access denied) when the pipeline tries to fetch source artifacts, not a failure to trigger. Option B is wrong because CodePipeline supports cross-region actions; an S3 source in a different region is allowed as long as the pipeline has a cross-region action configured. Option C is wrong because S3 versioning is not required for pipeline triggers; it is only needed if you want to use specific object versions as source artifacts, but the trigger itself works without versioning.

181
Multi-Selectmedium

Which TWO are valid use cases for using AWS CodeArtifact in a CI/CD pipeline? (Choose two.)

Select 2 answers
A.Caching dependencies from public repositories to improve build speed and reliability.
B.Storing Docker images that are used by ECS tasks.
C.Hosting npm packages that are consumed by CodeBuild during the build phase.
D.Storing source code archives for use in deployment stages.
E.Hosting static website assets for deployment to S3.
AnswersA, C

CodeArtifact acts as an intermediary upstream repository, caching packages from public registries such as npmjs, Maven Central, or PyPI. When CodeBuild first requests a dependency, CodeArtifact fetches it from the public source and stores a copy in your domain; subsequent builds retrieve the cached copy directly from CodeArtifact. This reduces external network round trips, minimizes build-time latency, and protects against upstream outages or sudden changes in public repositories.

Why this answer

CodeArtifact can act as a proxy cache for public repositories like npm, PyPI, Maven, and NuGet. By caching dependencies locally, it reduces reliance on external sources, improves build speed by avoiding repeated downloads, and increases reliability by insulating the pipeline from outages or rate limits of public registries.

Exam trap

The trap here is that candidates confuse CodeArtifact with a general-purpose artifact store, but it is strictly a package manager repository for language-specific packages (npm, Maven, PyPI, NuGet), not for Docker images, source code, or static assets.

182
MCQmedium

A company is implementing a CI/CD pipeline using AWS CodePipeline to deploy a serverless application using the AWS Serverless Application Model (SAM). The pipeline must build and package the application, then deploy it to multiple environments (dev, test, prod) sequentially with manual approval gates before production. Which stage configuration should be used?

A.Use a single CloudFormation stack with a change set approval step
B.Use a CodeBuild build stage to run 'sam package' and 'sam deploy' commands, then separate deploy stages for each environment with manual approval actions
C.Configure CodePipeline with a deploy action provider set to AWS CloudFormation
D.Use CodeDeploy to deploy the SAM template directly to Lambda
AnswerB

This design completely addresses the SAM pipeline lifecycle: a CodeBuild stage runs `sam package`, which uploads the function code and dependencies to S3 and writes a packaged template that CloudFormation can parse. Each environment's deploy stage then runs `sam deploy` (or uses the packaged template with CloudFormation) under environment-specific parameters, and a manual approval action preceding each higher environment provides the required release gate. Because every stage is a separate CodePipeline stage, approvals are isolated and promotions are sequential, preventing any single action from accidentally deploying to all environments.

Why this answer

It uses a CodeBuild build stage to run 'sam package' and 'sam deploy' commands, which is the recommended approach for SAM-based deployments. The pipeline then separates deploy stages for each environment (dev, test, prod) with manual approval actions before production, satisfying the sequential deployment and manual gate requirements.

Exam trap

The trap here is that candidates often assume the AWS CloudFormation deploy action provider can handle SAM templates directly, but it cannot because SAM templates require the 'sam package' command to transform and upload artifacts before deployment.

How to eliminate wrong answers

Option A is wrong because a single CloudFormation stack cannot deploy to multiple environments sequentially with manual approval gates; it would deploy to one environment only and lacks the multi-environment orchestration. Option C is wrong because the AWS CloudFormation deploy action provider in CodePipeline does not natively support SAM templates; it requires the template to be pre-packaged and uploaded to S3, and it cannot run 'sam package' or 'sam deploy' commands, which are essential for SAM transformations. Option D is wrong because CodeDeploy is designed for deploying applications to EC2, on-premises, or Lambda functions directly, but it cannot handle SAM template packaging, transformation, or multi-environment sequential deployment with manual approval gates.

183
MCQeasy

A DevOps engineer is setting up an AWS CodePipeline to deploy a web application to an EC2 instance using AWS CodeDeploy. The deployment group uses an in-place deployment configuration. The pipeline's deploy stage fails with the error: 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available, or some instances in your deployment group are experiencing problems.' The engineer checks the CodeDeploy logs on the instance and finds that the 'BeforeInstall' lifecycle hook script is failing. The script attempts to download a package from an Amazon S3 bucket that is encrypted with SSE-KMS. What is the MOST likely cause of the failure?

A.The EC2 instance does not have internet access to reach the S3 bucket.
B.The S3 bucket name is misspelled in the 'BeforeInstall' script.
C.The IAM role attached to the EC2 instance lacks the 'kms:Decrypt' permission for the AWS KMS key used to encrypt the S3 object.
D.The CodeDeploy agent does not have permissions to read from the S3 bucket.
AnswerC

In CodeDeploy, lifecycle hook scripts (such as BeforeInstall) run on the target instance and use the instance's IAM role, not the CodeDeploy service role. If the S3 object is encrypted with an AWS KMS customer-managed key, the script's `aws s3 cp` or `aws s3api get-object` call requires both s3:GetObject on the bucket/object and kms:Decrypt permission for that key. Even if s3:GetObject is allowed, lacking kms:Decrypt causes the S3 client to fail with an AccessDeniedException when it attempts to retrieve the plaintext, making the lifecycle hook exit non-zero and the deployment fail. This is the exact scenario that produces a script failure pointing to encryption authorization.

Why this answer

The error occurs because the EC2 instance's IAM role lacks the `kms:Decrypt` permission for the AWS KMS key used to encrypt the S3 object. When the `BeforeInstall` script attempts to download the package, the AWS SDK or CLI on the instance must decrypt the object using the KMS key. Without this permission, the download fails, causing the lifecycle hook to fail and the overall deployment to abort due to too many failed instances.

Exam trap

The trap here is that candidates often assume the CodeDeploy agent handles all S3 access, but the script runs under the instance's IAM role, and missing KMS permissions are a common oversight when using encrypted artifacts.

How to eliminate wrong answers

Option A is wrong because the EC2 instance can access S3 via a VPC endpoint or NAT gateway without requiring internet access; the error is specifically about decryption, not network connectivity. Option B is wrong because a misspelled bucket name would cause a 'NoSuchBucket' error, not a KMS-related decryption failure. Option D is wrong because the CodeDeploy agent itself does not directly read from S3; the script runs under the instance's IAM role, and the agent's permissions are separate from the script's S3 access.

184
MCQmedium

A DevOps team is implementing a CI/CD pipeline using AWS CodePipeline. The pipeline has a Source stage using CodeCommit, a Build stage using CodeBuild, and a Deploy stage using CloudFormation. The team wants to add manual approval before the Deploy stage for production deployments. How should this be configured?

A.Configure a CloudWatch event to send an email on build success.
B.Use a Lambda function to approve based on build status.
C.Add an Approval stage to the pipeline with SNS topic for notification.
D.Create a separate pipeline for production and trigger it manually.
AnswerC

Adding an Approval stage to the CodePipeline with an SNS topic is the correct approach because the approval action pauses all subsequent stage transitions until a designated reviewer clicks Approve (or Reject) in the console or invokes PutApprovalResult. The SNS topic sends email or other notifications to the approver, and the pipeline resumes only after the approval token is returned. This provides a auditable, controlled human decision point that is natively supported by CodePipeline.

Why this answer

AWS CodePipeline natively supports Approval stages that can be configured to pause the pipeline and send a notification via an SNS topic. The SNS topic can be subscribed to by email, SMS, or other endpoints, allowing a manual approver to review the build output and then approve or reject the transition to the Deploy stage. This directly meets the requirement for a manual approval gate before production deployment without custom code or separate pipelines.

Exam trap

The trap here is that candidates often confuse automated notifications (like CloudWatch events or Lambda triggers) with the manual approval action, failing to recognize that CodePipeline's built-in Approval stage is the only native way to pause the pipeline for human intervention before deployment.

How to eliminate wrong answers

Option A is wrong because a CloudWatch event on build success does not provide a manual approval mechanism; it only triggers an automated action or notification, not a pause-and-approve workflow. Option B is wrong because using a Lambda function to approve based on build status would be an automated approval, not a manual one, and it bypasses the human review required for production deployments. Option D is wrong because creating a separate pipeline for production and triggering it manually does not integrate a manual approval stage within the same pipeline; it adds operational overhead and does not leverage CodePipeline's built-in approval action.

185
MCQhard

A DevOps engineer is designing a CI/CD pipeline using AWS CodePipeline. The source stage is AWS CodeCommit, and the build stage uses AWS CodeBuild. The pipeline must only trigger on changes to the main branch. However, the engineer notices that the pipeline is also triggering on changes to feature branches that are merged via pull requests. What configuration change should the engineer make to ensure the pipeline only triggers on direct commits to the main branch?

A.Configure the CodeCommit repository to disable events for all branches except main.
B.Add a branch filter in the CloudWatch Events rule that triggers the pipeline, specifying only the main branch.
C.Modify the pipeline's source stage to use a branch name filter, which will ignore events from other branches.
D.Use a Lambda function as a source action to check the branch before starting the build.
AnswerB

By adding a branchName filter to the event pattern of the CloudWatch Events (EventBridge) rule that invokes the pipeline, the rule only triggers when a push occurs on the main branch. This is the documented and precise way to restrict executions by branch while still capturing all relevant repository state changes. The filter is evaluated in the event pattern, so other branches don't initiate a pipeline run.

Why this answer

AWS CodePipeline pipelines are triggered by CloudWatch Events rules that monitor CodeCommit repository events. By default, the rule may trigger on all branch changes. Adding a branch filter in the CloudWatch Events rule that specifies only the main branch ensures that only direct commits to main trigger the pipeline, ignoring feature branch merges.

Exam trap

The trap here is that candidates often confuse the pipeline source stage branch filter (which only affects which branch is used as source code) with the CloudWatch Events rule branch filter (which controls which events actually trigger the pipeline), leading them to incorrectly select option C.

Why the other options are wrong

A

CodeCommit does not have a per-branch event setting; events are emitted for all branches.

C

The branch name in the source action only defines which branch to pull; the trigger event still comes from any branch unless filtered at the event rule.

D

This is a workaround but not the standard or efficient solution; the event rule filter is simpler.

186
Drag & Dropmedium

Drag and drop the steps to configure an AWS Elastic Load Balancer (ALB) with HTTPS listeners and target groups.

Drag or tap steps into the slots.

Steps
Order
1Step 1
2Step 2
3Step 3
4Step 4

Why this order

First create the target group, then create the ALB, then configure HTTPS listener, then register targets, then add redirect rule.

187
Multi-Selectmedium

An IAM policy is attached to a service role used by AWS CodePipeline. Which TWO statements about this policy are correct?

Select 2 answers
A.The policy allows updating the pipeline definition
B.The policy allows starting any CodeBuild project
C.The policy allows starting a pipeline execution
D.The policy allows reporting job success or failure to CodePipeline
E.The policy allows reading and writing objects to any S3 bucket
AnswersC, D

The policy grants 'codepipeline:StartPipelineExecution' with a Resource element of '*', so the service role can trigger a new execution for any pipeline in the AWS account, not just a single named pipeline. In IAM, an action with Resource '*' matches all ARNs for that service; thus, the permission is not scoped to a specific pipeline. This statement is correct because the action is explicitly allowed and the resource constraint is unlimited.

Why this answer

The IAM policy attached to a CodePipeline service role must include permissions to allow the pipeline to start executions. The `codepipeline:StartPipelineExecution` action is required for the pipeline to be triggered by events or manual starts. Without this permission, the pipeline cannot initiate its execution flow.

Exam trap

The trap here is that candidates often confuse the permissions needed for the service role (runtime actions like starting executions and reporting status) with permissions for managing the pipeline (like updating the pipeline definition), leading them to select administrative actions instead of execution-specific ones.

188
MCQeasy

A team wants to automatically deploy a new version of a Lambda function when code is pushed to a CodeCommit repository. Which AWS service should orchestrate this workflow?

A.AWS CodeDeploy
B.AWS CodeBuild
C.AWS CodePipeline
D.AWS CloudFormation
AnswerC

AWS CodePipeline is the correct choice because it is a fully managed continuous delivery service that orchestrates the entire release process, from source code changes to production deployment. It can automatically detect new commits in a repository (e.g., GitHub, CodeCommit, S3) and then trigger a series of sequential or parallel stages, such as build with CodeBuild, test, and deploy via CodeDeploy or a direct Lambda update. By modeling the Lambda deployment as a pipeline action, CodePipeline ensures that each new version is built, tested, and deployed automatically and consistently, with the ability to add manual approvals or rollback steps.

Why this answer

AWS CodePipeline is the correct service because it is a fully managed continuous delivery service that orchestrates the entire release process, including source code changes from CodeCommit, building with CodeBuild, and deploying to Lambda. It can automatically trigger a pipeline execution when a new commit is pushed to a CodeCommit repository, enabling automated deployment of the Lambda function.

Exam trap

The trap here is that candidates often confuse CodeDeploy as the orchestrator because it handles the deployment step, but CodePipeline is the service that orchestrates the entire end-to-end workflow from source to deployment.

How to eliminate wrong answers

Option A is wrong because AWS CodeDeploy is a deployment service that automates application deployments to compute services like EC2, Lambda, or on-premises instances, but it does not orchestrate the entire workflow or detect source code changes in CodeCommit. Option B is wrong because AWS CodeBuild is a fully managed build service that compiles source code, runs tests, and produces artifacts, but it cannot orchestrate the multi-stage workflow or trigger deployments on its own. Option D is wrong because AWS CloudFormation is an infrastructure-as-code service for provisioning and managing AWS resources, but it is not designed to orchestrate continuous delivery pipelines triggered by code repository events.

189
MCQhard

A company deploys a serverless application using AWS SAM. The application includes an API Gateway REST API and multiple Lambda functions. The team wants to implement canary deployments for the API to gradually shift traffic to a new version. Which SAM template configuration should be used?

A.Use the CanaryDeployment property on the Serverless::Function resource with a DeploymentPreference
B.Create multiple Lambda function versions and use API Gateway stage variables to switch between them
C.Define the Lambda function with AutoPublishAlias: live and set the API Gateway integration to point to the alias
D.Use AWS CloudFormation's UpdatePolicy with AutoScalingRollingUpdate
AnswerA

The SAM CanaryDeployment property, when paired with a DeploymentPreference such as 'Canary10Percent5Minutes', delegates to AWS CodeDeploy to manage a gradual traffic shift. CodeDeploy publishes a new Lambda version, then adjusts the alias's routing configuration to send only 10% of live invocations to the new version for a 5-minute observation period, and finally shifts the remaining 90% after the interval succeeds. It also supports CloudWatch alarm-based automatic rollback, making it the only option here that provides a managed, gradual, and rollback-capable canary release on Lambda.

Why this answer

AWS SAM's `CanaryDeployment` property on the `AWS::Serverless::Function` resource, combined with a `DeploymentPreference` of type `Canary10Percent5Minutes`, enables gradual traffic shifting for API Gateway integrations. This configuration automatically creates a Lambda alias, publishes new versions, and shifts a percentage of API traffic to the new version over a specified time window, all without manual intervention.

Exam trap

The trap here is that candidates often confuse `AutoPublishAlias` with canary deployments, assuming that publishing a new version and pointing an alias to it automatically shifts traffic gradually, when in fact it requires an explicit `DeploymentPreference` with a canary type to enable traffic shifting.

How to eliminate wrong answers

Option B is wrong because manually creating multiple Lambda function versions and using API Gateway stage variables to switch between them is a manual, error-prone approach that does not provide automated canary traffic shifting or rollback capabilities. Option C is wrong because while `AutoPublishAlias: live` creates a Lambda alias and publishes new versions, it does not by itself implement canary deployments; it only points the API Gateway integration to a single alias, requiring additional custom logic for traffic shifting. Option D is wrong because `AWS CloudFormation's UpdatePolicy with AutoScalingRollingUpdate` is designed for Auto Scaling groups or EC2-based rolling updates, not for serverless resources like Lambda functions or API Gateway, and it does not support canary traffic shifting for API endpoints.

190
Multi-Selecteasy

Which TWO AWS services can be used as source actions in AWS CodePipeline to automatically trigger a pipeline when changes are made? (Choose two.)

Select 2 answers
A.Amazon CloudWatch
B.Amazon S3
C.Amazon EC2
D.AWS CloudFormation
E.AWS CodeCommit
AnswersB, E

Amazon S3 is a supported CodePipeline Source action that detects new uploads when versioning is enabled, either through CloudWatch Events or periodic polling. When a new object version is written to the designated bucket and key, CodePipeline starts a pipeline execution and downloads that object as the input artifact for downstream stages. This makes S3 a common choice for external tooling or third-party providers to drop build artifacts.

Why this answer

Amazon S3 is a valid source action in AWS CodePipeline because you can configure a pipeline to start when a new object is created or an existing object is updated in an S3 bucket. This is achieved by enabling Amazon S3 event notifications (via Amazon S3 Event Notifications) that send events to Amazon CloudWatch Events or directly to AWS CodePipeline using a CloudWatch Events rule, which then triggers the pipeline execution. This allows automatic pipeline runs on code or artifact changes stored in S3.

Exam trap

The trap here is that candidates often confuse Amazon CloudWatch (a monitoring service) with Amazon EventBridge (the event bus service that actually triggers pipelines), or they think EC2 can be a source because it can run scripts that poll for changes, but CodePipeline source actions require native event-driven integration, not custom polling.

191
MCQhard

Refer to the exhibit. A DevOps engineer created this IAM policy for a CodeDeploy service role. The deployment fails with an 'AccessDenied' error when attempting to register instances with an Auto Scaling group. What is the likely cause?

A.The policy does not allow autoscaling:CompleteLifecycleAction.
B.The role is not trusted by the EC2 service.
C.The iam:PassRole action is not scoped to the correct resource.
D.The policy is missing autoscaling:UpdateAutoScalingGroup and autoscaling:SetDesiredCapacity.
AnswerD

For a deployment to an Auto Scaling group, CodeDeploy must be able to adjust the group's desired capacity and update its configuration. autoscaling:UpdateAutoScalingGroup lets CodeDeploy modify min/max/desired values, while autoscaling:SetDesiredCapacity forces the group to scale to the exact instance count required for the deployment. Without these permissions, CodeDeploy cannot perform instance replacement or blue/green transitions, causing the deployment to fail.

Why this answer

The CodeDeploy service role must include permissions for autoscaling:UpdateAutoScalingGroup and autoscaling:SetDesiredCapacity to allow CodeDeploy to register instances with an Auto Scaling group during a deployment. Without these actions, the deployment fails with an 'AccessDenied' error when CodeDeploy attempts to attach instances to the Auto Scaling group or adjust its capacity.

Exam trap

The trap here is that candidates often assume the error is due to missing lifecycle hook permissions (Option A) or a trust relationship issue (Option B), but the actual cause is the lack of specific Auto Scaling write permissions required for instance registration.

How to eliminate wrong answers

Option A is wrong because autoscaling:CompleteLifecycleAction is used for lifecycle hooks, not for registering instances with an Auto Scaling group, and its absence would not cause the described error. Option B is wrong because the role is trusted by CodeDeploy (not EC2), and the error occurs during instance registration with Auto Scaling, not during EC2 instance launch. Option C is wrong because iam:PassRole is used to pass a role to a service, but the error is about Auto Scaling actions, not about passing roles; the policy likely already allows PassRole for the correct resource.

192
MCQeasy

A team uses AWS CodeBuild to build Docker images and push them to Amazon ECR. The buildspec.yml includes a post_build step that runs a security scan. The team wants to ensure that only images that pass the security scan are tagged as 'latest'. Which approach should be used?

A.Build the image with the 'latest' tag first, then run the security scan. If it fails, delete the 'latest' tag.
B.In the post_build phase, run the security scan, and if it passes, tag the image with 'latest' and push.
C.Use ECR lifecycle policies to remove images that do not pass the security scan.
D.Tag the image with 'latest' only after the build phase, regardless of scan results.
AnswerB

This is the correct approach because it guarantees the 'latest' tag is only ever applied to an image that has successfully passed the defined security gate. In the post_build phase of CodeBuild, you can run a local container scanner (e.g., Trivy, Snyk, or Anchore) and only when the exit code indicates a pass do you execute `docker tag` to relabel the built image as `latest` followed by `docker push`. This ensures the 'latest' tag remains immutable and clean, with no vulnerable image ever being exposed under that tag during the build or scan window.

Why this answer

It ensures that only images passing the security scan receive the 'latest' tag. By running the scan in the post_build phase and conditionally tagging only on success, the team avoids ever pushing a vulnerable image with the 'latest' tag. This approach follows the principle of atomic tagging, where the tag is applied only after all validation steps pass.

Exam trap

The trap here is that candidates may think deleting a tag after a failure is sufficient, but they overlook the race condition where the 'latest' tag is already published and could be consumed before deletion.

How to eliminate wrong answers

Option A is wrong because building the image with the 'latest' tag first and then deleting it on failure is not atomic; there is a window where the vulnerable image is already tagged and potentially pulled by consumers. Option C is wrong because ECR lifecycle policies are designed to automatically expire old or unused images based on age or count, not to react to security scan results in real time. Option D is wrong because tagging with 'latest' regardless of scan results defeats the purpose of the security gate, allowing vulnerable images to be promoted.

193
MCQeasy

A DevOps team is implementing infrastructure as code using AWS CloudFormation. They want to ensure that stack updates are reviewed and approved before execution. Which feature should they use?

A.Drift detection
B.Stack policies
C.StackSets
D.Change Sets
AnswerD

Change Sets in AWS CloudFormation generate a read-only summary of the exact resource-level actions (Update, Add, Remove) that would result from submitting a new template or parameters. They act as a dry-run, allowing the team to inspect the proposed modifications, identify resources that will be replaced, and evaluate potential downtime before executing the stack update. This review-and-approve capability makes Change Sets the ideal tool for implementing infrastructure as code with controlled change management.

Why this answer

Change Sets allow you to preview the proposed changes to a CloudFormation stack before executing them. This enables the DevOps team to review and approve modifications, ensuring that only validated updates are applied. By creating a change set, you can see exactly which resources will be added, modified, or deleted, and then decide whether to execute it.

Exam trap

The trap here is that candidates confuse stack policies (which control update permissions) with change sets (which provide a preview and approval workflow), leading them to select stack policies as the mechanism for review and approval.

How to eliminate wrong answers

Option A is wrong because drift detection identifies whether a stack's actual state differs from its template, but it does not provide a mechanism to review or approve updates before execution. Option B is wrong because stack policies define which resources can be updated or replaced during a stack update, but they do not offer a review-and-approve workflow for changes. Option C is wrong because StackSets enable you to create, update, or delete stacks across multiple accounts and regions, but they do not provide a per-update review and approval process.

194
Multi-Selecteasy

Which TWO criteria must be met for an AWS CloudFormation stack update to be successful? (Choose 2.)

Select 2 answers
A.The update template must be valid and must not contain any syntax errors.
B.The stack must be in a steady state with no previous failed updates.
C.The stack must be in a state that allows updates (e.g., CREATE_COMPLETE, UPDATE_COMPLETE).
D.A change set must be created and executed before the update.
E.The stack must have no drift detected.
AnswersA, C

CloudFormation performs template validation before any update action is taken, checking for well-formed JSON/YAML, resolving intrinsic functions, validating resource types and required properties. An invalid template will cause the UpdateStack API call to fail immediately with a ValidationError, leaving the stack's current status unchanged. This is a hard precondition that every direct update must satisfy.

Why this answer

AWS CloudFormation validates the template syntax and structure before initiating any stack update. If the template contains invalid JSON or YAML, references nonexistent resources, or violates intrinsic function rules, the update request is rejected immediately. This validation ensures that only syntactically correct templates proceed to the update operation.

Exam trap

The trap here is that candidates confuse 'stack must be in a steady state' (a common misconception) with the actual requirement that the stack must be in a state that allows updates, such as CREATE_COMPLETE or UPDATE_COMPLETE, not necessarily without any prior failures.

195
Multi-Selectmedium

A DevOps team is implementing a CI/CD pipeline for a microservices architecture. Each microservice is built and deployed independently. The team wants to ensure that only one build runs per microservice at a time to avoid resource contention, and that the build artifacts are stored securely. Which THREE steps should the team take?

Select 3 answers
A.Store build artifacts in AWS CodeArtifact
B.Enable versioning on the S3 bucket storing build artifacts
C.Configure a concurrency limit in the CodeBuild project for each microservice
D.Create a separate CodePipeline for each microservice
E.Enable server-side encryption on the S3 bucket storing build artifacts
AnswersB, C, E

Enabling S3 bucket versioning on the bucket that stores CodePipeline build artifacts preserves every object version, including each build output. When a deployment needs to roll back, you can retrieve a previous artifact version directly from S3 or point the pipeline stage to that exact version. Versioning is a prerequisite for using S3 as CodePipeline's default artifact store in a way that supports safe, reproducible rollbacks without losing prior builds.

Why this answer

Option B is correct because enabling versioning on the S3 bucket preserves every revision of the build artifacts, allowing recovery of previous versions and protecting against accidental overwrites or deletions, which supports secure artifact storage. Option C is correct because configuring a concurrency limit in each microservice's CodeBuild project ensures only one build for that microservice runs at a time, directly preventing resource contention as required. Option E is correct because enabling server-side encryption on the S3 bucket encrypts artifacts at rest using AWS-managed or KMS keys, satisfying the requirement to store build artifacts securely.

Option A is not correct because AWS CodeArtifact is a package/dependency repository for artifacts like npm, Maven, and PyPI packages, not the general build-artifact store used by CodePipeline, and the scenario's secure storage requirement is met by S3 with versioning and encryption. Option D is not correct because creating a separate CodePipeline per microservice supports independent deployment but does not by itself enforce one build at a time or secure artifact storage.

Exam trap

The trap here is that candidates often confuse AWS CodeArtifact (for package management) with S3 (for artifact storage), or they assume that creating separate pipelines inherently enforces concurrency limits, when in fact concurrency must be explicitly configured in the CodeBuild project settings.

196
MCQmedium

A development team uses AWS CodeCommit for source control. They want to enforce that all commits include a JIRA issue key in the commit message. What is the MOST efficient way to achieve this?

A.Use Amazon CloudWatch Events to detect new commits and invoke a Lambda function to validate the commit message.
B.Implement a pre-commit hook in each developer's local repository.
C.Configure a branch policy on the repository that requires commit message format.
D.Create a CodeCommit trigger that invokes an AWS Lambda function on every push to validate commit messages.
AnswerD

A CodeCommit trigger can be set up to invoke an AWS Lambda function whenever a push event occurs, and the event payload includes the full commit list with metadata such as the commit message and author. The Lambda function can programmatically validate each commit message against a required format or regex, and then take action such as sending an alert or invoking a rollback if validation fails. This is a serverless, centrally managed approach that runs on every push and cannot be bypassed by developers, making it the correct solution.

Why this answer

CodeCommit triggers can invoke an AWS Lambda function on every push event, allowing real-time validation of commit messages against a required pattern (e.g., JIRA issue key). This serverless approach enforces the policy centrally without relying on client-side configurations, making it the most efficient and reliable method for a team using AWS CodeCommit.

Exam trap

The trap here is that candidates confuse CodeCommit branch policies (which enforce approval workflows and restrict direct pushes) with the ability to validate commit message format, but branch policies do not support message validation—only CodeCommit triggers with Lambda can perform custom validation on commit content.

How to eliminate wrong answers

Option A is wrong because Amazon CloudWatch Events can detect CodeCommit events, but invoking a Lambda function via CloudWatch Events adds unnecessary complexity and latency compared to using a native CodeCommit trigger, which is designed for this exact purpose. Option B is wrong because a pre-commit hook in each developer's local repository is client-side and can be bypassed or not configured by all developers, failing to enforce the policy centrally. Option C is wrong because CodeCommit branch policies can enforce approval rules and restrict direct pushes, but they do not support validating commit message format; that capability is not available in CodeCommit branch policies.

197
Multi-Selecthard

Which TWO actions should a DevOps engineer take to ensure that an AWS CodeBuild project's artifacts are automatically deployed to an Amazon S3 bucket with server-side encryption using AWS KMS? (Choose 2.)

Select 2 answers
A.Enable versioning on the S3 bucket.
B.Configure the S3 bucket policy to require HTTPS for all uploads.
C.In the buildspec.yaml, set the 'artifacts' section to include 'encryptionDisabled: false' and specify the KMS key ID.
D.Enable default encryption on the S3 bucket using SSE-KMS.
E.Grant the CodeBuild service role permission to use the KMS key via the key policy.
AnswersC, E

In the buildspec.yaml, the artifacts section can set 'encryptionDisabled: false' and specify the desired KMS key ID via the 'kmsKeyId' setting (or similarly named property). This explicitly instructs CodeBuild to encrypt the output artifact using the specified customer-managed KMS key, ensuring server-side encryption at rest. This is the direct and reliable way to enforce SSE-KMS for build artifacts.

Why this answer

Setting 'encryptionDisabled: false' in the buildspec.yaml artifacts section explicitly enables encryption for the build output, and specifying the KMS key ID ensures that the artifacts are encrypted with that specific AWS KMS key. This configuration directly instructs CodeBuild to use server-side encryption with AWS KMS when uploading artifacts to S3.

Exam trap

The trap here is that candidates often confuse default bucket encryption (Option D) with explicit artifact encryption in CodeBuild, not realizing that CodeBuild's buildspec encryption settings override bucket defaults and that the service role must have explicit KMS key permissions.

198
Multi-Selecthard

A company uses AWS CloudFormation to deploy a multi-tier application. The stack creation fails with a 'CREATE_FAILED' error for a resource. The engineer wants to troubleshoot the issue. Which TWO steps should the engineer take? (Choose TWO.)

Select 2 answers
A.Use the 'describe-stack-events' AWS CLI command to view the events.
B.Review the CloudWatch Logs log group for the stack to find detailed error logs.
C.Check the 'ResourceStatusReason' field of the failed resource in the stack events.
D.Run 'delete-stack' to remove the failed stack and start over.
E.Use the 'describe-stacks' AWS CLI command to get the stack outputs.
AnswersA, C

The describe-stack-events AWS CLI command is the correct programmatic way to inspect the full event history of a stack, including each resource's CREATE_FAILED event followed by the overall stack rollback event. Each event object contains a ResourceStatusReason property with the detailed error thrown by the failed resource, along with the logical resource ID, physical resource ID, and timestamps. This command is ideal for automation because it returns the exact same failure information you would see in the CloudFormation console, allowing you to log or alert on the root cause.

Why this answer

The 'describe-stack-events' AWS CLI command retrieves all stack events, including the specific event for the failed resource. This event contains the 'ResourceStatusReason' field, which provides the detailed error message from CloudFormation explaining why the resource creation failed. Option C is correct because checking the 'ResourceStatusReason' field in the stack events directly reveals the underlying error.

Option B is incorrect because CloudFormation does not automatically create a CloudWatch Logs log group for stack errors; resource-specific logs are only available if the resource itself writes to CloudWatch. During a stack creation failure, there may be no such logs to review. Option D is incorrect because deleting the stack would lose the event history and prevent effective troubleshooting.

Option E is incorrect because 'describe-stacks' only returns stack outputs and status, not failure details.

Exam trap

The main trap is that candidates may incorrectly think that CloudFormation automatically creates a CloudWatch Logs log group for all stack errors (Option B), or prematurely delete the stack (Option D) instead of investigating the failure using stack events and the ResourceStatusReason field.

199
MCQmedium

A DevOps team uses AWS CodePipeline to deploy a static website to an Amazon S3 bucket. The pipeline has a source stage (CodeCommit), a build stage (CodeBuild that runs a build tool), and a deploy stage (S3). After a recent code change, the build stage succeeded but the deploy stage failed with the error: 'Access Denied' when uploading artifacts to the S3 bucket. What should the team do to fix the issue?

A.Configure the S3 bucket to allow public access
B.Add 's3:PutObject' permission to the CodePipeline service role
C.Add an S3 bucket policy that grants the CodeBuild service role s3:PutObject access
D.Verify that the CodeCommit repository has the correct permissions for the pipeline
AnswerB

The deploy stage of CodePipeline assumes the CodePipeline service role when it interacts with S3, so that role must have an IAM policy allowing s3:PutObject on the target bucket. This permission enables the pipeline to upload the artifact archive and any extracted files to the bucket that hosts the static website. Without it, the deploy action fails with a permissions error even if other roles, such as CodeBuild's, happen to have access to the same bucket.

Why this answer

The deploy stage in CodePipeline uses the CodePipeline service role to upload artifacts to the S3 bucket. The error 'Access Denied' indicates that this role lacks the necessary permissions. Adding 's3:PutObject' to the CodePipeline service role grants it the required write access to the S3 bucket, resolving the issue.

Exam trap

The trap here is confusing the CodeBuild service role with the CodePipeline service role; candidates often mistakenly add permissions to the CodeBuild role instead of the pipeline role, which does not resolve the deploy-stage access denied error.

How to eliminate wrong answers

Option A is wrong because making the S3 bucket publicly accessible would expose the static website to unauthorized write operations and is a security risk; it does not address the pipeline's permission issue. Option C is wrong because the CodeBuild service role is used during the build stage, not the deploy stage; the deploy stage uses the CodePipeline service role to upload artifacts to S3. Option D is wrong because the error occurs during the deploy stage, not the source stage; CodeCommit permissions are irrelevant to the S3 upload failure.

200
MCQeasy

Which AWS service is primarily used to automate the building, testing, and deployment of code changes to AWS infrastructure based on a defined release process?

A.AWS CodeCommit
B.AWS CodePipeline
C.AWS CodeBuild
D.AWS CodeDeploy
AnswerB

AWS CodePipeline is a fully managed continuous delivery service that automates the entire release process, from source through build, test, and deployment. It orchestrates the pipeline by connecting multiple stages, such as pulling code from CodeCommit, invoking CodeBuild, and triggering CodeDeploy, along with integrations for third-party tools like Jenkins or GitHub. This end-to-end automation makes it the central CI/CD service in AWS.

Why this answer

AWS CodePipeline is the correct service because it is a fully managed continuous delivery service that orchestrates the building, testing, and deployment of code changes through a defined release process. It integrates with source control (e.g., CodeCommit, GitHub), build services (e.g., CodeBuild), and deployment services (e.g., CodeDeploy) to automate the entire pipeline from commit to production.

Exam trap

The trap here is that candidates often confuse the individual services (CodeBuild for building, CodeDeploy for deploying) with the orchestrator (CodePipeline) that ties them together, leading them to select a service that performs only one part of the process rather than the full automation of the release process.

Why the other options are wrong

A

CodeCommit is a source control service, not a CI/CD pipeline orchestrator.

C

CodeBuild is a build service that compiles source code and runs tests, but it does not orchestrate the entire release process.

D

CodeDeploy automates code deployment to compute services, but it is not a full pipeline orchestrator.

201
MCQhard

A DevOps engineer is using AWS CodePipeline to deploy a containerized application to Amazon ECS. The pipeline has a source stage (Amazon ECR), a build stage (AWS CodeBuild), and a deploy stage (Amazon ECS). The engineer wants to implement blue/green deployments with automatic rollback if the new version fails health checks. Which configuration should the engineer use to achieve this?

A.Configure the ECS deploy action to use the 'CODE_DEPLOY' deployment controller and specify a CodeDeploy application and deployment group with blue/green configuration.
B.Configure the build stage to create a new ECS task definition and update the service with a new target group, and use AWS Lambda to shift traffic and roll back on failure.
C.Use the 'ECS' deployment controller and configure the ECS service to use a rolling update deployment type with a minimum healthy percent of 100.
D.Add a manual approval action before the deploy stage and configure the ECS service to use the 'EXTERNAL' deployment controller.
AnswerA

AWS CodePipeline integrates with AWS CodeDeploy to provide blue/green deployments for ECS. By setting the ECS deploy action to use the 'CODE_DEPLOY' deployment controller, you can specify a CodeDeploy application and deployment group configured for blue/green. CodeDeploy manages the traffic shift and can automatically roll back if health checks fail. This is the standard way to achieve blue/green with automatic rollback in CodePipeline.

Why this answer

To implement blue/green deployments for ECS with automatic rollback, the engineer should use AWS CodeDeploy as the deployment controller. In CodePipeline, the ECS deploy action can be configured to use CodeDeploy, specifying a CodeDeploy application and deployment group set up for blue/green. CodeDeploy handles the creation of a new task set, traffic shifting, and automatic rollback based on health checks.

This is the native AWS solution, providing reliability and minimal operational overhead. The other options either use rolling updates, require custom automation, or do not provide blue/green capabilities.

Exam trap

The trap here is assuming that ECS rolling updates or custom Lambda-based traffic shifting can provide blue/green with automatic rollback, when the managed solution requires CodeDeploy with the CODE_DEPLOY controller.

202
MCQeasy

A team wants to automate the deployment of a serverless application using AWS SAM. They have a template.yaml file defining Lambda functions, an API Gateway, and a DynamoDB table. Which command should they use to build and deploy the application?

A.aws cloudformation deploy --template-file template.yaml
B.sam package --output-template-file packaged.yaml
C.sam build && sam deploy
D.sam deploy --guided
AnswerC

This is the correct non-interactive deployment sequence for an AWS SAM application in an automated pipeline. `sam build` prepares the application by installing dependencies, compiling code, and creating the deployment artifacts required for Lambda functions and layers. `sam deploy` then packages these artifacts, uploads them to S3, and uses AWS CloudFormation to create or update the stack, all without requiring manual intervention.

Why this answer

The correct command sequence is `sam build && sam deploy` because AWS SAM requires the `sam build` command to transform the SAM template into an AWS CloudFormation template with the necessary artifact packaging, and then `sam deploy` to create or update the stack. Option C is the only choice that performs both the build (which resolves local dependencies and prepares deployment artifacts) and the deployment step, which is essential for a serverless application defined in a SAM template.

Exam trap

The trap here is that candidates often confuse `sam deploy` with `aws cloudformation deploy` or assume `sam deploy --guided` can handle the entire workflow without a separate build step, not realizing that `sam build` is mandatory to transform SAM-specific resources into standard CloudFormation resources and to prepare deployment artifacts.

How to eliminate wrong answers

Option A is wrong because `aws cloudformation deploy --template-file template.yaml` directly uses the raw SAM template, which AWS CloudFormation cannot process without first being transformed by `sam build` or `sam package`; it would fail due to unsupported SAM-specific resources like `AWS::Serverless::Function`. Option B is wrong because `sam package` only uploads artifacts to S3 and generates a packaged template, but it does not deploy the stack; it must be followed by a deploy command. Option D is wrong because `sam deploy --guided` is an interactive mode that prompts for parameters and configuration but still requires the template to be built first (i.e., `sam build` must run before `sam deploy --guided`); running it alone without a prior build will fail.

203
MCQhard

A DevOps engineer runs the above AWS CLI commands and notices that the CodeBuild project 'my-project' exists but builds fail with the error 'Access Denied' when trying to fetch source code from CodeCommit. The IAM role 'CodeBuildServiceRole' has a policy that allows 'codecommit:GitPull' on all repositories. What is the most likely cause of the failure?

A.The IAM role does not have permissions to access the CodeCommit repository.
B.The IAM role does not have a trust policy that allows CodeBuild to assume the role.
C.The CodeCommit repository does not exist.
D.The source location in the build project is incorrect.
AnswerB

CodeBuild first calls sts:AssumeRole to obtain temporary credentials for the service role, and this requires the role's trust policy to include codebuild.amazonaws.com as a trusted service principal. The permissions policy may be correct, but if the trust policy is missing or misconfigured, CodeBuild is not authorized to assume the role and the build fails before any repository action occurs. This is the classic cause when CLI output verifies the repository and the permissions policy, yet the build cannot start.

Why this answer

The error 'Access Denied' when CodeBuild tries to fetch source code from CodeCommit typically indicates that the IAM role CodeBuild is using does not have the necessary permissions to perform the action. Even though the role 'CodeBuildServiceRole' has a policy allowing 'codecommit:GitPull', the role itself must have a trust policy that allows the CodeBuild service to assume it. Without a proper trust policy, CodeBuild cannot assume the role, and any attached permissions are irrelevant, leading to an access denied error.

Exam trap

The trap here is that candidates often focus on the IAM policy permissions (e.g., 'codecommit:GitPull') and overlook the necessity of a trust policy, assuming that if the policy allows the action, the role is automatically usable by the service.

How to eliminate wrong answers

Option A is wrong because the IAM role does have a policy that allows 'codecommit:GitPull' on all repositories, so the permissions are present; the issue is that the role cannot be assumed. Option C is wrong because the problem states the CodeBuild project 'my-project' exists and the error occurs when fetching source code, implying the repository exists; if it didn't, the error would be 'RepositoryNotFound' or similar. Option D is wrong because an incorrect source location would typically result in a 'RepositoryNotFound' or 'InvalidSourceLocation' error, not an 'Access Denied' error.

204
Multi-Selecthard

A DevOps engineer is designing a deployment pipeline for a serverless application using AWS SAM. The pipeline must include the following stages: source, build, deploy to a development environment, run integration tests, and promote to production after manual approval. Which AWS services and features should be used to implement this pipeline? (Choose two.)

Select 2 answers
A.AWS CodeDeploy for deploying the SAM application.
B.AWS CodePipeline to orchestrate the pipeline stages.
C.AWS CodeCommit to build the SAM application.
D.AWS CodeBuild to run the SAM build, package, and test commands.
AnswersB, D

AWS CodePipeline is the fully managed continuous delivery service that models the entire release process as sequential stages (source, build, deploy) and manages transitions, artifacts, and approvals. For a SAM application, CodePipeline pulls source from a repository, invokes CodeBuild to run SAM CLI commands, and triggers a CloudFormation deployment through a deploy action. Its stage-based orchestration is exactly what the question's 'pipeline stages' refers to, making it the correct service to orchestrate the pipeline.

Why this answer

AWS CodePipeline is the correct service for orchestrating the pipeline stages because it provides native support for defining source, build, deploy, test, and manual approval stages in a sequential workflow. It integrates directly with AWS SAM and can trigger builds and deployments based on source code changes, making it the ideal orchestrator for this multi-stage pipeline.

Exam trap

The trap here is that candidates often confuse AWS CodeDeploy with the deployment mechanism for SAM applications, not realizing that SAM deployments are actually handled through AWS CloudFormation (via CodeBuild or CodePipeline), not CodeDeploy directly.

Why the other options are wrong

A

SAM applications are deployed via CloudFormation, not CodeDeploy.

C

CodeCommit is a source control service, not a build service.

205
MCQeasy

A development team uses AWS CodeCommit to store source code and AWS CodePipeline to automate builds and deployments. The team wants to ensure that every commit to the main branch triggers a build and deployment to a test environment. Which action should be taken?

A.Create a CodeBuild project that watches the main branch and starts a pipeline.
B.Use AWS Lambda to poll the repository and start the pipeline on new commits.
C.Set up an Amazon CloudWatch Events rule that matches commits to the main branch and targets the CodePipeline.
D.Configure the source stage of the CodePipeline to use the CodeCommit repository and specify the main branch.
AnswerD

In CodePipeline, a source stage with a CodeCommit action automatically subscribes to repository events on the specified branch (e.g., main) and triggers a new pipeline execution whenever a commit is pushed. This is the standard, fully managed integration: CodePipeline creates the necessary event rule to detect the branch update and passes the commit ID and repository name as inputs to subsequent stages. By specifying the branch in the action configuration, you also get filtering on that branch only, making this the simplest and most reliable way to achieve continuous delivery from CodeCommit.

Why this answer

CodePipeline natively integrates with CodeCommit as a source action. By configuring the source stage to use the CodeCommit repository and specifying the main branch, the pipeline automatically triggers on every commit to that branch without any additional infrastructure or polling. This is the simplest and most reliable approach, as CodePipeline uses Amazon CloudWatch Events under the hood to detect changes.

Exam trap

The trap here is that candidates may overthink the solution and choose a more complex option (like Lambda polling or manual CloudWatch Events rules) instead of recognizing that CodePipeline's native source configuration already handles event-driven triggers automatically.

How to eliminate wrong answers

Option A is wrong because CodeBuild does not have a built-in 'watch' feature for branches; it can only be triggered by events or manual invocation, and creating a CodeBuild project to watch a branch would require custom polling logic, which is unnecessary. Option B is wrong because using Lambda to poll the repository is an anti-pattern; it introduces latency, cost, and complexity, whereas CodePipeline already provides event-driven triggers via CloudWatch Events. Option C is wrong because while a CloudWatch Events rule can trigger a pipeline, it is redundant and less direct; CodePipeline automatically creates the necessary CloudWatch Events rule when you configure the source stage with CodeCommit, so manually creating one is unnecessary and can lead to duplicate triggers or misconfiguration.

206
MCQeasy

A developer wants to automatically deploy a new version of an AWS Lambda function whenever code is pushed to a specific branch in AWS CodeCommit. Which combination of services should be used?

A.AWS CodeCommit, Amazon EventBridge, AWS CodePipeline
B.AWS CodeCommit, Amazon S3, AWS Lambda
C.AWS CodeCommit, AWS CodeBuild
D.AWS CodeCommit, Amazon CloudWatch Logs
AnswerA

CodeCommit pushes are natively captured as events by Amazon EventBridge, which can be configured with a rule that matches the `codecommit:Push` event on a branch. That rule targets an AWS CodePipeline execution, and CodePipeline's deploy stage updates the Lambda function using either a CloudFormation stack or an AWS Lambda deploy action. This gives a fully managed, event-driven CI/CD workflow with no custom glue code, no polling, and no intermediate storage.

Why this answer

AWS CodePipeline can be configured with a source stage that uses AWS CodeCommit as the source provider, and an Amazon EventBridge rule can detect push events to a specific branch in CodeCommit. When a push occurs, EventBridge triggers the pipeline execution, which then deploys the new Lambda function version automatically. This combination provides a fully managed, event-driven CI/CD pipeline for Lambda deployments.

Exam trap

The trap here is that candidates may think a direct Lambda trigger from CodeCommit (via S3 or CloudWatch Logs) is sufficient, but they overlook the need for a pipeline service like CodePipeline to manage the deployment workflow and handle versioning, rollbacks, and approvals.

How to eliminate wrong answers

Option B is wrong because Amazon S3 is not a direct trigger for Lambda deployments from CodeCommit; while S3 can invoke Lambda, it does not provide the orchestrated pipeline needed to deploy a new Lambda version from a CodeCommit branch push. Option C is wrong because AWS CodeBuild alone can build and test code, but it cannot automatically deploy a new Lambda version without a pipeline service like CodePipeline to orchestrate the deployment stage. Option D is wrong because Amazon CloudWatch Logs is used for monitoring and logging, not for triggering or orchestrating deployments from CodeCommit pushes.

207
MCQhard

A company uses AWS CodePipeline with a GitHub source action. They want to automatically start the pipeline when a pull request is merged to the main branch. However, the pipeline also starts on every push to any branch. How can they limit the pipeline to only trigger on push events to the main branch?

A.Use a Lambda function as a source action instead of GitHub.
B.Create a GitHub webhook manually and point it to a Lambda function that starts the pipeline only for main branch pushes.
C.Configure the source action's 'Branch' field to 'main' and set 'PollForSourceChanges' to false, and use a webhook with filters.
D.Add a condition in the pipeline's first stage to check the branch name.
AnswerC

This is the correct approach. Setting the source action's Branch field to 'main' and disabling PollForSourceChanges ensures that the pipeline uses the CodePipeline-managed GitHub webhook instead of legacy polling, preventing duplicate executions. The webhook is configured with event filters that only forward push events for refs/heads/main, so the pipeline starts only when the default/main branch is updated. This gives you native, real-time triggering without custom code and without starting pipelines for other branches.

Why this answer

It configures the source action to only respond to push events on the main branch by setting the 'Branch' field to 'main' and disabling polling ('PollForSourceChanges': false), while using a webhook with branch filters. This ensures that only pushes to the main branch trigger the pipeline, not pushes to any other branch.

Exam trap

The trap here is that candidates often think branch filtering must be done inside the pipeline stages (Option D) or via a custom Lambda (Options A and B), overlooking CodePipeline's native webhook branch filter configuration that prevents the pipeline from even starting on non-matching branches.

How to eliminate wrong answers

Option A is wrong because replacing the GitHub source action with a Lambda function adds unnecessary complexity and does not inherently solve the branch filtering issue; the Lambda would still need to implement branch filtering logic. Option B is wrong because manually creating a GitHub webhook to a Lambda function is an overengineered approach that bypasses CodePipeline's native webhook integration, which already supports branch filtering. Option D is wrong because adding a condition in the pipeline's first stage to check the branch name would still cause the pipeline to start on every push, wasting resources and potentially failing the stage, rather than preventing the trigger entirely.

208
MCQmedium

Refer to the exhibit. A team uses this buildspec.yml file in AWS CodeBuild. After the build, they expect the artifacts to be placed in a folder structure, but all files are in the root of the output artifact. What is the reason?

A.The 'files' section only includes '**/*' which does not preserve paths.
B.The 'discard-paths' option is set to 'yes', which flattens the directory structure.
C.The 'base-directory' is not specified, so CodeBuild uses the root of the build output.
D.The 'name' property is missing, causing artifacts to be stored without structure.
AnswerB

In CodeBuild buildspec artifacts, setting discard-paths to 'yes' explicitly instructs CodeBuild to strip all directory information from the matched files. As a result, every file selected by the files glob is placed directly into the artifact root, losing any subdirectory hierarchy. This is the exact mechanism responsible for the observed flat output structure.

Why this answer

The `discard-paths` option in the `artifacts` section of a buildspec.yml file, when set to `yes`, explicitly flattens the directory structure. This means that even if the `files` glob pattern `**/*` matches files in subdirectories, they are all placed at the root of the output artifact, discarding their original relative paths. Without this setting (or when set to `no`), the directory hierarchy would be preserved.

Exam trap

The trap here is that candidates often assume the `files` glob pattern `**/*` automatically flattens the structure, but in CodeBuild, path flattening is controlled solely by the `discard-paths` boolean, not by the glob syntax itself.

How to eliminate wrong answers

Option A is wrong because the `files` section with `**/*` does preserve paths by default; it matches all files recursively while maintaining their relative directory structure unless `discard-paths` is explicitly set to `yes`. Option C is wrong because the `base-directory` is optional; if not specified, CodeBuild uses the root of the build output (the default `CODEBUILD_SRC_DIR`), which does not cause flattening—it simply means the artifact is created from the entire build output root. Option D is wrong because the `name` property is optional and only controls the artifact's filename (e.g., a zip or tar name), not the internal directory structure of the artifact; omitting it does not flatten paths.

209
Multi-Selecthard

A company is using AWS CodePipeline with multiple stages: Source (GitHub), Build (CodeBuild), Test (CodeBuild), and Deploy (CloudFormation). The deployment stage is failing intermittently with a 'Rate exceeded' error. The team needs to reduce deployment failures. Which TWO actions should the team take?

Select 2 answers
A.Implement a manual approval step before deployment to stagger multiple pipeline executions.
B.Use exponential backoff and retry in the deployment action.
C.Increase the timeout of the deploy action.
D.Enable CloudWatch detailed monitoring for the deployed resources.
E.Change the deployment to use an in-place deployment type.
AnswersA, B

A manual approval step inserted immediately before the deployment stage forces each pipeline execution to pause until an operator explicitly approves it, thereby serializing (or batching) executions and reducing the burst of concurrent API calls that trigger service-side rate limits. This directly lowers the request rate to services like CodeDeploy or CloudFormation, though it introduces human latency and requires a mechanism to trigger approvals for each queued execution. It does not reduce the per-execution API calls but instead changes their temporal distribution to stay under the quota.

Why this answer

Adding a manual approval step before the deployment stage introduces a gating mechanism that serializes pipeline executions. This prevents multiple concurrent deployments from hitting the CloudFormation API simultaneously, which is the root cause of the 'Rate exceeded' error (typically a 429 HTTP status from the AWS API due to throttling). By requiring human approval, the team can control the flow and reduce the likelihood of exceeding CloudFormation's API rate limits (e.g., 1 request per second per account per region for certain actions).

Exam trap

The trap here is that candidates might think increasing timeouts or changing deployment types (Options C and E) will fix API throttling, but these do not address the root cause of exceeding rate limits; only throttling-aware retry logic or serializing executions (Options A and B) can mitigate the 'Rate exceeded' error.

210
MCQeasy

A DevOps engineer is configuring a webhook trigger in AWS CodePipeline to automatically start a pipeline when changes are pushed to a specific branch in a CodeCommit repository. The webhook is created and the trigger is set to the 'main' branch. However, when a developer pushes a commit to the 'main' branch, the pipeline does not start. What is the MOST likely reason?

A.The webhook is not properly registered with CodeCommit due to a conflict with an existing webhook.
B.The CodeCommit repository is set to send events to Amazon S3, which conflicts with the webhook.
C.The pipeline requires an Amazon SNS notification to be configured for the trigger to work.
D.The CloudWatch Events rule that triggers the pipeline on repository changes is not configured.
AnswerD

For CodeCommit-based pipelines, CodePipeline relies on an Amazon CloudWatch Events (EventBridge) rule that listens for repository state changes, such as a branch reference updated to a specific branch name. If this rule is absent or disabled, the webhook may exist but no events are routed to the pipeline, so pushes to the repository will not trigger a new execution. Configuring or restoring this rule is the required fix.

Why this answer

AWS CodePipeline uses Amazon CloudWatch Events (now Amazon EventBridge) to detect repository changes and trigger pipeline executions. When a webhook is created in CodePipeline, it automatically sets up a CloudWatch Events rule that listens for CodeCommit repository state changes (e.g., push to a branch). If this rule is missing, misconfigured, or deleted, the pipeline will not start despite the webhook being present.

The webhook itself only registers the endpoint; the actual event routing depends on the CloudWatch Events rule.

Exam trap

The trap here is that candidates assume the webhook itself directly triggers the pipeline, but AWS CodePipeline relies on CloudWatch Events as the intermediary event bus, so a missing or misconfigured CloudWatch Events rule will break the trigger even if the webhook is correctly set up.

How to eliminate wrong answers

Option A is wrong because CodeCommit allows multiple webhooks per repository, and a conflict with an existing webhook would cause a creation error, not a silent failure after setup. Option B is wrong because CodeCommit can send events to Amazon S3 via notifications, but this does not conflict with webhooks; both can coexist independently. Option C is wrong because Amazon SNS is not required for webhook-based triggers in CodePipeline; the pipeline listens directly to CloudWatch Events, not SNS.

211
MCQhard

You are a DevOps engineer at a company that runs a critical web application on Amazon EC2 instances behind an Application Load Balancer (ALB). The application is deployed using AWS CodeDeploy with an in-place deployment strategy. The deployment group contains 10 EC2 instances in an Auto Scaling group. Recently, a deployment failed with the error 'The overall deployment failed because too many individual instances failed deployment.' You check the CodeDeploy agent logs on one of the failed instances and see the error 'Script at /opt/codedeploy-agent/deployment-root/deployment-logs/scripts/application_start.sh failed with exit code 1.' The application_start.sh script is part of the AppSpec file. The script attempts to restart the web server. You notice that the script uses a path that exists only on some instances. What should you do to resolve this issue and prevent future failures?

A.Increase the deployment timeout in CodeDeploy.
B.Modify the application_start.sh script to check for the existence of the path before running the restart command.
C.Remove the application_start.sh script from the AppSpec file.
D.Reinstall the CodeDeploy agent on all instances.
AnswerB

Modifying application_start.sh to check for the missing path before invoking the restart command directly addresses the root cause: the restart command (e.g., systemctl restart) is failing because its target binary or configuration file does not exist, causing a non-zero exit that fails the lifecycle hook. Adding a guard such as `if [ -f /path/to/binary ]; then systemctl restart app; else exit 1; fi` ensures the script handles missing dependencies gracefully and only attempts the restart when the prerequisite is actually present on the instance. This also makes the script more robust and idempotent so retries won't fail on the same missing file.

Why this answer

The error indicates that application_start.sh failed because it references a path that does not exist on all instances. The correct fix is to make the script robust by checking for the path's existence before attempting the restart, so it does not fail on instances where the path is absent. This addresses the root cause and prevents future deployment failures.

Exam trap

DOP-C02 often tests the temptation to blame the CodeDeploy agent or increase timeout, when the real issue is a non-idempotent or environment-dependent script that must be made robust.

How to eliminate wrong answers

Option A is wrong because increasing the deployment timeout does not fix a script that fails immediately due to a missing path; the script would still exit with code 1. Option C is wrong because removing application_start.sh from the AppSpec file would skip the application start step entirely, potentially leaving the application not running after deployment. Option D is wrong because reinstalling the CodeDeploy agent does not address the script's path issue; the agent is functioning correctly, as evidenced by the script execution and error log.

212
MCQeasy

A company uses AWS CodeCommit for source control. Developers report that their local branches are out of sync with the remote repository, and they are unable to push changes because of 'non-fast-forward' errors. What should the developers do to fix this?

A.Create a new branch and push that instead.
B.Use 'git push --force' to overwrite the remote branch.
C.Pull the latest changes using 'git pull --rebase' and then push.
D.Delete the remote branch and push again.
AnswerC

Running 'git pull --rebase' fetches the remote branch's new commits and replays your local commits one by one on top of that updated history, producing a linear, fast-forwardable branch. After the rebase, your local branch contains all remote commits, so the subsequent 'git push' is a clean fast-forward rather than a rejected non-fast-forward update. This synchronizes the branch without creating a merge commit or losing any work.

Why this answer

The 'non-fast-forward' error occurs when the local branch is behind the remote branch, meaning the remote has commits the local doesn't have. Running 'git pull --rebase' fetches the latest remote changes and replays the local commits on top of them, creating a linear history. After this, the local branch is up to date and the push will succeed without needing to force or create a new branch.

Exam trap

DOP-C02 often tests the misconception that force-pushing is an acceptable fix for non-fast-forward errors, but the exam expects knowledge of safe collaboration practices like rebasing or merging.

How to eliminate wrong answers

Option A is wrong because creating a new branch does not resolve the underlying divergence; it merely avoids the error by pushing to a different branch, which is not the intended fix. Option B is wrong because 'git push --force' overwrites the remote branch, potentially discarding other developers' commits and causing data loss. Option D is wrong because deleting the remote branch and pushing again is destructive and would remove the branch for all collaborators, leading to lost work and disruption.

213
MCQeasy

A DevOps engineer needs to automate the creation of an Amazon ECS cluster using AWS CloudFormation. The cluster will run a web application that requires a load balancer. Which resource should be used to define the ECS cluster?

A.AWS::ECS::Service
B.AWS::ECS::TaskDefinition
C.AWS::ECS::ContainerInstance
D.AWS::ECS::Cluster
AnswerD

The AWS::ECS::Cluster resource provisions a logical ECS cluster, which is the fundamental grouping of container instances or Fargate capacity where tasks and services are launched. In CloudFormation, this is the correct resource to automate the creation of the ECS cluster itself, and you can additionally configure settings like cluster name, capacity providers, and default namespaces via this resource. It is the top-level construct that other ECS resources like services and task definitions reference.

Why this answer

The AWS::ECS::Cluster resource is the correct CloudFormation resource to define an ECS cluster, which serves as the logical grouping of container instances or Fargate tasks. The question specifically asks for the resource that defines the cluster itself, not the services or tasks running within it. A load balancer can be associated with the cluster via an AWS::ECS::Service resource, but the cluster definition is solely handled by AWS::ECS::Cluster.

Exam trap

The trap here is that candidates confuse the resource that defines the cluster (AWS::ECS::Cluster) with the resource that runs tasks and attaches a load balancer (AWS::ECS::Service), leading them to select the service option when the question only asks for the cluster definition.

How to eliminate wrong answers

Option A is wrong because AWS::ECS::Service defines and manages the desired count, networking, and load balancer configuration for tasks, not the cluster itself. Option B is wrong because AWS::ECS::TaskDefinition defines the container specifications (image, ports, environment) and is used by services or standalone tasks, but does not create the cluster. Option C is wrong because AWS::ECS::ContainerInstance is not a valid CloudFormation resource; container instances are EC2 instances registered to a cluster via an Auto Scaling group or manually, not defined directly as a CloudFormation resource.

214
MCQmedium

Refer to the exhibit. A CodePipeline service role has this IAM policy attached. The pipeline's deploy stage uses CodeDeploy to perform an ECS blue/green deployment. The deployment fails with an access denied error. What is the MOST likely missing permission?

A.ecs:RegisterTaskDefinition
B.codedeploy:CreateDeployment
C.ecs:UpdateService
D.ecs:CreateService
AnswerC

The ecs:UpdateService action is the correct missing permission. During an ECS blue/green deployment, CodeDeploy instructs Amazon ECS to update the existing service with the new task definition, which creates a replacement task set and allows traffic shifting to proceed. The pipeline role must explicitly allow ecs:UpdateService for the target service so that the deployment action can perform this update. Without it, the pipeline fails with an access denied error at the deploy stage.

Why this answer

In an ECS blue/green deployment via CodeDeploy, the CodePipeline service role must have permission to call ecs:UpdateService on the ECS service to trigger the deployment of the new task definition. Without this permission, CodeDeploy cannot update the ECS service to use the new task set, resulting in an access denied error. The other permissions are either already present or not directly required for the deployment action.

Exam trap

The trap here is that candidates assume the CodeDeploy deployment only needs codedeploy:CreateDeployment, but they miss that the service role must also have ecs:UpdateService to allow CodeDeploy to update the ECS service during the blue/green deployment.

How to eliminate wrong answers

Option A is wrong because ecs:RegisterTaskDefinition is typically performed by the pipeline's build stage or a separate action, not by the CodeDeploy deploy stage; the task definition is usually already registered before the deploy stage begins. Option B is wrong because codedeploy:CreateDeployment is the action that initiates the deployment itself, and if it were missing, the pipeline would fail earlier with a different error, not during the ECS service update. Option D is wrong because ecs:CreateService is used to create a new ECS service, not to update an existing one during a blue/green deployment; the service already exists and only needs to be updated.

215
MCQhard

A company uses AWS CodePipeline to deploy a serverless application using AWS SAM. The pipeline has a source stage from CodeCommit, a build stage that runs 'sam build', and a deploy stage that runs 'sam deploy --no-confirm-changeset'. The deploy stage fails with the error 'The security token included in the request is invalid.' What is the MOST likely cause?

A.The CloudFormation stack is in a 'ROLLBACK_COMPLETE' state and cannot be updated.
B.The CodeBuild project does not have access to the CodeCommit repository.
C.The IAM role used by CodeBuild has expired credentials or insufficient permissions to call AWS CloudFormation.
D.The SAM template is invalid and contains syntax errors.
AnswerC

In a serverless CodePipeline, the CodeBuild project executes `sam deploy` and uses its IAM service role to make CloudFormation API calls; if that role's temporary STS credentials have expired or its policies lack `cloudformation:CreateChangeSet`, `cloudformation:ExecuteChangeSet`, or `cloudformation:DescribeStacks`, CloudFormation returns an ExpiredTokenException or AccessDenied error with 'security token invalid' in the message. CodeBuild projects receive short-lived credentials for the build session, and if the build exceeds the role session duration or the role was modified mid-deploy, these credential failures surface in the deploy stage. This precisely matches the reported symptom.

Why this answer

The error 'The security token included in the request is invalid' indicates that the AWS credentials used by CodeBuild to call the CloudFormation API are either expired or lack the necessary permissions. In a CodePipeline with a CodeBuild action, the build project assumes an IAM role to perform actions such as 'sam deploy', which internally calls CloudFormation. If that IAM role's temporary credentials have expired (e.g., due to a long-running build) or the role does not have the required CloudFormation permissions (e.g., cloudformation:CreateChangeSet, cloudformation:ExecuteChangeSet), the API call will fail with this exact error.

Exam trap

The trap here is that candidates often confuse credential expiration with permission errors or misattribute the error to the source repository (CodeCommit) or template syntax, rather than recognizing that the 'sam deploy' command makes CloudFormation API calls using the CodeBuild service role's temporary credentials.

How to eliminate wrong answers

Option A is wrong because a stack in ROLLBACK_COMPLETE state would cause a different error (e.g., 'Stack:arn:aws:cloudformation:... is in ROLLBACK_COMPLETE state and can not be updated'), not a security token error. Option B is wrong because the CodeBuild project's access to the CodeCommit repository is only relevant during the source or build phase, not during the deploy phase; the error occurs during 'sam deploy', which interacts with CloudFormation, not CodeCommit. Option D is wrong because an invalid SAM template would produce a validation error from CloudFormation (e.g., 'Template format error: ...'), not a security token error.

216
MCQmedium

Refer to the exhibit. An IAM policy is attached to a user who needs to start a CodePipeline pipeline and view its details. The user reports that they cannot see the pipeline in the AWS Management Console. What is the MOST likely reason?

A.There is an explicit deny statement elsewhere that is overriding the allow.
B.The user does not have permission to start the pipeline execution.
C.The pipeline ARN is incorrect.
D.The policy does not include the codepipeline:ListPipelines action, which is needed to view pipelines in the console.
AnswerD

The AWS CodePipeline console calls the ListPipelines API to populate the pipeline list. The attached policy, as shown, grants only StartPipelineExecution on a specific pipeline and lacks codepipeline:ListPipelines, which is a required permission for the console to display any pipelines. Without ListPipelines, the user sees an empty console even though they can trigger executions via the API or CLI. To fix this, an additional allow statement for codepipeline:ListPipelines on the `*` resource is necessary (the ListPipelines action does not support resource-level permissions).

Why this answer

The AWS Management Console requires the `codepipeline:ListPipelines` action to populate the pipeline list view. Without this permission, the console cannot display any pipelines, even if the user has permissions for specific pipeline actions like `StartPipelineExecution` or `GetPipeline`. The attached policy grants `codepipeline:StartPipelineExecution` and `codepipeline:GetPipeline`, but omits `ListPipelines`, which is why the user sees an empty pipeline list.

Exam trap

The trap here is that candidates focus on the explicit actions granted (StartPipelineExecution, GetPipeline) and assume they are sufficient, overlooking that the console requires the `ListPipelines` action as a prerequisite for displaying pipelines in the UI.

How to eliminate wrong answers

Option A is wrong because there is no evidence of an explicit deny statement; the issue is a missing allow for a required action, not an override. Option B is wrong because the user can start the pipeline execution (the policy includes `codepipeline:StartPipelineExecution`), but the console still fails to show the pipeline due to missing list permission. Option C is wrong because the pipeline ARN is not relevant to the console's inability to display the pipeline; the ARN is used for resource-level permissions, but the core problem is the missing `ListPipelines` action, not an incorrect ARN.

217
MCQeasy

A development team is using AWS CodeCommit as a source control repository. They want to automate code builds and run unit tests every time a developer pushes code to the 'develop' branch. Which AWS service should they use to trigger the build automatically?

A.Create an AWS CodePipeline with CodeCommit as source and CodeBuild as build stage, configured to start on source changes.
B.Set up AWS CodeDeploy to run builds on code push.
C.Configure AWS CodeCommit to invoke AWS CodeBuild directly.
D.Use Amazon CloudWatch Events to detect a push to CodeCommit and trigger AWS CodeBuild.
AnswerA

AWS CodePipeline is purpose-built for continuous delivery and natively integrates CodeCommit as a source action with CodeBuild as a build action. The pipeline automatically subscribes to CodeCommit repository events (via Amazon EventBridge under the hood) so any push to the selected branch immediately triggers the build stage. This is the recommended, fully managed approach because it also provides artifact passing, stage sequencing, and optional manual approvals without requiring custom glue code.

Why this answer

AWS CodePipeline can be configured with CodeCommit as the source stage and CodeBuild as the build stage, and by enabling the 'Amazon CloudWatch Events' trigger on the pipeline, it automatically starts whenever a change is pushed to the specified branch (e.g., 'develop'). This is the native, fully managed way to achieve continuous integration without custom scripting or additional services.

Exam trap

The trap here is that candidates may think CloudWatch Events alone is sufficient (Option D), but they overlook that CodePipeline provides a higher-level orchestration layer that simplifies CI/CD management, and the exam expects the best-practice service for automating builds on code pushes.

How to eliminate wrong answers

Option B is wrong because AWS CodeDeploy is a deployment service, not a build service; it cannot run builds or unit tests directly. Option C is wrong because CodeCommit does not have native integration to invoke CodeBuild directly; it relies on event-driven triggers via CloudWatch Events or CodePipeline. Option D is wrong because while CloudWatch Events can detect a CodeCommit push and trigger CodeBuild, this approach requires manual setup of a custom event rule and target, and it lacks the orchestration, sequencing, and artifact management that CodePipeline provides out of the box for CI workflows.

218
MCQmedium

A company uses AWS CodePipeline to deploy a microservices application to Amazon ECS. The pipeline has a source stage (CodeCommit), a build stage (CodeBuild), and a deploy stage (CodeDeploy). Recently, deployments have been failing intermittently during the deploy stage with the error: 'The service has reached its maximum number of running tasks.' How should a DevOps engineer resolve this issue?

A.Increase the memory reservation for the task definition
B.Update the ECS service configuration to increase the maximum number of tasks
C.Configure an Amazon ECS Service Auto Scaling policy to scale out
D.Increase the number of concurrent deployments allowed in CodeDeploy
AnswerB

This is the direct fix: the ECS service has an explicit maximum task count (specified via the service's `maximumPercent` in deployment configuration or the `MaxTasks` parameter) that is being exceeded. By increasing that maximum, you permit the service to scale out to the required number of running tasks. The error message specifically indicates that the service cannot add more tasks because this limit is hit, so adjusting the maximum resolves the root cause.

Why this answer

The error 'The service has reached its maximum number of running tasks' indicates that the ECS service's desired count or maximum tasks (if using a placement constraint) has been hit. Updating the ECS service configuration to increase the maximum number of tasks (or the desired count) allows the deployment to proceed by accommodating the new tasks during a rolling update. This directly resolves the capacity limit that CodeDeploy encounters when trying to launch new tasks.

Exam trap

The trap here is that candidates confuse ECS service task limits with CodeDeploy deployment limits or auto scaling policies, leading them to choose options that address scaling or concurrency rather than the explicit task count cap on the ECS service itself.

How to eliminate wrong answers

Option A is wrong because increasing memory reservation does not change the maximum number of tasks the service can run; it only affects resource allocation per task and may cause placement failures but does not address the task count limit. Option C is wrong because Amazon ECS Service Auto Scaling adjusts the desired count based on metrics like CPU/memory, but it does not override the hard limit on maximum tasks; the error occurs because the service already reached its configured maximum, and auto scaling cannot exceed that maximum. Option D is wrong because CodeDeploy's concurrent deployment limit controls how many deployments can run simultaneously across the pipeline, not the number of tasks within a single ECS service; the error is specific to the ECS service task capacity, not CodeDeploy's parallelism.

219
Multi-Selectmedium

A company uses AWS CodeDeploy for deploying applications to an Auto Scaling group of Amazon EC2 instances. The deployment is failing with the error 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available, or some instances in your deployment group are experiencing problems.' Which two actions should the DevOps engineer take to troubleshoot and resolve the issue? (Choose two.)

Select 2 answers
A.Check the CodeDeploy agent logs on the failed instances to identify script errors or missing dependencies.
B.Increase the size of the Auto Scaling group to ensure more instances are available.
C.Verify that the deployment group's Auto Scaling group has the correct tags and that the instances have the CodeDeploy agent installed.
D.Change the deployment configuration to 'CodeDeployDefault.AllAtOnce' to bypass the error.
E.Redeploy the application using a different revision.
AnswersA, C

The CodeDeploy agent writes detailed logs to /opt/codedeploy-agent/deployment-logs/codedeploy-agent-deployments.log, capturing script output, exit codes, and stack traces for each lifecycle event. Reviewing these logs on failed instances reveals whether the root cause is a missing dependency, a syntax error in an AppSpec script, or a permissions issue, enabling a targeted fix.

Why this answer

The CodeDeploy agent logs on each EC2 instance contain detailed error messages about script failures, missing dependencies, or permission issues that cause the deployment to fail. Checking these logs is the first step in diagnosing why individual instances are failing, as the agent executes the AppSpec lifecycle hooks and reports back to the CodeDeploy service.

Exam trap

The trap here is that candidates often jump to scaling or configuration changes (like AllAtOnce) without first checking the instance-level logs, which are the definitive source for diagnosing deployment failures in CodeDeploy.

Why the other options are wrong

B

Increasing the group size does not address the underlying cause; it might mask the issue.

D

Changing the deployment configuration does not resolve the underlying issue; it may cause downtime.

E

Redeploying the same revision will likely fail again; the root cause must be addressed.

220
MCQhard

A company uses AWS CodeBuild to run security scans. The scans require access to a private Amazon ECR repository. The build project is configured with a service role. What is the correct way to provide access to ECR?

A.Set environment variables with ECR credentials in the build project.
B.Configure the ECR repository policy to allow access from the CodePipeline service role.
C.Include the ECR credentials in the buildspec file.
D.Attach an IAM policy to the CodeBuild service role that allows ECR operations.
AnswerD

Attaching an IAM policy to the CodeBuild service role is the correct approach because CodeBuild assumes this role during the build and uses it to authorize ECR actions such as ecr:GetAuthorizationToken, ecr:BatchGetImage, and ecr:GetDownloadUrlForLayer. This gives the build project exactly the permissions it needs, following least privilege, without exposing static credentials in environment variables or source files. The service role is the native and secure identity for CodeBuild to interact with AWS resources like ECR.

Why this answer

CodeBuild uses an IAM service role to define the permissions granted to the build environment. By attaching an IAM policy that allows ECR operations (such as ecr:GetDownloadUrlForLayer, ecr:BatchGetImage, and ecr:GetAuthorizationToken) to the CodeBuild service role, the build project can authenticate and pull images from the private ECR repository without needing to embed or manage static credentials.

Exam trap

The trap here is that candidates often think they need to embed credentials (options A or C) or rely on another service's role (option B), when the correct approach is to attach the necessary IAM policy directly to the CodeBuild service role.

How to eliminate wrong answers

Option A is wrong because setting environment variables with ECR credentials (e.g., access keys) is insecure and unnecessary; CodeBuild should never require long-term credentials when a service role can be used. Option B is wrong because the CodePipeline service role is not involved in the CodeBuild build process; the ECR repository policy could allow access from the CodeBuild service role's principal, but the question specifically asks about the CodeBuild project's access, and the repository policy alone does not grant the CodeBuild service role the required permissions. Option C is wrong because including ECR credentials in the buildspec file would expose sensitive information in plaintext and violates security best practices; the buildspec should rely on the service role's IAM permissions.

221
MCQmedium

A company uses AWS CodePipeline to deploy a web application to an Elastic Beanstalk environment. The pipeline has a source stage from CodeCommit, a build stage using CodeBuild, and a deploy stage to Elastic Beanstalk. Recently, deployments started failing with an error: 'The deployment failed because the Elastic Beanstalk environment is in an UPDATE_ROLLBACK_IN_PROGRESS state.' What is the MOST likely cause?

A.The buildspec.yml file contains an invalid command that prevents artifact generation
B.A previous deployment failed and triggered an automatic rollback, leaving the environment in an unstable state
C.A CloudWatch alarm is blocking the deployment due to high error rates
D.Insufficient IAM permissions for CodePipeline to pull source code from CodeCommit
AnswerB

Elastic Beanstalk environments monitor deployment health and can automatically roll back a failed deployment, leaving the environment in an UPDATE_ROLLBACK_IN_PROGRESS or UPDATE_ROLLBACK_FAILED state. While the environment is rolling back, it is in an unstable state and Elastic Beanstalk rejects new application version deployments, causing the CodePipeline deploy action to fail or remain stuck. This is a known operational issue where a previous failure cascades into blocking subsequent deployments until the rollback completes or is manually resolved.

Why this answer

The error indicates the Elastic Beanstalk environment is stuck in an UPDATE_ROLLBACK_IN_PROGRESS state, which occurs when a previous deployment failed and Elastic Beanstalk automatically rolled back the changes. This leaves the environment in an unstable state that prevents new deployments until the rollback completes or is manually resolved. CodePipeline cannot proceed because Elastic Beanstalk rejects any new update operations while in this state.

Exam trap

The trap here is that candidates may confuse a deployment failure with a permissions or build configuration issue, but the specific error message about the environment state directly points to a prior failed deployment and rollback as the root cause.

How to eliminate wrong answers

Option A is wrong because an invalid command in buildspec.yml would cause the CodeBuild stage to fail, not the deploy stage, and the error message specifically references the Elastic Beanstalk environment state, not a build artifact issue. Option C is wrong because CloudWatch alarms can trigger actions like scaling or notifications but do not directly block CodePipeline deployments; the error message does not mention any alarm or metric. Option D is wrong because insufficient IAM permissions for CodePipeline to pull from CodeCommit would cause the source stage to fail, not the deploy stage, and the error message is about the Elastic Beanstalk environment state, not a permissions error.

222
MCQhard

A DevOps engineer is designing a CI/CD pipeline that must enforce a policy: any change to the production branch in CodeCommit must be reviewed and approved by two senior developers before the change can be merged. The pipeline must also automatically build and deploy to a staging environment after approval. Which combination of AWS services and configurations should be used?

A.Configure CodeBuild to run a script that checks the commit author and rejects if not approved
B.Use Amazon EventBridge to trigger a Lambda function that validates the number of approvers before merging
C.Use IAM policies to restrict write access to the production branch to only senior developers
D.Use CodeCommit pull request approval rules and a CodePipeline with a manual approval step triggered by a Lambda function that checks approval status
AnswerD

CodeCommit's native pull request approval rules are the correct mechanism to block merging until a specified number of approvals (here, two) are received from authorized IAM principals. After the PR is approved and merged, CodePipeline can be triggered by the branch change, and a Lambda function can query the CodeCommit API (for example, `GetPullRequest` or `DescribePullRequestEvents`) to verify the approval state before the pipeline advances. Including a manual approval step in CodePipeline adds an additional human checkpoint between staging and production, which together with the approval rule satisfies both the two-approver requirement and the automated staging deployment.

Why this answer

CodeCommit pull request approval rules enforce the requirement for two senior developers to approve changes before merging, and CodePipeline with a manual approval step can be configured to trigger a Lambda function that checks the approval status before proceeding to build and deploy to staging. This combination directly satisfies the policy of requiring two approvals and automating the build/deploy after approval.

Exam trap

The trap here is that candidates often confuse post-commit checks (like CodeBuild or EventBridge) with pre-merge enforcement, not realizing that only pull request approval rules can block a merge before it happens.

How to eliminate wrong answers

Option A is wrong because CodeBuild runs after a commit is already in the branch; it cannot prevent a merge or enforce pre-merge approval, and checking the commit author does not ensure two senior developers have reviewed and approved the change. Option B is wrong because EventBridge triggers on events but cannot enforce pre-merge approval rules; it would react after a merge event, not prevent unauthorized merges. Option C is wrong because IAM policies restricting write access to senior developers only ensures who can push, but does not enforce the requirement for two approvals before merging; a single senior developer could still push directly without review.

223
MCQmedium

A DevOps team uses AWS CodePipeline to deploy a microservices application. The pipeline includes a CodeBuild project that runs unit tests. Recently, builds have been failing intermittently due to test timeouts. The team wants to improve the reliability of the pipeline without increasing the build timeout. Which action should the team take?

A.Increase the build timeout to the maximum allowed value of 8 hours.
B.Use AWS CodeDeploy to run the unit tests on EC2 instances with more CPU and memory.
C.Modify the unit tests to be non-flaky by adding retries for network calls.
D.Configure the CodeBuild project to run tests in parallel by using separate build environments or test splits.
AnswerD

CodeBuild supports batch builds and test splitting (e.g., dividing the test suite into shards and running them across multiple concurrent build environments), which can dramatically reduce wall-clock time and keep the build under the timeout threshold. With Amazon CodeBuild's batch configuration, you can define a buildspec that splits tests by file, directory, or using tools like pytest-xdist, and CodeBuild orchestrates concurrent execution. This directly addresses the root cause by parallelizing CPU-intensive work rather than extending the deadline or masking flaky tests.

Why this answer

Running unit tests in parallel using separate build environments or test splits directly addresses intermittent timeouts by reducing the total execution time without increasing the build timeout. This approach leverages CodeBuild's ability to run multiple build jobs concurrently, distributing the test load and improving pipeline reliability.

Exam trap

The trap here is that candidates may confuse increasing the timeout (Option A) as a valid fix for intermittent failures, when the correct approach is to optimize test execution time through parallelism rather than extending the timeout window.

How to eliminate wrong answers

Option A is wrong because increasing the build timeout to 8 hours does not fix the root cause of flaky test timeouts; it only masks the symptom and can lead to wasted compute costs and delayed feedback. Option B is wrong because using CodeDeploy to run unit tests on EC2 instances with more CPU and memory is an over-engineered solution that introduces additional infrastructure management overhead and does not inherently resolve intermittent timeouts caused by test flakiness or resource contention. Option C is wrong because adding retries for network calls only addresses one specific type of flaky test (network-related), but the problem statement indicates intermittent timeouts from test execution, not necessarily network failures; retries can also mask underlying issues without improving reliability.

224
Multi-Selecthard

A company uses AWS CodeBuild to run security scans on code. The scan requires access to a private Amazon ECR repository for downloading scanning tools. The CodeBuild project is configured with a VPC and uses an IAM role. However, the build fails with 'Error: unable to pull image from registry.' Which TWO steps should be taken to resolve this?

Select 2 answers
A.Change the ECR repository policy to allow public access.
B.Remove the VPC configuration from the CodeBuild project so it can access the public internet.
C.Add 'ecr:GetDownloadUrlForLayer' and 'ecr:BatchGetImage' permissions to the CodeBuild service role.
D.Grant 'kms:Decrypt' permissions for the KMS key used by ECR.
E.Create a VPC endpoint for Amazon ECR and associate it with the VPC used by CodeBuild.
AnswersC, E

The CodeBuild service role must include ecr:GetDownloadUrlForLayer and ecr:BatchGetImage, along with ecr:GetAuthorizationToken, to successfully pull a container image from Amazon ECR. BatchGetImage retrieves the image manifest, while GetDownloadUrlForLayer obtains the URLs for each layer, and both are required after CodeBuild calls GetAuthorizationToken to authenticate. Without these permissions, CodeBuild receives an AccessDenied exception and the security scan cannot start.

Why this answer

The CodeBuild service role must have the 'ecr:GetDownloadUrlForLayer' and 'ecr:BatchGetImage' permissions to authorize the retrieval of container image layers from the private ECR repository. Without these permissions, the Docker pull operation fails with 'unable to pull image from registry' even if network connectivity is established.

Exam trap

The trap here is that candidates often focus solely on IAM permissions (Option C) and overlook the VPC endpoint requirement (Option E), or they incorrectly assume removing the VPC (Option B) is the fix, not realizing that VPC endpoints are the correct way to provide private connectivity to ECR.

225
MCQeasy

Refer to the exhibit. A developer has a buildspec.yaml for a React application. The build completes successfully, but the artifacts output is empty. What is the most likely cause?

A.The base-directory specified does not exist after the build phase.
B.The install phase did not run because npm install is not in the correct phase.
C.The artifacts files pattern '**/*' is invalid.
D.The runtime version nodejs 14 is not supported by CodeBuild.
AnswerA

The 'base-directory' value in the artifacts block points to a path that CodeBuild expects to exist when it attempts to upload artifacts after the build phase completes. If your build commands generate output inside 'dist', for example, then specifying a base-directory like 'build' will cause an 'artifact base-directory does not exist' failure because that directory was never created or populated. CodeBuild does not automatically compile or copy files; it simply packages whatever is present under the specified path at that moment. Therefore this is the correct reason for the error, not an invalid pattern or runtime.

Why this answer

The most likely cause is that the `base-directory` specified in the `artifacts` section of the buildspec.yaml does not exist after the build phase completes. CodeBuild uses the `base-directory` to locate the files to package as artifacts; if the directory is missing (e.g., because the build output was written to a different path or the directory name was misspelled), no files are found, resulting in an empty artifacts output. This is a common misconfiguration when the build process generates files in a subdirectory that does not match the declared `base-directory`.

Exam trap

The trap here is that candidates assume an empty artifacts output must be caused by a syntax error in the files pattern or a missing install phase, rather than recognizing that a valid but incorrect `base-directory` path silently produces no artifacts.

How to eliminate wrong answers

Option B is wrong because `npm install` is correctly placed in the `install` phase of the buildspec, and the build completed successfully, indicating the install phase ran without issue. Option C is wrong because the pattern `'**/*'` is a valid glob pattern in CodeBuild that recursively matches all files and directories, so it is not the cause of an empty artifacts output. Option D is wrong because Node.js 14 is a supported runtime version in AWS CodeBuild, and the build succeeded, so runtime support is not the issue.

← PreviousPage 3 of 5 · 316 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Sdlc Automation questions.