Courseiva

CCNA Sdlc Automation Questions

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

226
Multi-Selecteasy

A DevOps engineer is designing a CI/CD pipeline for a containerized application using AWS CodeBuild and Amazon ECS. Which TWO actions will help reduce the frequency of Docker image pulls from the public Docker Hub registry?

Select 2 answers
A.Create a Docker Hub access token and store it in AWS Secrets Manager
B.Enable CodeBuild local caching for the cache type 'LOCAL_DOCKER_LAYER_CACHE'
C.Store the base image in Amazon ECR and use it in the build
D.Use AWS CodeArtifact as a proxy for Docker Hub
E.Configure CodeBuild to use a VPC with a NAT gateway
AnswersB, C

Enabling CodeBuild local caching with the cache type LOCAL_DOCKER_LAYER_CACHE stores image layers in the build host's local Docker daemon after the first successful build. On subsequent builds, CodeBuild can reuse those locally cached layers instead of pulling them from Docker Hub, which cuts both external network calls and build time. This is the most direct way to reduce Docker Hub pull frequency for a standard container-image CI pipeline.

Why this answer

Option B is correct because enabling CodeBuild local caching with the cache type 'LOCAL_DOCKER_LAYER_CACHE' persists Docker image layers between builds on the same host, so previously pulled base image layers are reused and Docker does not need to re-pull them from Docker Hub. Option C is correct because storing the base image in Amazon ECR and referencing it in the build pulls the image from ECR (a private, AWS-hosted registry) instead of the public Docker Hub registry, directly reducing Docker Hub pulls. Option A is incorrect because a Docker Hub access token in Secrets Manager only authenticates and raises rate limits; it does not reduce the number or frequency of image pulls.

Option D is incorrect because AWS CodeArtifact does not support Docker/OCI registries as a Docker Hub proxy (it supports package formats like npm, Maven, PyPI, NuGet), so it cannot serve as a pull-through cache for Docker images. Option E is incorrect because attaching CodeBuild to a VPC with a NAT gateway only changes network routing for outbound traffic; it does not cache or eliminate Docker Hub image pulls.

Exam trap

Candidates may think that D (CodeArtifact proxy) is correct, but AWS CodeArtifact does not support Docker registries or act as a proxy for Docker Hub. It is intended for software packages like npm, PyPI, Maven, and NuGet, not for container image caching.

227
MCQmedium

A development team uses AWS CodeCommit for source control and AWS CodePipeline for CI/CD. The pipeline has a source stage that pulls from a CodeCommit repository, a build stage using AWS CodeBuild, and a deploy stage that uses AWS CodeDeploy to deploy to an EC2 Auto Scaling group. The team notices that the pipeline frequently fails at the deploy stage with the error 'The deployment failed because the deployment group's deployment configuration specifies a minimum healthy host count of 1, but 0 healthy hosts are available.' What is the MOST likely cause of this issue?

A.The IAM role for CodePipeline does not have sufficient permissions to access the CodeCommit repository.
B.The build artifacts are not being stored in an S3 bucket.
C.The EC2 instances are not registered with a Classic Load Balancer.
D.The CodeDeploy agent is not installed or is not running on the EC2 instances.
AnswerD

The CodeDeploy agent is a daemon installed on EC2 instances that handles deployment instructions, lifecycle events, and reporting instance status to the CodeDeploy service. Without a running agent, the service never receives a heartbeat or a success signal, so the instance is considered unhealthy and the deployment fails with an error like 'No healthy instances found'. This directly matches the symptom described, and verifying agent status with 'sudo service codedeploy-agent status' or checking /var/log/aws/codedeploy-agent/install.log is the first troubleshooting step. Installing or starting the agent on the tagged instances resolves the failure.

Why this answer

The error message indicates that the CodeDeploy deployment is failing because zero healthy hosts are available in the deployment group. The most common cause is that the CodeDeploy agent is not installed or not running on the EC2 instances, preventing them from reporting their health status to the CodeDeploy service. Without a healthy agent, the instances cannot execute the deployment lifecycle hooks, and CodeDeploy considers them unhealthy, leading to the failure.

Exam trap

The trap here is that candidates often confuse deployment failures caused by missing agents with network or load balancer issues, but the specific error about '0 healthy hosts' directly points to the agent not running or not reporting health, not to load balancer registration or pipeline permissions.

How to eliminate wrong answers

Option A is wrong because the IAM role for CodePipeline lacking permissions to access the CodeCommit repository would cause the source stage to fail, not the deploy stage. Option B is wrong because build artifacts not being stored in an S3 bucket would cause the build or source stage to fail, as CodePipeline requires artifacts to be passed between stages; the deploy stage error specifically relates to host health, not artifact storage. Option C is wrong because EC2 instances not being registered with a Classic Load Balancer is not a requirement for CodeDeploy to work; CodeDeploy can deploy to instances directly via tags or Auto Scaling groups, and the error is about host health, not load balancer registration.

228
MCQhard

A developer is troubleshooting a failed CodeBuild build. The build is triggered by a pull request from a forked repository. The buildspec includes a command to fetch pull request references. What is the most likely cause of the failure?

A.The IAM role for CodeBuild does not have permission to read from the repository.
B.The buildspec file is not present in the source code.
C.The CodeBuild project is not configured to allow pull requests from forked repositories.
D.The buildspec contains invalid syntax.
AnswerC

CodeBuild intentionally does not build pull requests from forked repositories unless you explicitly enable the 'Allow pull requests from forked repositories' setting in the project's webhook configuration. Fork PRs are considered untrusted because the entire buildspec, including install commands and environment variable injection, is controlled by the fork author—so CodeBuild requires an opt-in before it will fetch refs such as refs/pull/123/head or refs/pull/123/merge from a fork. When this setting is off, the source client cannot complete the git fetch for the fork PR, producing exactly the kind of git error being troubleshooted.

Why this answer

When a build is triggered by a pull request from a forked repository, CodeBuild requires explicit configuration to allow builds from forks. By default, CodeBuild projects do not accept webhook events from forked repositories. The error occurs because the project lacks the 'Allow pull requests from forked repositories' setting enabled, even though the IAM role and buildspec may be correctly configured.

Exam trap

The trap here is that candidates often assume the failure is due to IAM permissions or buildspec issues, overlooking the specific CodeBuild setting that controls whether pull requests from forked repositories are allowed.

How to eliminate wrong answers

Option A is wrong because the IAM role for CodeBuild typically has permissions to read from the repository when the build is triggered; the failure is specific to forked repository restrictions, not IAM. Option B is wrong because if the buildspec were missing, CodeBuild would fail with a 'buildspec not found' error, but the question states the buildspec includes a command, implying it exists. Option D is wrong because invalid syntax would cause a build failure at the parsing stage, but the question's context of a forked repository pull request points to a configuration-level restriction, not a syntax issue.

229
MCQhard

A company has a monorepo in AWS CodeCommit with multiple microservices. They want to use AWS CodePipeline to build and deploy only the microservice that changed. What is the MOST efficient approach?

A.Configure a single pipeline that always builds all microservices.
B.Create separate CodeCommit repositories for each microservice.
C.Use an AWS Lambda function triggered by CloudWatch Events for CodeCommit to start the specific pipeline for the changed microservice.
D.Use a single pipeline with multiple build actions that each check if their microservice changed.
AnswerC

This is the correct approach because CodeCommit emits CloudWatch Events (EventBridge) on branch pushes, and a Lambda function can use the CodeCommit API to inspect the files changed in that push. The Lambda then maps a changed path prefix (e.g., 'services/order-service/') to the corresponding CodePipeline pipeline and calls StartPipelineExecution with the exact commit ID and branch. This provides path-based, per-service CI/CD while preserving the monorepo, and it only builds the microservice that actually changed, avoiding wasted compute and keeping feedback fast.

Why this answer

It uses an AWS Lambda function triggered by CloudWatch Events (now Amazon EventBridge) on CodeCommit repository events (e.g., push to a specific branch) to detect which microservice changed and then start the corresponding CodePipeline pipeline. This is the most efficient approach as it avoids unnecessary builds of unchanged microservices and does not require splitting the monorepo or adding complex conditional logic within a single pipeline.

Exam trap

The trap here is that candidates may think a single pipeline with conditional build actions (Option D) is efficient, but they miss that the pipeline still triggers on every change, wasting pipeline executions and build minutes for unchanged microservices.

How to eliminate wrong answers

Option A is wrong because building all microservices on every change wastes compute time and resources, and does not scale efficiently. Option B is wrong because it requires splitting the monorepo into separate repositories, which contradicts the stated monorepo requirement and adds operational overhead for managing multiple repos. Option D is wrong because a single pipeline with multiple build actions that each check if their microservice changed still triggers the entire pipeline on any change, and the conditional checks inside build actions are inefficient and do not prevent the pipeline from running for all microservices.

230
MCQmedium

A DevOps engineer is designing a CI/CD pipeline for a microservices application using AWS CodePipeline. Each microservice has its own CodeCommit repository. The engineer wants to run unit tests in parallel for all services when any repository receives a push, then run integration tests only after all unit tests pass. Which pipeline structure should the engineer use?

A.Create a single pipeline with a parallel action for unit tests, then a serial stage for integration tests
B.Create a single pipeline with a serial stage for unit tests, then integration tests
C.Create one pipeline per microservice, each triggering integration tests via SNS
D.Use AWS CodeBuild batch builds with a fan-out/fan-in pattern
AnswerA

This design uses CodePipeline stages to gate flow: a stage with parallel unit-test actions runs the per-microservice unit suites concurrently, cutting total test wall-clock time, and the stage only completes when every action succeeds. The subsequent integration-test stage is serial relative to unit tests, so integration testing starts only after all unit suites are green, preserving deterministic dependency ordering while still exploiting parallelism where safe.

Why this answer

AWS CodePipeline supports parallel actions within a stage, allowing unit tests for all microservices to run concurrently. After all unit tests succeed, the pipeline transitions to a serial stage for integration tests, ensuring the correct dependency order. This structure minimizes build time while enforcing the required sequential gate.

Exam trap

The trap here is that candidates often confuse parallel actions within a stage with parallel stages, or assume that separate pipelines are needed for each microservice, overlooking CodePipeline's ability to run multiple actions concurrently in a single stage.

How to eliminate wrong answers

Option B is wrong because it runs unit tests serially, which increases overall pipeline duration unnecessarily since there is no dependency between microservice unit tests. Option C is wrong because creating separate pipelines per microservice prevents a single coordinated integration test stage after all unit tests pass; triggering via SNS would require custom orchestration and lose CodePipeline's built-in state management. Option D is wrong because AWS CodePipeline does not natively support fan-out/fan-in patterns; CodeBuild batch builds can parallelize builds but lack the stage-level dependency control needed to run integration tests only after all unit tests complete.

231
MCQhard

A company uses AWS CodeBuild to run integration tests as part of a pipeline. The tests require access to an Amazon RDS database. The RDS instance is in a private subnet with no public access. The CodeBuild project is configured with a VPC. Which additional configuration is necessary to ensure the build can connect to the database?

A.Add an IAM policy that grants the CodeBuild service role access to the RDS instance.
B.Configure the security group for the RDS instance to allow inbound traffic from the security group associated with the CodeBuild project.
C.Create a VPC endpoint for Amazon RDS.
D.Attach a NAT gateway to the private subnet.
AnswerB

The RDS instance's security group must have an inbound rule that allows TCP traffic on the database port (e.g., 3306, 5432) from the security group ID attached to the CodeBuild project's elastic network interface. This is the standard way to permit traffic between AWS resources within a VPC, because security group rules reference other security groups as sources. The CodeBuild project must also be configured with VPC settings (VPC ID, subnets, and security groups) so its ENI is placed in the same network context as the RDS instance, enabling the security group-to-security group allow.

Why this answer

The CodeBuild project is configured with a VPC, meaning it runs inside a private subnet and uses an elastic network interface (ENI) with an associated security group. To allow the build container to connect to the RDS instance, the RDS security group must have an inbound rule that permits traffic on port 3306 (or the appropriate database port) from the CodeBuild security group. This is a standard network-layer access control; no additional IAM or gateway is required for connectivity.

Exam trap

The trap here is that candidates confuse IAM permissions (which control API access) with network security group rules (which control traffic flow), leading them to select Option A, or they mistakenly think a VPC endpoint is needed for database connectivity when it is only for API calls.

How to eliminate wrong answers

Option A is wrong because IAM policies control authentication and authorization for AWS API calls, not network-level traffic; RDS security groups control inbound traffic at the network layer, and IAM does not open ports. Option C is wrong because a VPC endpoint for RDS is used to access the RDS API (e.g., to modify DB instances) from within a VPC without internet traffic, not to connect to the database engine itself; database connections use the database port, not the RDS API endpoint. Option D is wrong because a NAT gateway provides outbound internet access for private subnets, but the RDS instance is in the same VPC, so traffic between CodeBuild and RDS stays within the VPC and does not require internet access.

232
MCQhard

Refer to the exhibit. A developer is using this buildspec.yml in AWS CodeBuild to build and push a Docker image to Amazon ECR. The build fails with the error: 'Error: No region specified'. Which change should the developer make to resolve this error?

A.Add a pre_build command to export AWS_DEFAULT_REGION using the AWS CLI.
B.Set the AWS_DEFAULT_REGION environment variable in the CodeBuild project's environment configuration.
C.Replace $AWS_DEFAULT_REGION with a hardcoded region like us-east-1.
D.Use the AWS_REGION environment variable instead of AWS_DEFAULT_REGION in the buildspec.
AnswerB

Setting AWS_DEFAULT_REGION in the CodeBuild project's environment configuration is the correct fix because CodeBuild injects all project-level environment variables into every phase of the build, making the value available to the AWS CLI, SDKs, and all build commands without any buildspec changes. This approach is explicit, portable, and aligns with AWS best practices for configuring tooling at the project level rather than relying on phase-scoped shell exports.

Why this answer

The error occurs because the $AWS_DEFAULT_REGION environment variable is not set in the CodeBuild project. The developer must explicitly set the AWS_DEFAULT_REGION environment variable in the CodeBuild project configuration.

233
Multi-Selecteasy

A company uses AWS CodePipeline to automate their software release process. They want to add a stage that runs security scanning on the code before deployment. Which two AWS services can be integrated into the pipeline for this purpose? (Choose TWO.)

Select 2 answers
A.Amazon Inspector
B.Amazon GuardDuty
C.Amazon Detective
D.AWS CodeBuild
E.AWS CodeDeploy
AnswersA, D

Amazon Inspector is a vulnerability management service that scans workloads for software vulnerabilities and unintended network exposure. Its CodePipeline integration uses the Inspector Scan action to automatically inspect container images stored in Amazon ECR during the pipeline, blocking deployment if critical findings are discovered. This catches CVE-level issues in dependencies and OS packages before release, making it a direct preventive control.

Why this answer

Amazon Inspector is a vulnerability management service that scans workloads for software vulnerabilities and unintended network exposure. It can be integrated into a CodePipeline stage to perform automated security scanning on the code or infrastructure before deployment, helping to identify issues early in the SDLC.

Exam trap

The trap here is that candidates often confuse Amazon Inspector (a vulnerability scanner for workloads) with Amazon GuardDuty (a threat detector for account activity), or assume that AWS CodeDeploy includes built-in security scanning capabilities, when in fact it only handles deployment orchestration.

234
MCQmedium

A DevOps engineer is reviewing the IAM policy attached to a CodeBuild service role. The policy allows starting builds and viewing logs. However, when CodeBuild tries to download artifacts from an S3 bucket in the same account, it fails with an access denied error. What is the missing permission?

A.s3:GetObject
B.kms:Decrypt
C.s3:PutObject
D.logs:DescribeLogGroups
AnswerA

To download an object from an S3 bucket, the calling principal must be granted the s3:GetObject action. Without this permission, S3 returns an AccessDenied error even if other S3 actions like ListBucket or PutObject are allowed, so adding s3:GetObject is the minimal and correct fix for a build process that retrieves artifacts.

Why this answer

The error occurs because CodeBuild needs to download artifacts from S3, which requires the s3:GetObject permission on the bucket or object. Without this permission, the service role cannot read the artifact files, even though it can start builds and view logs. The s3:GetObject action is the specific permission that grants read access to S3 objects.

Exam trap

The trap here is that candidates may confuse s3:GetObject with s3:PutObject or assume KMS decryption is always required, but the direct cause is the lack of read access to the S3 object.

How to eliminate wrong answers

Option B is wrong because kms:Decrypt is only needed if the S3 bucket uses server-side encryption with AWS KMS (SSE-KMS), but the question does not mention encryption, so the missing permission is not KMS-related. Option C is wrong because s3:PutObject is for uploading objects to S3, not downloading them; the error is about downloading artifacts, not uploading. Option D is wrong because logs:DescribeLogGroups is for listing CloudWatch log groups, which is unrelated to S3 access; it would not cause an S3 access denied error.

235
Multi-Selecthard

A company uses AWS CodePipeline to deploy a serverless application using AWS SAM. The pipeline includes a build stage that runs 'sam build' and a deploy stage that runs 'sam deploy'. The team wants to automatically test the deployed application before promoting it to production. Which THREE steps should be included in the pipeline?

Select 3 answers
A.Add a stage that runs a performance or load test.
B.Add a stage that automatically rolls back the deployment if tests fail.
C.Add a manual approval stage after testing before promoting to production.
D.Add a stage that deploys the application to a separate production environment.
E.Add a stage after deployment that runs integration tests against the deployed API.
AnswersA, C, E

Running a performance/load test stage (e.g., using AWS CodeBuild with Apache JMeter or Artillery against the deployed API endpoint) validates that the serverless application can sustain expected concurrency and throughput without exceeding Lambda concurrency limits or API Gateway throttling quotas. It catches issues like cold start latency, inadequate memory allocation, or downstream dependency bottlenecks that unit tests miss. In serverless, load tests also confirm that provisioned concurrency or auto-scaling behavior works as intended under spike traffic.

Why this answer

Adding a performance or load test stage after deployment validates that the serverless application can handle expected traffic volumes under AWS SAM's provisioned concurrency and scaling limits. This ensures the application meets non-functional requirements before promotion, catching issues like cold start latency or throttling that unit tests miss.

Exam trap

The trap here is that candidates confuse automatic rollback (Option B) with a valid pipeline step, but AWS CodePipeline requires explicit actions for rollback, and the question specifically asks for steps to include, not automated recovery mechanisms.

236
Multi-Selecteasy

A DevOps team is implementing a CI/CD pipeline for a microservices application deployed on Amazon ECS. They want to automatically build, test, and deploy container images to Amazon ECR and then update the ECS service. Which TWO steps are essential to achieve this goal?

Select 2 answers
A.Use AWS CodeDeploy to update the ECS service with a new task definition.
B.Use AWS Secrets Manager to store Docker credentials.
C.Use AWS CodeBuild to build the Docker image and push it to Amazon ECR.
D.Use AWS X-Ray for tracing.
E.Use Amazon CodeGuru for code review.
AnswersA, C

AWS CodeDeploy provides a native ECS deployment mechanism that can shift traffic from the old to the new task definition using blue/green or rolling configurations with an Application Load Balancer. In a CodePipeline-based CI/CD flow, this is the deployment action that makes the newly built image actually run on the ECS service, so it is essential to the pipeline.

Why this answer

AWS CodeDeploy is the native AWS service for managing ECS rolling or blue/green deployments. It orchestrates the creation of a new ECS task definition, registers it, and updates the ECS service to use the new task definition, ensuring zero-downtime deployments. Option C is correct because AWS CodeBuild can execute build commands from a buildspec.yml file to build a Docker image and push it to Amazon ECR using the built-in AWS CLI or Docker commands, which is a fundamental step in a CI/CD pipeline for containerized applications.

Exam trap

The trap here is that candidates may confuse AWS CodeDeploy with AWS CodePipeline or AWS CloudFormation for updating ECS services, but CodeDeploy is the specific service designed for controlled ECS deployments with traffic shifting and rollback capabilities.

237
Multi-Selecteasy

A company is designing a CI/CD pipeline for a serverless application using AWS CodePipeline. Which TWO actions are valid ways to deploy an AWS Lambda function?

Select 2 answers
A.Use AWS CloudFormation to update the Lambda function's stack.
B.Use Amazon S3 to trigger the Lambda function deployment.
C.Use AWS CodeBuild to directly deploy the Lambda function.
D.Use AWS CodeCommit to push the Lambda code.
E.Use AWS CodeDeploy to deploy the Lambda function with traffic shifting.
AnswersA, E

CloudFormation is an infrastructure-as-code service that declares the entire serverless application stack, including the Lambda function, IAM role, event source mappings, and environment variables. Updating the stack applies code and configuration changes in a deterministic order and supports rollback on failure, making it a valid CI/CD deployment step. It treats the Lambda function as a managed resource, and can be invoked via CodePipeline or directly. This is a correct approach because it ensures drift-free, auditable releases.

Why this answer

AWS CloudFormation can manage Lambda function deployments as part of a stack update. By defining the Lambda function resource in a CloudFormation template, CodePipeline can trigger a stack update that creates or updates the function, ensuring infrastructure-as-code best practices and consistent deployments.

Exam trap

The trap here is that candidates often confuse build or source control actions (CodeBuild, CodeCommit) with deployment actions, or mistake event-driven invocations (S3 triggers) for deployment mechanisms, leading them to select options that are valid for other purposes but not for deploying Lambda functions.

238
MCQmedium

A development team is using AWS CodeCommit as a source repository and AWS CodePipeline to automate their CI/CD pipeline. The pipeline includes a build stage that runs on AWS CodeBuild. The team wants to automatically trigger the pipeline when changes are pushed to the 'develop' branch of the CodeCommit repository. Which configuration change should be made to the pipeline?

A.Enable S3 event notifications on the repository to invoke the pipeline.
B.Add a manual approval action before the build stage.
C.Configure the source action to use CodeCommit as the source provider and specify the 'develop' branch.
D.Create a CodeBuild webhook on the CodeCommit repository.
AnswerC

Configuring the source action with CodeCommit as the source provider and specifying the 'develop' branch is exactly how CodePipeline implements automatic change detection for a CodeCommit repository. The action references the repository and branch; on each update to that branch, CodePipeline uses an automatically managed CloudWatch Events rule (or event polling) to trigger a new pipeline execution. This is the recommended native integration, and it ensures every commit to the 'develop' branch starts the pipeline without custom webhooks or manual steps.

Why this answer

CodePipeline's source action can be configured to use CodeCommit as the source provider, and by specifying the 'develop' branch in the source action configuration, the pipeline will automatically start a new execution whenever a change is pushed to that branch. This is the native and recommended way to trigger a pipeline from a CodeCommit repository branch change, without needing additional webhooks or event notifications.

Exam trap

The trap here is that candidates often confuse CodeBuild webhooks (which trigger a build directly) with CodePipeline's native event-driven triggers, leading them to select Option D, even though CodePipeline does not use webhooks for CodeCommit sources.

How to eliminate wrong answers

Option A is wrong because S3 event notifications are not applicable to CodeCommit repositories; CodeCommit uses Git events, not S3 bucket events, and CodePipeline integrates directly with CodeCommit via its source action, not through S3 notifications. Option B is wrong because adding a manual approval action before the build stage would block the pipeline from automatically triggering; it would require manual intervention to proceed, defeating the purpose of automatic triggering on branch pushes. Option D is wrong because CodeBuild webhooks are used to trigger a CodeBuild project directly from a repository, not to trigger a CodePipeline; CodePipeline manages its own polling or event-based triggers for CodeCommit, and creating a separate webhook on CodeCommit would be redundant and not integrated with the pipeline's execution.

239
MCQeasy

A developer is using AWS CodeBuild to compile code. The build takes a long time because dependencies are downloaded each time. What can the developer do to reduce build time?

A.Split the build into multiple parallel build actions.
B.Use multiple build environments to distribute the work.
C.Enable caching in the build project to store dependencies in Amazon S3.
D.Use a larger compute type for the build project.
AnswerC

Enabling S3 caching in a CodeBuild project stores the dependency cache (e.g., Maven's .m2, npm's node_modules, or Python's pip cache) in an Amazon S3 bucket between builds, so the build only downloads changed or missing packages instead of re-fetching the full dependency set each time. This directly reduces the time spent on network I/O, which is often the dominant cost for builds with many third-party libraries. By setting the 'cache' type to S3 and specifying a bucket, subsequent builds restore the cache at the start, making the compilation faster. This is the recommended approach because it targets the common bottleneck of dependency resolution.

Why this answer

Enabling caching in AWS CodeBuild allows the build project to store frequently downloaded dependencies (e.g., Maven, npm, pip packages) in an Amazon S3 bucket. On subsequent builds, CodeBuild retrieves the cached dependencies from S3 instead of re-downloading them from the internet, which significantly reduces build time. This is the most direct and efficient solution for the described problem of repeated dependency downloads.

Exam trap

The trap here is that candidates often confuse scaling compute resources (Option D) or parallelizing work (Option A) with solving a network-bound dependency download problem, failing to recognize that caching is the only option that directly eliminates redundant downloads.

How to eliminate wrong answers

Option A is wrong because splitting the build into multiple parallel build actions does not address the root cause of repeated dependency downloads; it only parallelizes independent build steps, which may reduce overall wall-clock time but does not eliminate the redundant download overhead. Option B is wrong because using multiple build environments distributes the work across different compute instances but does not cache dependencies; each environment would still download dependencies from scratch, so the total download time remains unchanged. Option D is wrong because using a larger compute type (e.g., more CPU/memory) may speed up the build process itself but does not prevent the repeated download of dependencies; the network-bound download step remains a bottleneck regardless of compute size.

240
MCQhard

Refer to the exhibit. Why does the build fail?

A.The CodeBuild role does not have permission to create CloudFront invalidations.
B.The S3 bucket policy denies write access to the CodeBuild role.
C.The CodeBuild project is not associated with the correct service role.
D.The CloudFront distribution ID is incorrect.
AnswerA

The error message in the build log explicitly returns AccessDenied for the CreateInvalidation action, which means the IAM role assumed by CodeBuild does not include a statement allowing cloudfront:CreateInvalidation on the target distribution. Even though the role is correctly associated and used, it lacks this specific identity-based permission, so the aws cloudfront create-invalidation API call fails. This is an IAM policy gap, not a misconfiguration of the project or the distribution.

Why this answer

The build fails because the CodeBuild service role lacks the necessary IAM permission to create a CloudFront invalidation. In AWS CodeBuild, the service role must have explicit permissions for all AWS API calls made during the build, including cloudfront:CreateInvalidation. Without this permission, the AWS CLI command to invalidate the CloudFront distribution returns an AccessDenied error, causing the build to fail.

Exam trap

DOP-C02 often tests the misconception that S3 bucket policies or project role association are the cause of permission errors, when the actual issue is missing specific IAM permissions for the service role.

How to eliminate wrong answers

Option B is wrong because the S3 bucket policy is not the issue; the build likely succeeded in uploading to S3, and the error is related to CloudFront invalidation, not S3 write access. Option C is wrong because the CodeBuild project is associated with a service role (otherwise it couldn't perform any AWS actions), but that role simply lacks the specific CloudFront permission. Option D is wrong because an incorrect CloudFront distribution ID would result in a different error (e.g., NoSuchDistribution), not an access denied error.

241
Multi-Selecthard

Which THREE considerations are important when designing a CI/CD pipeline for a microservices architecture using AWS CodePipeline? (Choose three.)

Select 3 answers
A.All microservices should be deployed using a single pipeline to ensure consistency.
B.Include automated integration tests that validate service-to-service interactions.
C.Use manual approval gates at every stage to ensure quality.
D.Each microservice should have its own pipeline to enable independent deployment.
E.Implement blue/green deployments to reduce downtime and allow quick rollback.
AnswersB, D, E

Automated integration tests that exercise real interactions between services (for example, using contract tests or a dedicated test environment) catch API mismatches, schema changes, and network configuration errors before production. By running these tests early in the CI/CD pipeline, you shift left defect detection, reduce the cost of fixes, and increase confidence that independently deployed services will interoperate correctly.

Why this answer

In a microservices architecture, automated integration tests are essential to validate that service-to-service interactions (e.g., API calls, event-driven communication) work correctly after changes. AWS CodePipeline can run these tests in a dedicated stage using AWS CodeBuild or third-party tools, catching integration failures before deployment to production.

Exam trap

The trap here is that candidates often confuse consistency (Option A) with the need for independent pipelines, or overestimate the value of manual approvals (Option C) in a CI/CD context, failing to recognize that microservices thrive on autonomy and automation.

242
MCQhard

Which AWS service is a fully managed source control service?

A.AWS CodeCommit
B.AWS CodeBuild
C.AWS CodeDeploy
D.AWS CodePipeline
E.AWS CloudFormation
F.Amazon EventBridge
AnswerA

AWS CodeCommit is a fully managed source-control service that hosts private Git repositories, supporting branches, commits, pull requests, and merge operations with IAM-based access control. It matches the description of a source-control service because it is the central repository where developers store, version, and collaborate on code. Its native Git compatibility and tight AWS integration enable seamless use with other DevOps services, but its core identity is version control, not building or deploying.

Why this answer

AWS CodeCommit is a fully managed source control service that hosts private Git repositories, providing version control without managing servers. It integrates with IAM for access control and other AWS developer tools. The other services in the list serve different CI/CD pipeline stages.

Exam trap

DOP-C02 often tests the CI/CD service lineup, tricking candidates into confusing CodeCommit (source), CodeBuild (build), CodeDeploy (deploy), and CodePipeline (orchestration) by their similar naming.

How to eliminate wrong answers

Option B is wrong because AWS CodeBuild is a fully managed build service that compiles code and runs tests, not a source control system. Option C is wrong because AWS CodeDeploy automates application deployments to EC2, Lambda, or on-premises instances, not source control. Option D is wrong because AWS CodePipeline orchestrates CI/CD workflows across stages, not a repository.

Option E is wrong because AWS CloudFormation is an infrastructure-as-code service for provisioning resources, not source control. Option F is wrong because Amazon EventBridge is a serverless event bus for routing events between services, not a source control service.

243
MCQmedium

A DevOps team is designing a CI/CD pipeline for a microservices application. Each microservice has its own CodeCommit repository and must be built and deployed independently. The team wants to minimize manual configuration and ensure that adding a new microservice automatically creates the corresponding pipeline stages. Which approach should the team use?

A.Create a separate AWS CodePipeline for each microservice manually using the AWS Management Console.
B.Use the AWS Cloud Development Kit (CDK) to define a pipeline that dynamically discovers repositories.
C.Use a single AWS CodePipeline with multiple stages, each triggered by a different branch of the same repository.
D.Define a CloudFormation template that creates a pipeline for a given repository and invoke it automatically when a new repository is created using EventBridge and Lambda.
AnswerD

The correct approach uses a parameterized AWS CloudFormation template that defines a complete CodePipeline (source, build, deploy) for a given repository, and combines it with an EventBridge rule that detects the `CreateRepository` API call from CodeCommit (via CloudTrail) and triggers a Lambda function. That Lambda function validates the input and invokes `CreateStack` (or `UpdateStack`) with the repository name as a parameter, automatically provisioning a dedicated pipeline for each new microservice as soon as the repo is created. This delivers event-driven, infrastructure-as-code automation, ensuring every pipeline is identical, versioned, and created without human interaction, thereby meeting the scalability and consistency goals of the team.

Why this answer

It uses an event-driven approach: EventBridge detects the creation of a new CodeCommit repository, triggers a Lambda function that invokes a CloudFormation template to create a corresponding CodePipeline. This fully automates pipeline provisioning for new microservices without manual intervention, aligning with the requirement to minimize manual configuration.

Exam trap

The trap here is that candidates may choose Option B (CDK) thinking it provides dynamic discovery, but CDK is a compile-time tool that cannot react to runtime events like repository creation, whereas EventBridge and Lambda provide true event-driven automation.

How to eliminate wrong answers

Option A is wrong because manually creating a separate CodePipeline for each microservice via the console violates the requirement to minimize manual configuration and does not scale. Option B is wrong because the AWS CDK cannot dynamically discover repositories at runtime; it requires explicit repository references in the code and does not automatically react to new repository creation events. Option C is wrong because using a single pipeline with multiple stages triggered by different branches of the same repository assumes all microservices share a single repository, contradicting the requirement that each microservice has its own CodeCommit repository and must be built and deployed independently.

244
MCQhard

A company runs a critical application on Amazon ECS with Fargate. They use blue/green deployments via AWS CodeDeploy. During a recent deployment, the new task set failed health checks and CodeDeploy automatically rolled back. However, the old task set also became unhealthy shortly after rollback. What could explain this?

A.The CloudWatch alarm that triggered the rollback also stopped the old task set.
B.CodeDeploy did not drain connections from the Application Load Balancer before terminating the old task set.
C.The ECS service auto-scaling policy reduced the desired count of the old task set during the deployment.
D.The new application version changed the database schema, which broke the old version after rollback.
AnswerD

When the new version applied a forward-only database schema migration, the schema changed irreversibly for the running environment. CodeDeploy rolled back the ECS task set to the old code, but that old code cannot understand the new schema, causing errors, failed health checks, and a broken application. This is the recognized cause: database changes are not automatically rolled back, so they break the previous version. The fix is to implement reverse migrations or use an expansion-contraction pattern.

Why this answer

A backward-incompatible database schema change (e.g., a column removal or renaming) applied by the new application version can corrupt or invalidate the data that the old version relies on. When CodeDeploy rolls back to the old task set, the old application cannot function correctly with the altered schema, causing it to fail health checks. This is a classic rollback failure scenario where the deployment changes shared state (the database) that persists beyond the task set lifecycle.

Exam trap

The trap here is that candidates assume rollback always restores full functionality, overlooking that shared mutable state (like a database schema) can persist across deployments and break the old version after rollback.

How to eliminate wrong answers

Option A is wrong because CloudWatch alarms that trigger a rollback do not stop the old task set; they only initiate the rollback process, which CodeDeploy handles by shifting traffic back to the original task set. Option B is wrong because CodeDeploy with ECS blue/green deployments uses the 'original' task set's listener rule weight to shift traffic back during rollback; it does not terminate the old task set until the deployment succeeds, and connection draining is handled by the ALB's deregistration delay, not by CodeDeploy. Option C is wrong because ECS Service Auto Scaling policies do not reduce the desired count of the old task set during a deployment; CodeDeploy manages the desired count of both task sets independently, and auto-scaling is suspended or operates on the active service, not on the old task set being preserved for rollback.

245
MCQhard

A company uses AWS CodeDeploy to deploy a web application to an Auto Scaling group. After a deployment, some instances fail the health check and are terminated by the Auto Scaling group. What should the DevOps engineer do to prevent this?

A.Configure a CloudWatch alarm to stop the deployment if instances are unhealthy.
B.Modify the deployment configuration to deploy to only one instance at a time.
C.Update the deployment group to use an Elastic Load Balancer and configure health checks.
D.Increase the desired capacity of the Auto Scaling group to tolerate failures.
AnswerC

Registering the instances with an Elastic Load Balancer and configuring health checks in the CodeDeploy deployment group is the correct fix because CodeDeploy can then use the ELB's health check to validate that each instance is serving traffic correctly before allowing the deployment to continue. ELB health checks also enable automatic instance replacement by the Auto Scaling group when an instance becomes unhealthy, which prevents the deployment from being stuck with known-bad hosts. This integrates deployment validation with traffic shift and instance lifecycle management, directly addressing the health check failure at the application layer.

Why this answer

Configuring an Elastic Load Balancer (ELB) with health checks in the CodeDeploy deployment group allows CodeDeploy to monitor instance health during deployment. If an instance fails the ELB health check, CodeDeploy can automatically roll back or stop the deployment, preventing the Auto Scaling group from terminating unhealthy instances. This integrates the deployment lifecycle with load balancer health signals, ensuring only healthy instances serve traffic.

Exam trap

The trap here is that candidates often confuse Auto Scaling group health checks (which terminate instances) with CodeDeploy's deployment health checks (which can stop or roll back deployments), leading them to choose options that only address symptoms rather than integrating the two services properly.

How to eliminate wrong answers

Option A is wrong because a CloudWatch alarm can trigger actions like scaling or notifications, but it cannot directly stop a CodeDeploy deployment; CodeDeploy has its own built-in rollback and health check mechanisms that should be used. Option B is wrong because deploying to one instance at a time reduces risk but does not prevent instances from failing health checks and being terminated by the Auto Scaling group; it only limits blast radius. Option D is wrong because increasing the desired capacity of the Auto Scaling group does not address the root cause of health check failures; it only masks the problem by adding more instances, and unhealthy instances will still be terminated.

246
MCQhard

A DevOps engineer is troubleshooting a slow AWS CodeBuild project. The build is a Java application that compiles source code and runs tests. The build environment uses a general1.large compute type. The build duration has increased from 5 minutes to 15 minutes over the past month. The engineer notices that the build logs show 'Downloading...' messages for Maven dependencies for several minutes. What is the most cost-effective way to reduce the build time?

A.Configure the build to use a VPC with a NAT gateway
B.Use AWS CodeArtifact as a proxy for Maven dependencies
C.Change the compute type to general1.2xlarge
D.Enable local caching in the CodeBuild project for dependencies
AnswerD

Enabling local caching in the CodeBuild project tells the build runner to preserve a cache directory on the build host between executions, and when using Maven you can point it at the local repository (~/.m2) so previously downloaded artifacts are reused instead of fetched again. This directly eliminates the repeated network transfer of third-party dependencies, making PR builds dramatically faster by serving artifacts from local disk. Unlike remote caches or bigger compute, it targets the exact dependency-resolution bottleneck and works for both Maven and other package managers when configured correctly.

Why this answer

Enabling local caching in AWS CodeBuild allows the build environment to cache Maven dependencies in the local file system across builds. This eliminates the need to re-download dependencies from remote repositories each time, directly addressing the 'Downloading...' messages in the logs. It is the most cost-effective solution as it requires no additional AWS services or compute upgrades.

Exam trap

The trap here is that candidates often assume upgrading compute resources (Option C) or adding network components (Option A) will fix performance issues, when the actual bottleneck is repetitive network downloads that can be eliminated with caching.

How to eliminate wrong answers

Option A is wrong because configuring the build to use a VPC with a NAT gateway would add network complexity and cost without solving the dependency download bottleneck; NAT gateways are for outbound internet access from private subnets, not for caching dependencies. Option B is wrong because while AWS CodeArtifact can serve as a proxy for Maven dependencies, it introduces additional service costs and setup overhead, making it less cost-effective than local caching for this specific scenario. Option C is wrong because changing the compute type to general1.2xlarge would increase cost by doubling compute capacity without addressing the root cause of slow dependency downloads; the build time is dominated by network latency, not CPU or memory constraints.

247
MCQhard

A company uses AWS CloudFormation to manage infrastructure. The development team wants to promote changes from a development environment to a production environment using change sets. They need to ensure that the production stack is not updated if there are any changes to the stack's IAM policies. Which approach should the team use?

A.Enable drift detection on the production stack and compare with the development stack.
B.Create a ChangeSet from the updated template, review the changes for IAM modifications, and execute only if no IAM changes are present.
C.Use AWS CloudFormation StackSets to deploy to multiple accounts and use stack instance filters.
D.Use a custom resource in the template that checks for IAM changes and fails the update.
AnswerB

Change sets generate a preview of proposed resource modifications, letting the team inspect each JSON diff before execution. Because IAM policy updates surface as distinct resource-change entries, the team can detect them and simply decline to run the change set, satisfying the requirement that production remain unmodified whenever IAM policies differ.

Why this answer

AWS CloudFormation change sets allow you to review the proposed changes to a stack before executing them. By creating a change set from the updated template, the team can inspect the list of changes and specifically look for any modifications to IAM resources (e.g., AWS::IAM::Role, AWS::IAM::Policy). If the change set contains IAM-related changes, they can choose not to execute it, thereby preventing unintended updates to the production stack's IAM policies.

Exam trap

The trap here is that candidates may confuse drift detection (which is reactive) with change sets (which are proactive), or they may think that StackSets or custom resources are needed for multi-environment promotion, when in fact change sets provide a simple, native mechanism for reviewing and selectively applying updates.

How to eliminate wrong answers

Option A is wrong because drift detection compares the current state of a stack with its expected template configuration, but it does not prevent updates; it only reports differences after they occur. Option C is wrong because AWS CloudFormation StackSets are designed for deploying identical templates across multiple accounts and regions, not for reviewing or blocking changes based on IAM modifications in a single production stack. Option D is wrong because a custom resource that checks for IAM changes and fails the update would require complex custom logic and would not leverage the built-in change set review capability; it also risks breaking the update process entirely rather than providing a controlled review step.

248
MCQhard

Refer to the exhibit. A CodeBuild project uses this buildspec. The build fails with the error: 'The runtime version specified is not supported in this environment.' What change should be made?

A.Add an install command to install Node.js 12 from source.
B.Remove the runtime-versions section and install Node.js manually.
C.Update the runtime-versions to nodejs: 14.
D.Change the build environment to use a custom image that includes Node.js 12.
AnswerC

Updating runtime-versions to nodejs:14 is the correct fix because the CodeBuild standard image likely no longer includes Node.js 12 after that version reached end-of-life or was deprecated from the managed environment. By specifying an actively supported runtime like Node.js 14, CodeBuild provisions the matching pre-installed runtime, eliminating the "run not available" error. This change is simple, declarative, and leverages CodeBuild's managed image updates without requiring manual installation or custom images.

Why this answer

The CodeBuild managed image for the specified environment (likely Ubuntu Standard 5.0 or similar) only supports Node.js runtime versions 14 and above. The error indicates that Node.js 12 is not available in the runtime-versions section of the buildspec for that environment. Updating to nodejs: 14 aligns with the supported runtime versions in the managed image, resolving the error without requiring custom images or manual installation.

Exam trap

The trap here is that candidates may assume they can install any Node.js version manually (Option A or B) without realizing that the runtime-versions section is validated against the managed image's pre-configured runtime manager, and the error is not about missing Node.js but about the version not being in the allowed list.

How to eliminate wrong answers

Option A is wrong because installing Node.js 12 from source via an install command would not override the runtime-versions section, and the build environment's runtime version validation occurs before the install phase, so the error would persist. Option B is wrong because removing the runtime-versions section and installing Node.js manually would still fail, as the build environment's default runtime (if any) might not match, and the error is triggered by the environment's lack of support for Node.js 12, not by the presence of the section. Option D is wrong because while using a custom image with Node.js 12 would work, it is an unnecessary and more complex solution compared to simply updating the runtime-versions to a supported version like nodejs: 14, which is the intended fix.

249
MCQmedium

A team uses AWS CloudFormation to manage infrastructure. They have a stack that creates an Amazon RDS instance. During an update, the stack fails with 'CREATE_FAILED' for the DB instance resource, and the error message indicates 'The DB instance already exists.' What is the most likely cause?

A.An RDS instance with the same identifier already exists in the account and region.
B.The stack update is trying to replace the DB instance without a proper UpdateReplace policy.
C.The stack has a DeletionPolicy of Retain on the RDS instance.
D.The RDS instance has deletion protection enabled.
AnswerA

RDS enforces uniqueness of the DB instance identifier within an account and region, so CloudFormation's CREATE_FAILED reflects a naming collision with an existing instance rather than a template or permission fault. The stem's "already exists" error directly satisfies that constraint.

Why this answer

The error 'The DB instance already exists' indicates that CloudFormation is attempting to create a new RDS instance with a DB instance identifier that is already in use within the same AWS account and region. Since DB instance identifiers must be unique per account and region, the creation fails. This typically occurs when a stack update triggers a resource replacement (e.g., due to a property change that requires recreation) and the old instance was not deleted or its identifier is still reserved.

Exam trap

The trap here is that candidates often confuse 'DeletionPolicy' or 'deletion protection' with the root cause, but the error is specifically about a duplicate identifier during creation, not about deletion or retention policies.

How to eliminate wrong answers

Option B is wrong because CloudFormation does not have an 'UpdateReplace policy'; instead, it uses replacement behaviors based on the resource's 'RequiresRecreation' property, and the error here is about a duplicate identifier, not a missing policy. Option C is wrong because a 'DeletionPolicy' of 'Retain' would cause the old RDS instance to persist after stack deletion, but during an update replacement, CloudFormation creates the new instance before deleting the old one, leading to a duplicate identifier conflict — however, the error message specifically says 'already exists,' which is the direct cause, not the DeletionPolicy itself. Option D is wrong because deletion protection prevents the instance from being deleted via the AWS API, but it does not prevent CloudFormation from attempting to create a new instance with the same identifier; the error is about creation, not deletion.

250
MCQmedium

A team is using AWS CloudFormation to manage infrastructure. They want to implement a change management process where any modifications to the stack must be reviewed and approved. Which feature should they use?

A.Change Sets
B.StackSets
C.Drift Detection
D.Stack Policy
AnswerA

Change Sets let you preview the exact changes CloudFormation will make to a stack before executing them. When you create a change set, CloudFormation compiles a list of actions (add/remove/modify resources) that you can review in JSON or summary form, and you can approve, edit, or delete it without touching live infrastructure. This makes them the ideal mechanism for an approval-based change workflow, because the set can be submitted to a reviewer who validates it before the stack update is actually run.

Why this answer

Change Sets allow you to preview how proposed changes to a CloudFormation stack will impact your running resources before you execute them. This enables a review-and-approve workflow because you can generate a change set, have a team member or automated process inspect the list of resource additions, modifications, or deletions, and then either execute or discard the change set. This directly supports the required change management process.

Exam trap

The trap here is that candidates confuse Stack Policies (which protect resources from accidental updates) with a change review mechanism, but Stack Policies do not provide a preview or approval step—they only block certain updates at execution time.

How to eliminate wrong answers

Option B is wrong because StackSets are used to deploy CloudFormation stacks across multiple accounts and regions, not to review or approve changes to a single stack. Option C is wrong because Drift Detection identifies whether a stack's actual resources have diverged from its template, but it does not provide a mechanism to preview or approve proposed modifications. Option D is wrong because a Stack Policy is a resource-level permission document that prevents accidental updates or deletions of specific stack resources, but it does not generate a preview of changes or enforce a review-and-approve workflow.

251
Multi-Selectmedium

A company is implementing a CI/CD pipeline for a microservices architecture on Amazon ECS. The pipeline must deploy to multiple environments (dev, test, prod) in sequence with manual approval gates between environments. Which two AWS services should be used together to meet these requirements? (Choose TWO.)

Select 2 answers
A.AWS CodePipeline
B.AWS CodeBuild
C.AWS CloudFormation
D.AWS CodeDeploy
E.AWS Elastic Beanstalk
AnswersA, D

AWS CodePipeline is the correct orchestrator for a CI/CD pipeline because it provides end-to-end workflow management, defining stages for source, build, test, deployment, and manual approval gates. It can trigger CodeBuild to build and push a container image, then use CodeDeploy or an ECS deploy action to update the ECS service, and even pause between environments (e.g., staging to production) for human sign-off. Its role is to coordinate the sequence and dependencies, not to execute the build or deployment itself, making it the central control plane for the pipeline.

Why this answer

AWS CodePipeline (A) is correct because it provides the orchestration framework to model the CI/CD pipeline with sequential stages for dev, test, and prod environments, including built-in support for manual approval gates between stages. AWS CodeDeploy (D) is correct because it integrates directly with CodePipeline to handle the actual deployment of containerized applications to Amazon ECS, supporting blue/green deployments and traffic shifting for microservices.

Exam trap

The trap here is that candidates often confuse AWS CodeDeploy with AWS CodeBuild or AWS CloudFormation, mistakenly thinking that a build or infrastructure tool can also handle the deployment sequencing and manual approval gates, when in fact CodePipeline is the only service that orchestrates the pipeline flow and CodeDeploy is the service that performs the actual ECS deployment.

252
MCQeasy

A developer is using AWS CodeCommit as a source repository for a CodePipeline. They want to automatically start the pipeline when changes are pushed to the main branch. What is the simplest way to achieve this?

A.Add a Lambda function that is invoked by CodeCommit triggers, which then starts the pipeline.
B.Configure the pipeline to poll the CodeCommit repository every 5 minutes.
C.Use a webhook from CodeCommit to the pipeline.
D.Create an Amazon EventBridge rule that triggers the pipeline on CodeCommit 'push to main' events.
AnswerD

EventBridge is the recommended method for triggering a CodePipeline on CodeCommit pushes. You create a rule with a source of aws.codecommit and an event pattern that matches the codecommit:ReferenceCreated or codecommit:ReferenceUpdated event, and then filter by the branch referenceName, for example "main". The rule targets the CodePipeline pipeline, and the pipeline starts nearly instantly after the push. This approach is fully managed, has no custom code, supports precise branch filtering, and is the AWS-prescribed best practice for CodeCommit source actions.

Why this answer

Amazon EventBridge can natively capture CodeCommit repository events, such as 'push to main', and directly trigger a CodePipeline execution without any custom code or polling. This is the simplest and most serverless approach, as it requires no additional infrastructure or manual configuration of webhooks.

Exam trap

The trap here is that candidates may confuse CodeCommit with third-party Git repositories and assume a webhook is required, but CodeCommit integrates natively with EventBridge, not webhooks, making option C a common distractor.

How to eliminate wrong answers

Option A is wrong because adding a Lambda function introduces unnecessary complexity and cost; CodeCommit triggers invoke Lambda for custom actions, but EventBridge provides a built-in, simpler integration to start pipelines. Option B is wrong because polling every 5 minutes introduces latency (up to 5 minutes delay) and is inefficient compared to event-driven triggers; CodePipeline supports event-based triggers via EventBridge or webhooks. Option C is wrong because CodeCommit does not support webhooks for pipeline triggers; webhooks are used with third-party sources like GitHub or Bitbucket, not with CodeCommit, which relies on EventBridge or CloudWatch Events.

253
MCQhard

A company uses AWS CloudFormation to create a stack with a Lambda function that uses a VPC. The stack creation fails with 'CREATE_FAILED: The provided execution role does not have permissions to call ec2:CreateNetworkInterface on the resource'. What is the likely cause?

A.The VPC does not have a subnet with internet access.
B.The CloudFormation template does not specify a security group.
C.The Lambda function code has a syntax error.
D.The Lambda execution role is missing the ec2:CreateNetworkInterface permission.
AnswerD

When a Lambda function is configured with VPC settings, the AWS Lambda service must create an elastic network interface (ENI) in each subnet on the function's behalf, which requires the execution role to have the `ec2:CreateNetworkInterface` permission. Without this permission, CloudFormation receives an 'Ec2.CreateNetworkInterface is not authorized' error and fails the stack creation, because the function resource cannot be provisioned. The role also needs `ec2:DescribeNetworkInterfaces` and `ec2:DeleteNetworkInterface` for cleanup, but the missing `CreateNetworkInterface` action is the direct blocker.

Why this answer

When a Lambda function is configured to run inside a VPC, it requires the `ec2:CreateNetworkInterface` permission to create an Elastic Network Interface (ENI) in the VPC subnets. The error message explicitly states that the execution role lacks this permission, which is a required IAM action for VPC-enabled Lambda functions. Without this permission, CloudFormation cannot provision the ENI, causing the stack creation to fail.

Exam trap

The trap here is that candidates may confuse network connectivity issues (like missing internet access or security groups) with IAM permission errors, but the error message explicitly names the missing permission, making D the only technically correct answer.

How to eliminate wrong answers

Option A is wrong because the error is about missing IAM permissions, not about subnet internet access; Lambda functions in a VPC do not need internet access unless they explicitly require it (e.g., via a NAT gateway). Option B is wrong because while a security group is required for VPC-enabled Lambda, the error message specifically points to a missing IAM permission, not a missing security group specification. Option C is wrong because a syntax error in the Lambda code would cause a different error (e.g., 'CREATE_FAILED: Invalid function code' or a runtime error), not a permission-related failure during stack creation.

254
Multi-Selecteasy

A company is using AWS CodeBuild to build a Docker image and push it to Amazon ECR. The buildspec.yaml includes commands to build and tag the image. However, the push to ECR fails with an authentication error. Which TWO actions should the DevOps engineer take to resolve this?

Select 2 answers
A.Configure the ECR repository as public.
B.Add a command in the buildspec to run 'aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <account>.dkr.ecr.<region>.amazonaws.com'.
C.Create an ECR lifecycle policy to expire untagged images.
D.Ensure the CodeBuild service role has permissions for ecr:GetAuthorizationToken and ecr:Push.
E.Run 'docker login' with ECR credentials in the buildspec.
AnswersB, D

This command is the standard way to authenticate Docker to an ECR registry. It invokes the AWS CLI to call ecr:GetAuthorizationToken, which returns a base64-encoded password valid for 12 hours, and pipes it directly to docker login using the --password-stdin flag to avoid exposing the token in process listings. The username must be AWS and the registry URL must include the account ID and region. With proper IAM permissions, this makes the subsequent docker push/build step succeed.

Why this answer

The `aws ecr get-login-password` command retrieves a temporary authentication token from the ECR service, which is then piped to `docker login` to authenticate the Docker client against the private ECR registry. This is the standard AWS-recommended method for authenticating Docker to ECR in automated build environments like CodeBuild, as it avoids hardcoding long-lived credentials.

Exam trap

The trap here is that candidates may think simply running `docker login` with static credentials (Option E) is sufficient, but they overlook that ECR requires a dynamically generated token via `get-login-password`, and that the CodeBuild service role must have the correct IAM permissions (Option D) for the authentication flow to succeed.

255
Multi-Selecthard

A company uses AWS CodePipeline with a source stage from Amazon S3. The pipeline deploys a static website to an S3 bucket. The deployment must ensure that the website is always available and that rollbacks happen automatically if the deployment fails. Which TWO actions should the company take?

Select 2 answers
A.Use Amazon Route53 weighted routing to shift traffic
B.Use AWS CodeDeploy with an in-place deployment
C.Use a blue/green deployment strategy with two S3 buckets
D.Configure AWS CloudFormation stack with automatic rollback on failure
E.Enable S3 bucket versioning to keep multiple versions
AnswersC, D

A blue/green deployment strategy with two S3 buckets allows you to host both the current (blue) and new (green) versions of your application or static assets in separate buckets. You validate the green version in production, then switch routing (e.g., via Route 53 or CloudFront) from blue to green, ensuring zero downtime. If issues arise after the switch, changing the routing back to the blue bucket provides an immediate rollback.

Why this answer

A blue/green deployment strategy with two S3 buckets allows the company to maintain the current (blue) bucket serving the live website while deploying the new version to a separate (green) bucket. This ensures zero-downtime deployments and, if the deployment fails, traffic can simply remain pointed to the blue bucket, providing an automatic rollback without any manual intervention. Option D is correct because AWS CloudFormation can be configured with automatic rollback on failure, which will revert the stack to its last known good state if the deployment fails, ensuring the website remains available.

Exam trap

The trap here is that candidates often confuse S3 bucket versioning (Option E) with a deployment rollback strategy, but versioning only provides object-level version history and does not automate traffic switching or infrastructure rollback on failure.

256
Multi-Selectmedium

A company is using AWS CodeBuild to run builds for a Java application. The build takes a long time because it downloads Maven dependencies every time. The team wants to speed up the build by caching dependencies. Which TWO actions should be taken? (Choose 2)

Select 2 answers
A.Enable Amazon S3 caching in the CodeBuild project and specify an S3 bucket to store the cache.
B.Use CodeBuild's 'build cache' feature without specifying a bucket; it will automatically cache to a default location.
C.Set the cache type to 'Local' in the CodeBuild project configuration.
D.Mount an Amazon EFS file system to the build container and configure Maven to use it as a local repository.
E.Configure the buildspec file to save the Maven local repository (.m2) to the cache path.
AnswersA, E

Enabling Amazon S3 caching in the CodeBuild project configuration lets you specify an S3 bucket (and optional prefix) that CodeBuild uses to store and retrieve build artifacts such as the Maven local repository. When S3 caching is turned on, CodeBuild automatically saves the directories declared in the buildspec's cache/paths section to that bucket and restores them at the start of subsequent builds, eliminating repeated dependency downloads and reducing build time. This is the recommended, fully managed caching approach for Java/Maven projects.

Why this answer

CodeBuild supports Amazon S3 caching, which allows you to store build artifacts (such as Maven dependencies) in a specified S3 bucket. By enabling this feature, subsequent builds can download the cached dependencies from S3 instead of re-downloading them from the internet, significantly reducing build time. Option E is correct because the buildspec file must explicitly define the cache path (e.g., /root/.m2) to tell CodeBuild which directory to cache; without this, CodeBuild does not know what to save or restore.

Exam trap

The trap here is that candidates often assume CodeBuild has a built-in local cache that works automatically without configuration, but in reality, you must explicitly define the cache path in the buildspec and choose between S3 or local caching (local caching is only available for certain build environments and still requires the buildspec path).

257
Multi-Selecthard

Which TWO approaches can be used to automatically roll back a failed deployment in AWS CodeDeploy? (Choose two.)

Select 2 answers
A.Use a CloudWatch Events rule to trigger a rollback when a deployment fails
B.Attach an IAM policy to the CodeDeploy service role that allows rollback actions
C.Specify a rollback revision in the AppSpec file
D.Configure the deployment group to automatically roll back when a deployment fails
E.Configure the deployment group to automatically roll back when a CloudWatch alarm is triggered
AnswersD, E

Configuring the deployment group to automatically roll back when a deployment fails is a built-in CodeDeploy feature: you select this option in the deployment group's rollback configuration, and if the deployment fails (for example, due to a failed health check), CodeDeploy automatically redeploys the last successfully deployed revision. This is one of the two native automatic rollback triggers, and it requires no external services or custom code. It also logs the rollback as a new deployment event for auditability.

Why this answer

AWS CodeDeploy allows you to configure a deployment group to automatically roll back a deployment when it fails. This is a native feature that can be enabled in the deployment group settings, ensuring that if a deployment fails (e.g., due to health check failures or script errors), CodeDeploy automatically reverts to the last known good revision without manual intervention.

Exam trap

The trap here is that candidates often confuse CloudWatch Events rules with direct rollback triggers, but CloudWatch Events can only invoke actions like notifications or Lambda functions, not native CodeDeploy rollbacks, which require explicit configuration in the deployment group.

258
MCQhard

A company is using AWS CodeDeploy with a blue/green deployment strategy for an Amazon ECS service. After a deployment, the new task set fails health checks, and CodeDeploy automatically rolls back to the original task set. However, the rollback fails because the original task set's desired count is set to 0. What is the most likely cause?

A.The original task set's desired count was set to 0 during the blue/green deployment and the rollback is unable to restore it because the original task definition is no longer available.
B.The original task set's health checks are failing.
C.The original task set's CloudFormation stack was deleted during the deployment.
D.The original task set was deregistered from the target group.
AnswerA

In a blue/green ECS deployment, CodeDeploy shifts traffic to the replacement task set and sets the original task set's desired count to zero. When a rollback triggers, CodeDeploy attempts to restore that original task set, but if its task definition revision was deregistered or replaced, ECS cannot recreate the task set. The missing task definition makes it impossible to satisfy the service's desired count, leaving the service at zero. This is why keeping the original task definition revision available is critical for successful rollbacks.

Why this answer

During a blue/green deployment on ECS, CodeDeploy sets the original (blue) task set's desired count to 0 after the new (green) task set is created and begins serving traffic. If the green task set fails health checks and triggers an automatic rollback, CodeDeploy attempts to restore the original task set's desired count to its previous value. However, if the original task definition has been deregistered or deleted (e.g., due to lifecycle policies or manual cleanup), the rollback cannot scale the original task set back up, causing the rollback to fail.

Exam trap

The trap here is that candidates assume the rollback fails because the original task set is unhealthy or deregistered from the target group, when in reality the root cause is the deletion of the original task definition, which CodeDeploy needs to recreate the task set during rollback.

How to eliminate wrong answers

Option B is wrong because the original task set's health checks are irrelevant — the original task set is not running (desired count is 0) and thus cannot fail health checks; the rollback failure is due to the inability to restore the task set, not health check failures. Option C is wrong because CloudFormation stacks are not involved in the CodeDeploy blue/green deployment process for ECS; the deployment is managed by CodeDeploy and ECS services, not CloudFormation stack deletion. Option D is wrong because deregistering the original task set from the target group would not prevent the rollback from scaling it up — the rollback fails because the original task definition is missing, not because of target group registration.

259
MCQeasy

A team wants to automate the creation of a CI/CD pipeline using a JSON/YAML file that defines source, build, and deploy stages. Which AWS service should they use?

A.AWS CloudFormation
B.AWS Elastic Beanstalk
C.AWS CodePipeline
D.AWS CodeDeploy
AnswerA

AWS CloudFormation is the correct choice because it allows the CI/CD pipeline to be defined declaratively as infrastructure as code. A CloudFormation template can specify the source stage, build actions, deployment providers (including CodeDeploy), IAM roles, S3 buckets, and event triggers, then create or update the pipeline in a repeatable and version-controlled manner. This makes it a true automation mechanism for pipeline creation, unlike the other services listed, which either are the pipeline itself or operate within it.

Why this answer

AWS CloudFormation is the correct service because it allows you to define infrastructure as code (IaC) using JSON or YAML templates, which can include the creation of a CI/CD pipeline by defining resources like AWS CodePipeline, CodeBuild, and CodeDeploy. This enables full automation of the pipeline's source, build, and deploy stages through a declarative template, rather than manually configuring each service. The question specifically asks for automating the creation of the pipeline itself using a JSON/YAML file, which is exactly what CloudFormation does.

Exam trap

The trap here is that candidates often confuse the service that defines the pipeline (CloudFormation) with the service that runs the pipeline (CodePipeline), leading them to select CodePipeline because it is directly associated with CI/CD, but the question explicitly asks for the service that uses a JSON/YAML file to automate the creation of the pipeline, which is CloudFormation.

How to eliminate wrong answers

Option B is wrong because AWS Elastic Beanstalk is a PaaS service that automates application deployment and scaling, but it does not allow you to define a CI/CD pipeline using a JSON/YAML file; it uses a configuration file (e.g., .ebextensions) for environment settings, not for pipeline stages. Option C is wrong because AWS CodePipeline is a CI/CD service that orchestrates source, build, and deploy stages, but it is the pipeline itself, not a tool to create the pipeline via a JSON/YAML file; while CodePipeline can be defined in a CloudFormation template, the question asks for the service to automate the creation of the pipeline, not the pipeline service itself. Option D is wrong because AWS CodeDeploy is a deployment service that automates code deployments to compute services like EC2 or Lambda, but it only handles the deploy stage and cannot define the entire pipeline (source, build, deploy) using a JSON/YAML file.

260
MCQhard

A DevOps engineer is troubleshooting a CodePipeline that has a Build stage using AWS CodeBuild. The build logs show 'Error: No such file or directory' for a file that is present in the source repository. What is the most likely cause?

A.The buildspec.yaml specifies an incorrect path for the file relative to the source root.
B.The build commands are not executed because the pre_build phase failed.
C.The artifact definition in the buildspec.yaml is incorrect.
D.The environment variables in CodeBuild are not set correctly.
AnswerA

In CodeBuild, each build phase executes from the source root, so any command that references a file—such as a build script, configuration file, or dependency manifest—must specify a path relative to that root (or use $CODEBUILD_SRC_DIR). If buildspec.yaml points to a file using an incorrect relative path (e.g., forgetting a subdirectory, misspelling a folder, or assuming a different working directory), the shell returns a 'No such file or directory' error. Verify the actual repository layout against every file path used in the install, pre_build, build, and post_build commands.

Why this answer

The error 'No such file or directory' indicates that the build process is attempting to access a file at a path that does not exist relative to the source root. In AWS CodeBuild, the build runs in a temporary directory that contains the source code, and all paths in the buildspec.yaml are relative to the source root by default. If the buildspec.yaml specifies an incorrect relative path (e.g., using an absolute path or a wrong subdirectory), CodeBuild will fail to locate the file, even though it exists in the repository.

Exam trap

The trap here is that candidates often confuse file path errors with environment variable misconfiguration or artifact issues, but the root cause is almost always a path mismatch in the buildspec.yaml relative to the source root.

How to eliminate wrong answers

Option B is wrong because if the pre_build phase failed, the build phase would not execute at all, and the error message would typically indicate a phase failure, not a 'No such file or directory' error for a specific file. Option C is wrong because an incorrect artifact definition would cause issues during the artifact packaging or upload phase, not during the build execution when accessing source files. Option D is wrong because environment variables in CodeBuild do not affect file path resolution; they are used for passing configuration values, not for locating files in the source directory.

261
MCQmedium

A development team uses AWS CodePipeline to orchestrate builds and deployments. They want to automatically deploy to a staging environment only if a manual approval step is granted. Which configuration should they use?

A.Add an approval action in the pipeline stage before the deploy action.
B.Use a Lambda function to check a parameter in Parameter Store.
C.Configure a CloudWatch Events rule to trigger deployment after a manual event.
D.Set the deploy action to manual invocation only.
AnswerA

Adding a manual approval action is the native CodePipeline mechanism for inserting a human gate before a deploy action. When the pipeline reaches this action, the execution status changes to OnHold, and the pipeline pauses until an authorized user approves or rejects the action via the console, AWS CLI, or API. You can also configure an SNS notification or a custom URL (e.g., a change request ticket) to guide the approver; if approved, the deploy action automatically proceeds, which directly satisfies the requirement for a manual sign-off before deployment.

Why this answer

AWS CodePipeline supports a manual approval action that pauses the pipeline at a specified stage until an authorized user approves or rejects the deployment. By placing the approval action in the stage before the deploy action, the pipeline will only proceed to the staging deployment after the manual approval is granted, satisfying the requirement exactly.

Exam trap

The trap here is that candidates often confuse manual approval with manual invocation, not realizing that a manual approval action pauses the pipeline for a decision, whereas manual invocation means the action is never automatically triggered by the pipeline.

How to eliminate wrong answers

Option B is wrong because a Lambda function checking a parameter in Parameter Store does not inherently pause the pipeline or enforce a manual approval gate; it would require custom logic to block the pipeline and does not provide the native approval workflow with IAM-based authorization and notification. Option C is wrong because a CloudWatch Events rule can trigger a deployment based on events, but it cannot enforce a manual approval step within the pipeline; it would either start a new pipeline execution or invoke a target, not pause an existing pipeline for human review. Option D is wrong because setting the deploy action to manual invocation only means the action must be started manually outside the pipeline, which breaks the automated orchestration of CodePipeline and does not integrate the approval step as a gate within the pipeline flow.

262
MCQmedium

A team uses AWS CodeBuild to run security scans on code before deployment. They want to ensure that if the security scan fails, the build is marked as FAILED and no further pipeline stages execute. What should they add to the buildspec?

A.Use the 'artifacts' section to define failure conditions.
B.Use the 'env' section to set a variable that fails the build.
C.Use the 'reports' section to mark the build as failed if tests fail.
D.Use the 'phases' section with a command that exits with a non-zero status on failure.
AnswerD

The 'phases' section is the correct place to implement failure logic because CodeBuild evaluates the exit status of each shell command run in its sub-sections (install, pre_build, build, post_build). If any command exits with a non-zero status, the build is stopped immediately and marked as FAILED. For a security scan, you would invoke your scanning tool in the 'build' phase and rely on that exit status to signal failure. This is the only mechanism that directly controls the build outcome.

Why this answer

In AWS CodeBuild, the build process is controlled by the 'phases' section of the buildspec file. Each phase runs a series of commands sequentially, and if any command exits with a non-zero status (e.g., a security scan tool returns a failure exit code), CodeBuild immediately marks the build as FAILED and stops further execution. This ensures that no subsequent pipeline stages are triggered, as the build status propagates to the pipeline.

Exam trap

The trap here is that candidates often confuse the 'reports' section (which only generates test reports) with the mechanism that actually fails the build, forgetting that only the exit code of commands in the 'phases' section determines build success or failure.

How to eliminate wrong answers

Option A is wrong because the 'artifacts' section is used to define output files to be uploaded to Amazon S3 or passed to downstream actions; it does not control build failure conditions or exit codes. Option B is wrong because the 'env' section is used to define environment variables, shell variables, or parameter-store references; setting a variable alone cannot cause the build to fail unless a command later uses it to exit non-zero. Option C is wrong because the 'reports' section is used to specify test report groups for CodeBuild to analyze and export to Amazon CloudWatch or a test report dashboard; it does not directly mark the build as failed if tests fail—only the exit code of commands in the 'phases' section determines build success or failure.

263
MCQmedium

During a deployment using AWS CodeDeploy, the deployment 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 deployment group is configured with a minimum healthy instances of 75%. What could be the cause?

A.The deployment configuration timeout is too short.
B.The CodeDeploy service role does not have sufficient permissions.
C.The instances are not running the CodeDeploy agent.
D.More than 25% of the instances failed the deployment.
AnswerD

A deployment configuration with a 25% failure margin means that the minimum healthy instances threshold is set to 75% (or the equivalent fleet percentage). CodeDeploy continuously monitors the health of each instance across lifecycle events; if more than one quarter of the instances fail or abort, the remaining healthy percentage drops below 75%, and CodeDeploy terminates the deployment to protect the service. The state becomes 'Failed' with a message about the minimum healthy instances threshold being breached.

Why this answer

The error message explicitly states that too many individual instances failed deployment and too few healthy instances are available. With a minimum healthy instances setting of 75%, the deployment fails when more than 25% of the instances in the deployment group fail their deployment. This is a built-in safety mechanism in AWS CodeDeploy to prevent cascading failures and ensure application availability.

Exam trap

The trap here is that candidates may confuse the 'minimum healthy instances' threshold with other deployment configuration settings like timeout values or agent health, when in fact the error message directly indicates that the threshold of 75% healthy instances was breached because more than 25% of instances failed.

How to eliminate wrong answers

Option A is wrong because a timeout that is too short would cause individual instance deployment failures, but the error message specifically points to the aggregate failure threshold being exceeded, not a timeout issue. Option B is wrong because insufficient permissions in the CodeDeploy service role would cause a different error, such as 'AccessDenied' or 'Unable to access the S3 bucket', not the specific healthy-instances threshold error. Option C is wrong because if instances were not running the CodeDeploy agent, they would appear as 'Unknown' or 'Not registered' in the deployment group, and the error would be about missing agents, not about too many failed instances relative to healthy ones.

264
MCQeasy

A startup is using AWS CloudFormation to manage their infrastructure. They have a stack that creates an Amazon S3 bucket and an Amazon DynamoDB table. The stack was created successfully, but when they try to update the stack to add a new S3 bucket, the update fails with the error 'CREATE_FAILED - S3 bucket already exists'. The new bucket name is unique and does not exist. The template uses the same AWS::S3::Bucket resource type. What is the most likely cause?

A.The IAM user does not have permission to create S3 buckets.
B.The S3 bucket name was previously used and is still in the process of being deleted (bucket name not yet released).
C.The stack is in a different region than where the bucket is being created.
D.The CloudFormation template uses the wrong resource type for the bucket.
AnswerB

This is the correct answer because S3 bucket names are globally unique and are not released immediately after deletion. When a bucket is deleted, S3 enters a 'pending deletion' state where the name is still reserved for a variable period (usually minutes, sometimes up to an hour). Attempting to create a new bucket with that same name, whether through CloudFormation or the CLI, results in a BucketAlreadyExists (or BucketAlreadyOwnedByYou for the same account) error until the name is fully released. Since the stack previously managed a bucket with the same name and deleted it, the name is likely still in this cleanup window.

Why this answer

S3 bucket names are globally unique across all AWS accounts and regions. When a bucket is deleted, its name is not immediately released — it enters a 'bucket name not yet available' state that can last from minutes to hours (historically up to 24 hours or longer). If the template tries to create a bucket with a name that was recently deleted, CloudFormation reports CREATE_FAILED with 'bucket already exists' even though the name appears unique to the user.

Exam trap

DOP-C02 often tests the misconception that 'unique name' means 'available name' — candidates forget that S3's global namespace retains deleted bucket names for an indeterminate period.

How to eliminate wrong answers

Option A is wrong because an IAM permission failure would produce an AccessDenied error, not 'bucket already exists'. Option C is wrong because S3 bucket names are global, not region-scoped, so a region mismatch would not cause this specific error. Option D is wrong because AWS::S3::Bucket is the correct resource type; using a wrong type would produce a template validation error, not a name-collision error.

265
MCQeasy

A DevOps engineer is setting up an AWS CodeBuild project that needs to access resources in a VPC, such as an Amazon RDS database. The engineer has configured the CodeBuild project to run in the VPC. Which additional configuration is required for CodeBuild to pull the build Docker image?

A.Create a VPC peering connection to another VPC that has internet access.
B.Configure a VPC gateway endpoint for Amazon ECR.
C.Attach an internet gateway to the VPC and add a default route to it.
D.Create a VPC interface endpoint for Amazon ECR and configure the CodeBuild project to use it.
AnswerD

This is correct because interface endpoints (AWS PrivateLink) for Amazon ECR provide private connectivity from your VPC without requiring internet access. You need to create both the ECR API endpoint and the ECR Docker Registry (DKR) endpoint, and then configure the CodeBuild project to use the VPC, subnet, and security group associated with those endpoints. This allows the build to pull images and push to ECR securely over the AWS network.

Why this answer

When a CodeBuild project runs inside a VPC, it loses default internet access, so it cannot reach public endpoints like Amazon ECR (Docker Hub or ECR) to pull the build image. A VPC interface endpoint (powered by AWS PrivateLink) creates a private, highly available connection to Amazon ECR within the VPC, allowing CodeBuild to pull images without traversing the internet. This is the correct solution because it provides direct, secure access to ECR while keeping all traffic within the AWS network.

Exam trap

The trap here is that candidates often confuse gateway endpoints (which work only for S3 and DynamoDB) with interface endpoints (which are required for services like ECR, ECS, and API Gateway), leading them to incorrectly select option B.

How to eliminate wrong answers

Option A is wrong because VPC peering connects two VPCs but does not provide internet access or a route to Amazon ECR; it would only allow communication between the peered VPCs, not to external services. Option B is wrong because a VPC gateway endpoint is only supported for Amazon S3 and DynamoDB, not for Amazon ECR; ECR requires an interface endpoint (PrivateLink) for private connectivity. Option C is wrong because attaching an internet gateway and adding a default route would give the VPC internet access, but CodeBuild in a VPC does not automatically use that route for pulling images; it would require a NAT gateway or instance in a public subnet, and even then, it is less secure and more complex than using a VPC interface endpoint.

266
MCQeasy

A development team uses AWS CodeCommit as a Git repository. They want to automatically trigger a build in AWS CodeBuild whenever a pull request is created or updated. Which AWS service should be used to detect the pull request events and start the build?

A.Amazon Simple Notification Service (SNS)
B.AWS CodePipeline
C.Amazon CloudWatch Logs
D.Amazon EventBridge
AnswerD

Amazon EventBridge (formerly CloudWatch Events) is the correct service because it provides a default event bus that captures AWS service events, including CodeCommit repository events like 'Reference Created', 'Reference Updated', and 'Reference Deleted'. By defining a rule with an event pattern filtered by repository and branch, EventBridge can directly trigger a CodeBuild project through a built-in integration, passing commit details like the commit ID and branch name to the build, enabling fully event-driven CI/CD without custom glue code.

Why this answer

Amazon EventBridge can capture CodeCommit repository events, such as pull request creation and updates, via its event bus. By setting up an EventBridge rule that matches these specific events, you can directly trigger an AWS CodeBuild project as a target, enabling automated builds without additional orchestration services.

Exam trap

The trap here is that candidates often confuse EventBridge with CloudWatch Events (its predecessor) or assume that SNS is sufficient for triggering builds, overlooking that EventBridge provides direct, event-driven integration with CodeBuild without intermediate services.

How to eliminate wrong answers

Option A is wrong because Amazon SNS is a pub/sub notification service that does not directly invoke CodeBuild; it would require a separate subscriber (e.g., a Lambda function) to parse the notification and call the CodeBuild API, adding unnecessary complexity. Option B is wrong because AWS CodePipeline is a CI/CD orchestration service that can integrate with CodeCommit and CodeBuild, but it is not designed to react to individual pull request events in real time without polling or webhook configuration; EventBridge is the native event-driven solution for this use case. Option C is wrong because Amazon CloudWatch Logs is used for storing, monitoring, and accessing log data, not for detecting repository events or triggering builds; it has no mechanism to capture CodeCommit pull request events.

267
MCQhard

A company uses AWS CodeCommit for source control. Developers frequently push large binary files (e.g., compiled binaries, datasets) to the repository, causing repository size to grow and clone operations to become slow. What is the BEST approach to manage this?

A.Use S3 as the source in CodePipeline and skip CodeCommit for binaries.
B.Store binaries in a separate CodeCommit repository.
C.Increase the repository size limit by requesting a quota increase.
D.Enable Git LFS in CodeCommit and configure the large files to use LFS.
AnswerD

Git LFS in CodeCommit replaces large binary files with small pointer files in the repository and stores the actual binary content in an S3 bucket managed by the service. When developers clone the repo, they only fetch pointers, keeping the repository small and clones fast; the actual binary is downloaded on demand when checking out a specific revision. This maintains Git's full versioning, branching, and commit atomicity while ensuring that the repository itself never bloats.

Why this answer

AWS CodeCommit supports Git Large File Storage (LFS), which replaces large files in the repository with text pointers while storing the actual binary content in a separate hosted storage backend. This keeps the repository lightweight, speeds up clone and fetch operations, and avoids hitting the default repository size limits. Enabling Git LFS is the recommended and best practice for managing large binary files in CodeCommit.

Exam trap

The trap here is that candidates often assume increasing quotas or splitting repositories will solve performance issues, but they fail to recognize that Git LFS is the only option that directly addresses the root cause—large binary files bloating the repository and slowing Git operations.

How to eliminate wrong answers

Option A is wrong because using S3 as the source in CodePipeline bypasses CodeCommit entirely, which breaks the existing developer workflow and version control history for binaries; it also does not solve the problem of slow clones from CodeCommit. Option B is wrong because storing binaries in a separate CodeCommit repository does not reduce the size impact on clone operations—each repository still contains the full binary history, and developers would need to clone both repositories, compounding the problem. Option C is wrong because increasing the repository size limit does not address the underlying issue of slow clones caused by large files; it only postpones hitting the limit while the repository continues to grow and performance degrades further.

268
MCQhard

A DevOps team is designing a CI/CD pipeline for a microservices application. Each service is stored in a separate repository. The team wants to build and test only the services that changed in a given commit. Which AWS solution is MOST efficient and cost-effective?

A.Use AWS CodeCommit triggers with Amazon SNS to send notifications and then manually trigger builds.
B.Use AWS CodeBuild with a webhook that triggers builds only for repositories where files changed, using buildspec filters.
C.Use AWS CodePipeline with a single pipeline that builds all services on every commit.
D.Use Amazon EventBridge to detect repository changes and trigger AWS Lambda functions that determine which services changed.
AnswerB

AWS CodeBuild webhooks natively support filter groups that include FILEPATH patterns, allowing you to trigger a build only when a committed file under a specified path (e.g., 'services/payment/**') changes. Each microservice can have its own CodeBuild project and webhook, so commits to unrelated services do not waste compute time. Additionally, the buildspec can further refine the build with conditional phases, giving precise, automated control without custom infrastructure.

Why this answer

AWS CodeBuild webhooks can be configured with buildspec filter patterns (e.g., using `git diff` or path-based globs) to trigger builds only for repositories where files changed. This avoids unnecessary builds for unchanged services, making it both efficient and cost-effective by minimizing compute time and resource usage.

Exam trap

The trap here is that candidates may overcomplicate the solution by choosing EventBridge and Lambda (Option D) for change detection, missing that CodeBuild webhooks with buildspec filters provide a simpler, built-in, and more cost-effective mechanism for selective builds.

How to eliminate wrong answers

Option A is wrong because manually triggering builds via SNS notifications defeats automation and is neither efficient nor cost-effective for a CI/CD pipeline. Option C is wrong because a single pipeline building all services on every commit wastes resources and time, as unchanged services would be rebuilt unnecessarily. Option D is wrong because while EventBridge and Lambda can detect changes, this adds complexity and cost (Lambda invocations, custom logic) compared to the built-in webhook filtering in CodeBuild, which is more straightforward and cost-effective.

269
Multi-Selectmedium

A company uses AWS CodePipeline with multiple stages. The pipeline includes a Beta stage that deploys to a test environment and a Prod stage. The team wants to require manual approval before the Prod stage. Which TWO actions should be taken to implement this? (Choose TWO.)

Select 2 answers
A.Ensure that the IAM user or role performing the approval has codepipeline:PutApprovalResult permissions.
B.Use CloudWatch Events to trigger a Lambda function that requires manual sign-off.
C.Set the Prod stage to only run on manual invocation.
D.Add a manual approval action in the pipeline stage between Beta and Prod.
E.Configure a CodeCommit approval rule template to require approval before merging.
AnswersA, D

Approving a manual approval action calls the PutApprovalResult API, so the approver's IAM identity must hold codepipeline:PutApprovalResult permission. Without it, the approval token cannot be submitted and the pipeline stalls before the Prod stage, failing the stem's requirement for a gated manual approval.

Why this answer

Option D is correct because AWS CodePipeline implements manual gating through a dedicated approval action: you add a manual approval action to the stage (or a stage placed between Beta and Prod) so the pipeline pauses and waits for a human decision before continuing to Prod. Option A is correct because the person or role that approves the action must call the CodePipeline PutApprovalResult API, which requires the codepipeline:PutApprovalResult IAM permission; without it, the approval cannot be submitted and the pipeline stays blocked. Option B is not needed because CloudWatch Events/EventBridge with Lambda is a custom workaround, whereas CodePipeline natively supports manual approval actions.

Option C is incorrect because CodePipeline stages do not have a 'manual invocation only' setting; approvals are handled by approval actions, not stage invocation modes. Option E is incorrect because CodeCommit approval rule templates govern pull-request merges in CodeCommit, not CodePipeline stage transitions.

Exam trap

The trap here is that candidates often confuse manual approval actions with other approval mechanisms like CodeCommit approval rules or Lambda-based automation, but CodePipeline's manual approval is a distinct action type that requires explicit IAM permissions and a human-in-the-loop step.

270
MCQhard

Refer to the exhibit. A developer runs the AWS CLI command to start a build in AWS CodeBuild. The build project 'my-project' uses an S3 bucket as the source. What is the MOST likely cause of the error?

A.The CodeBuild service role does not have s3:GetObject permission on the source bucket.
B.The S3 bucket name is misspelled in the build project configuration.
C.The developer's IAM user does not have s3:GetObject permission.
D.The S3 bucket is in a different region than the CodeBuild project.
AnswerA

The CodeBuild service role is the IAM role that the build service assumes at runtime to perform actions on your behalf, including fetching source code from Amazon S3. If the role's attached policy lacks an s3:GetObject action on the source bucket, the build start fails with an AccessDenied error that names the role. This is the correct diagnosis because CodeBuild's access to source objects is governed entirely by the service role, not by the caller's user-level S3 permissions.

Why this answer

The error occurs because CodeBuild needs to download the source code from the S3 bucket during the build. The CodeBuild service role, not the developer's IAM user, makes the s3:GetObject API call to retrieve the source object. Without this permission on the service role, the build fails with an access denied error.

Exam trap

The trap here is that candidates confuse the developer's IAM permissions with the CodeBuild service role's permissions, assuming the developer's credentials are used for all actions, when in fact CodeBuild uses its own role for resource access.

How to eliminate wrong answers

Option B is wrong because a misspelled bucket name would cause a 'NoSuchBucket' error, not an access denied error. Option C is wrong because the developer's IAM user only needs permission to start the build (codebuild:StartBuild), not to read the source directly; the service role handles S3 access. Option D is wrong because CodeBuild can access S3 buckets in any region as long as the bucket policy and service role permissions allow cross-region access; there is no regional restriction for S3 sources in CodeBuild.

271
MCQhard

A DevOps team is implementing a CI/CD pipeline for a microservices architecture on AWS ECS. They want to ensure zero-downtime deployments and automatic rollback if health checks fail. Which combination of services should they use?

A.AWS CodePipeline with ECS rolling update and manual rollback.
B.AWS CodeDeploy with ECS blue/green deployment and CloudWatch alarms for automatic rollback.
C.AWS Elastic Beanstalk with rolling deployment and enhanced health reporting.
D.AWS CloudFormation with ECS service update and SNS notification on failure.
AnswerB

AWS CodeDeploy's ECS blue/green deployment creates a new 'green' task set with the new application version while preserving the original 'blue' task set and its target group. During the deployment, CodeDeploy shifts load balancer traffic from blue to green using a canary or linear strategy, and you can define post-deployment hooks and wait times. CloudWatch alarms, such as a failing health check on the green service or increased error rate, trigger a CodeDeploy rollback that automatically reroutes traffic to the blue task set and kills the green tasks. This gives microservices teams zero-downtime release with fully automated rollback—directly meeting the requirement.

Why this answer

AWS CodeDeploy supports blue/green deployments for ECS, which creates a new replacement task set alongside the original, allowing traffic to shift only after health checks pass. CloudWatch alarms can be configured to trigger an automatic rollback if the new deployment fails health checks, ensuring zero-downtime and automated recovery.

Exam trap

The trap here is that candidates often assume AWS CodePipeline with rolling update (Option A) can handle automatic rollback, but CodePipeline itself does not manage deployment strategies or health-check-based rollbacks—those are handled by CodeDeploy, which is specifically designed for blue/green deployments with automatic rollback capabilities.

How to eliminate wrong answers

Option A is wrong because AWS CodePipeline with ECS rolling update does not support automatic rollback on health check failure; manual intervention is required, violating the automatic rollback requirement. Option C is wrong because AWS Elastic Beanstalk is a PaaS service for single applications, not designed for microservices on ECS, and its rolling deployment with enhanced health reporting lacks native blue/green deployment and automatic rollback for ECS. Option D is wrong because AWS CloudFormation with ECS service update can update the service but does not provide built-in blue/green deployment or automatic rollback based on health checks; SNS notification only alerts, it does not trigger rollback.

272
MCQeasy

A company uses AWS CloudFormation to manage infrastructure. The DevOps team wants to deploy a stack across multiple accounts using AWS CodePipeline. Which approach is BEST for automating cross-account deployments?

A.Use AWS CloudFormation StackSets to deploy the stack across accounts.
B.Create a separate pipeline in each account and trigger them manually.
C.Use a single pipeline in the management account with IAM roles that assume cross-account roles.
D.Use an S3 bucket with cross-account access and Lambda to invoke CloudFormation.
AnswerC

A single pipeline in the management account leverages CodePipeline's native cross-account support by assuming an IAM role in the target account for the deployment action. The pipeline uses KMS customer-managed keys to encrypt artifacts, and each target account's role restricts the pipeline to deploy only the intended stack. This centralizes visibility and approval while keeping every account's permissions scoped, making it the recommended pattern for multi-account infrastructure delivery.

Why this answer

AWS CodePipeline can assume an IAM role in the target account (via a cross-account role) to perform CloudFormation deployments. This allows a single pipeline in the management account to automate deployments across multiple accounts without manual triggers or separate pipelines, adhering to the principle of least privilege and centralized control.

Exam trap

The trap here is that candidates often confuse AWS CloudFormation StackSets (Option A) as the best automation tool for CI/CD pipelines, but StackSets lack the sequential orchestration, approval gates, and source stage integration that CodePipeline provides for cross-account deployments.

How to eliminate wrong answers

Option A is wrong because AWS CloudFormation StackSets are designed for deploying identical stacks across multiple accounts and regions from a single admin account, but they lack native integration with CodePipeline for step-by-step CI/CD orchestration, approval gates, and source stage triggers. Option B is wrong because creating separate pipelines in each account and triggering them manually defeats the purpose of automation and introduces operational overhead and inconsistency. Option D is wrong because using an S3 bucket with cross-account access and Lambda to invoke CloudFormation is an overly complex, brittle approach that bypasses CodePipeline's built-in cross-account role assumption mechanism, increasing maintenance burden and security risk.

273
Multi-Selectmedium

A DevOps engineer is troubleshooting a failed CodePipeline execution. The pipeline has a source stage from CodeCommit, a build stage using CodeBuild, and a deploy stage using CodeDeploy. The build stage succeeds, but the deploy stage fails with 'No deployments found for the specified deployment group.' Which TWO actions should the engineer take to resolve this?

Select 2 answers
A.Update the IAM role for CodePipeline to allow it to list deployment groups.
B.Confirm that the CodeDeploy deployment group exists in the same AWS Region as the pipeline.
C.Check the CodeBuild build logs for errors.
D.Verify that the deploy stage in CodePipeline is configured with the correct deployment group name.
E.Ensure the CodeCommit repository has a valid commit.
AnswersB, D

CodePipeline and CodeDeploy are regional services. When a pipeline deploys to a CodeDeploy deployment group, the pipeline's deploy action resolves that group by name within the same AWS Region where the pipeline is running. If the deployment group exists only in a different region, the action cannot find it and fails with a 'deployment group not found' error. This is a common cause, especially when copying pipeline templates across regions without recreating the deployment stack. You must either create the deployment group in the same region as the pipeline or configure a cross-region action with a corresponding artifact bucket in the target region.

Why this answer

CodePipeline and CodeDeploy must operate in the same AWS Region. If the deployment group is in a different Region, CodePipeline cannot find it, resulting in the 'No deployments found' error. This is a common cross-Region misconfiguration that prevents the deploy stage from locating the specified deployment group.

Exam trap

The trap here is that candidates often assume the error is due to IAM permissions (Option A) or source issues (Option E), when the real cause is a Region mismatch or a misconfigured deployment group name in the pipeline definition.

274
Multi-Selectmedium

An organization uses AWS CodePipeline to deploy a static website to Amazon S3. The pipeline has a source stage (CodeCommit), a build stage (CodeBuild that minifies assets), and a deploy stage (S3 deployment). The team wants to add a stage for running security vulnerability scans on the code. Which TWO options are viable?

Select 2 answers
A.Add a custom action in the pipeline that invokes a third-party scanning service via AWS Lambda.
B.Enable AWS Shield Advanced to scan for vulnerabilities.
C.Use Amazon Inspector to scan the source code.
D.Add an S3 event notification to trigger a Lambda function that scans the S3 bucket.
E.Modify the buildspec in the build stage to include commands that run security scanning tools.
AnswersA, E

CodePipeline’s custom-action framework lets you define a stage gate backed by a Lambda function that calls your third-party scanner; the Lambda uses the job worker API (e.g., PutJobSuccessResult/PutJobFailureResult) to report the scan outcome, failing the stage if vulnerabilities are found. This approach is ideal when the scanning vendor doesn't have a built-in action provider and you need the scan to happen at a specific point in the pipeline before deployment.

Why this answer

AWS CodePipeline supports custom actions that can invoke external services via AWS Lambda. By creating a custom action, the team can integrate a third-party security scanning service directly into the pipeline, allowing the scan to run as a distinct stage between build and deploy. This approach ensures that the pipeline fails if vulnerabilities are detected, preventing insecure code from reaching the S3 bucket.

Exam trap

The trap here is that candidates may confuse Amazon Inspector (which scans runtime environments) with a source code scanner, or assume that Shield Advanced provides vulnerability scanning, when in fact it only mitigates DDoS attacks.

275
MCQeasy

A company is using AWS CodeCommit for source control and wants to automatically trigger a build in AWS CodeBuild whenever a pull request is created against the main branch. Which AWS service should be used to connect CodeCommit events to CodeBuild?

A.AWS CodePipeline
B.Amazon EventBridge
C.AWS Lambda
D.Amazon Simple Notification Service (SNS)
AnswerB

Amazon EventBridge is the native event-delivery service for AWS and CodeCommit automatically publishes repository events—such as referenceCreated, referenceUpdated, and referenceDeleted—as event objects to the default EventBridge bus. You can define a rule with an event pattern matching the specific CodeCommit repository and event type, then set the rule's target to a CodeBuild project, which EventBridge invokes directly and asynchronously. This is the simplest and most direct integration because no intermediate processing or custom code is required, and you can even configure an input transformer to pass the commit ID as the sourceVersion to the CodeBuild build so the build uses the exact revision that triggered it.

Why this answer

Amazon EventBridge is the correct choice because it can capture CodeCommit repository events (such as pull request creation) via a default event bus and route them to targets like CodeBuild. This allows you to define a rule that matches the 'codecommit: PullRequestCreated' event and triggers a CodeBuild project directly, without needing an intermediary pipeline or compute service.

Exam trap

The trap here is that candidates often choose AWS CodePipeline because they assume a full CI/CD pipeline is required for any build trigger, but EventBridge provides a simpler, event-driven integration that directly connects CodeCommit events to CodeBuild without pipeline overhead.

How to eliminate wrong answers

Option A is wrong because AWS CodePipeline is a CI/CD orchestration service that can poll CodeCommit for changes or be triggered by EventBridge, but it is not the direct service to connect CodeCommit events to CodeBuild for a single pull request trigger; it adds unnecessary complexity and cost. Option C is wrong because AWS Lambda can be used as a custom target to invoke CodeBuild, but it requires writing and maintaining custom code to parse the event and call the CodeBuild API, whereas EventBridge provides a native, serverless integration without code. Option D is wrong because Amazon SNS is a pub/sub messaging service that can receive events from EventBridge and fan out to subscribers, but it cannot directly trigger CodeBuild; you would still need an additional service (like Lambda or a webhook) to invoke the build.

276
MCQmedium

A development team uses AWS CodeCommit for source control and AWS CodePipeline for CI/CD. The pipeline has a Source stage that polls the repository for changes. Recently, developers have noticed that the pipeline does not always trigger when code is pushed to the main branch. What is the most likely cause?

A.The number of pushes to the repository has exceeded the CodePipeline poll rate limit.
B.The repository does not have a webhook configured to notify CodePipeline of changes.
C.The IAM role used by CodePipeline does not have permission to read from CodeCommit.
D.CloudWatch Events is not enabled for the repository.
AnswerA

CodePipeline polls CodeCommit for changes at a fixed interval (e.g., every 5 minutes) when no webhook is configured. If the repository receives numerous pushes in a short period, the polling calls to CodeCommit's API may be throttled by their respective rate limits, causing a poll to fail silently. Even if the poll succeeds, changes are aggregated, so a single push may not generate a distinct execution if superseded by later commits. This throttling—not any missing configuration—results in no pipeline trigger being created.

Why this answer

CodePipeline uses a polling mechanism to check for changes in CodeCommit repositories. When the number of pushes exceeds the default poll rate limit (typically one request per 15 seconds), the pipeline may miss some changes, leading to inconsistent triggering. This is a known limitation of polling-based detection, especially in high-velocity development environments.

Exam trap

The trap here is that candidates often assume webhooks are mandatory for CodePipeline to detect CodeCommit changes, but the default polling mechanism can still work—though it may miss changes under high push volume, leading to intermittent failures.

How to eliminate wrong answers

Option B is wrong because CodePipeline does not require a webhook for CodeCommit; it relies on polling by default, and the question states the pipeline polls the repository. Option C is wrong because if the IAM role lacked read permissions, the pipeline would fail consistently, not intermittently. Option D is wrong because CloudWatch Events is not required for CodePipeline to detect changes; the pipeline uses polling, not event-driven triggers, unless explicitly configured with a webhook or CloudWatch Events rule.

277
MCQmedium

A company uses AWS CodePipeline to deploy a Node.js application to AWS Elastic Beanstalk. The pipeline includes a build stage that runs 'npm install' and 'npm test'. The team notices that the build stage often fails due to network timeouts when downloading npm packages. Which action would MOST reliably resolve this issue?

A.Configure the CodeBuild project to use a VPC with a NAT gateway to the internet.
B.Use a custom Docker image that includes pre-installed npm packages.
C.Enable local dependency caching in the buildspec file.
D.Increase the build timeout to the maximum value.
AnswerA

By default, a CodeBuild project that is associated with your Amazon VPC runs in one of your private subnets and has no outbound internet connection unless your route table directs traffic through a NAT gateway. Without that route, `npm install` cannot reach the npm registry and fails with network timeouts. Placing the NAT gateway in a public subnet, updating the private route table to `0.0.0.0/0 -> nat-gateway-id`, and associating the CodeBuild project with that VPC gives the build deterministic, reliable egress to the internet while still allowing it to access any VPC-only resources.

Why this answer

The network timeouts occur because the CodeBuild project lacks outbound internet access to reach the npm registry. By configuring the CodeBuild project to use a VPC with a NAT gateway, you provide a stable, routable path to the internet via the NAT gateway's elastic IP, eliminating intermittent connectivity issues caused by relying on public endpoints through a non-VPC network path.

Exam trap

The trap here is that candidates often assume increasing timeouts or caching will fix intermittent network failures, but the real issue is a missing outbound internet path when CodeBuild is configured to run inside a VPC without a NAT gateway.

How to eliminate wrong answers

Option B is wrong because pre-installing npm packages in a custom Docker image does not address the root cause of network timeouts during the build; it only avoids downloading packages for the first build, but subsequent updates or missing dependencies would still require internet access. Option C is wrong because local dependency caching reduces download time for repeated dependencies but does not resolve network timeouts caused by lack of outbound internet connectivity; the timeout would still occur on the first cache miss or cache refresh. Option D is wrong because increasing the build timeout does not fix the underlying network connectivity issue; it merely allows the build to wait longer for a timeout that will still occur if the npm registry is unreachable.

278
MCQhard

A DevOps engineer maintains a CodePipeline whose deploy stage uses the AWS CloudFormation deploy action. The team needs to add a step that runs a custom validation script against the generated CloudFormation template, and the validation must run before the stack is updated but must not modify the template. The validation script is stored in the same CodeCommit repository as the template. What is the most appropriate way to insert this step?

A.Configure the CloudFormation deploy action to use a change set and require manual approval of the change set before execution.
B.Replace the CloudFormation deploy action with a CodeBuild action that runs the validation script and then calls cloudformation deploy.
C.Add a Lambda invoke action in the deploy stage before the CloudFormation deploy action and have the function pull the template from CodeCommit to validate it.
D.Add a CodeBuild action in the same stage before the deploy action, with a buildspec that runs the validation script on the input artifact.
AnswerD

CodeBuild actions in a stage run in runOrder sequence and receive the pipeline's artifacts as input. Placing a validation action before the deploy action lets the script inspect the generated template without modifying it, and the deploy action only runs if validation succeeds, preserving the native deploy behavior.

Why this answer

The validation must run before the stack update, operate on the pipeline's template artifact, and leave the template unchanged. A CodeBuild action placed earlier in the same stage with a lower runOrder consumes the input artifact, runs the repository's script, and gates the subsequent CloudFormation deploy action, preserving native deploy behavior and artifact consistency.

Exam trap

The trap here is replacing the CloudFormation deploy action or adding manual approval, when a preceding CodeBuild action in the same stage already provides scripted validation on the pipeline artifact.

279
MCQmedium

A company uses AWS CloudFormation to manage infrastructure. They have a stack that creates an Amazon RDS instance. The stack creation fails with the error: 'The following resource(s) failed to create: [DBInstance]'. The CloudFormation template includes a parameter for the DB instance class. Which troubleshooting step should be taken FIRST?

A.Increase the stack creation timeout to allow more time for the database to be created.
B.Check the CloudFormation stack events for a detailed status message from the DBInstance resource.
C.Verify that the VPC has at least two public subnets in different Availability Zones.
D.Use the Amazon RDS console to check if a DB instance with the same identifier already exists.
AnswerB

Checking the CloudFormation stack events is the most direct and authoritative diagnostic step because every resource action logs a status reason that mirrors the exact API error returned by the RDS service. For a DBInstance failure, the event's status message will contain the precise reason—such as an invalid DB instance class, insufficient subnet coverage, or a parameter group mismatch—saving you from guesswork. The events tab also shows the sequence of resource creation, so you can determine whether the failure is isolated to the database or caused by a dependency like a VPC or subnet group that failed earlier.

Why this answer

The first step when a CloudFormation stack creation fails is to check the stack events in the CloudFormation console or via the AWS CLI. Each resource creation attempt generates a status message that includes a detailed reason for the failure, such as insufficient capacity, incorrect parameter values, or network configuration issues. For an RDS DBInstance, the event message will provide the specific error (e.g., 'DB instance class not supported in this Availability Zone'), enabling targeted troubleshooting without guesswork.

Exam trap

The trap here is that candidates jump to common RDS prerequisites (like VPC subnets or duplicate identifiers) without first consulting the CloudFormation stack events, which provide the precise failure reason and are the standard diagnostic tool for any stack creation failure.

How to eliminate wrong answers

Option A is wrong because increasing the stack creation timeout does not address the root cause of a failure; it only extends the wait period, and RDS instance creation typically completes within the default timeout unless there is a resource constraint or misconfiguration. Option C is wrong because RDS instances in a VPC require at least two subnets (public or private) in different Availability Zones only if you are creating a Multi-AZ deployment or a DB subnet group; the error message does not indicate a subnet issue, and this is not the first troubleshooting step. Option D is wrong while checking for a duplicate DB instance identifier is a valid possibility, the CloudFormation stack events will explicitly report a 'DBInstanceAlreadyExists' error if that is the cause, making it redundant to check the RDS console first; the events provide the definitive diagnosis.

280
MCQhard

A company has a CI/CD pipeline that deploys to Amazon ECS using AWS CodePipeline. The pipeline includes a manual approval step before deployment to production. The security team requires that all approvals be logged in AWS CloudTrail and that the approver's identity be verified. Which action should the DevOps engineer take to meet these requirements?

A.Ensure that the manual approval action is configured as a CodePipeline approval action; CloudTrail will log the 'Approval' event with the IAM user ARN.
B.Create a custom CloudTrail trail specifically for CodePipeline API calls.
C.Enable CloudTrail Insights to detect unusual approval activity.
D.Configure the approval action to send a notification to an Amazon SNS topic, and log the SNS delivery to CloudWatch Logs.
AnswerA

CodePipeline's manual approval action generates a PutApprovalResult API call when an approver clicks to approve or reject. CloudTrail automatically captures that call, and the event includes the IAM principal ARN (user or role), the timestamp, source IP, and session context. This satisfies the audit requirement without any additional configuration.

Why this answer

CodePipeline's manual approval action inherently generates an 'Approval' event in CloudTrail when an approver approves or rejects the action. This event includes the IAM user ARN of the approver, satisfying both the logging and identity verification requirements without additional configuration.

Exam trap

The trap here is that candidates may think they need to create a custom CloudTrail trail or enable Insights to meet logging requirements, but CloudTrail already logs all CodePipeline API calls by default, including manual approval actions with the approver's identity.

How to eliminate wrong answers

Option B is wrong because creating a separate CloudTrail trail for CodePipeline API calls is unnecessary; CloudTrail is already enabled by default for all AWS services, including CodePipeline, and logs all management events, including approval actions. Option C is wrong because CloudTrail Insights is designed to detect unusual API activity patterns (e.g., anomalous call volumes), not to log or verify individual approval events or identities. Option D is wrong because sending a notification to an SNS topic and logging delivery to CloudWatch Logs does not capture the approver's IAM identity in CloudTrail; it only logs the SNS delivery event, not the approval action itself.

281
MCQmedium

A company uses AWS CodeDeploy with a blue/green deployment strategy for an Amazon EC2 Auto Scaling group. During deployment, the new instances are failing health checks and the deployment is rolling back. What is the MOST likely cause?

A.The new instances are not passing the configured health check grace period.
B.The application is not registered with an Elastic Load Balancer.
C.The deployment group is not configured to use an Auto Scaling group.
D.The CodeDeploy agent is not installed on the new instances.
AnswerA

During a CodeDeploy blue/green deployment, the new instances (green) are launched and then a health check grace period is applied before traffic is shifted. If the application fails to become healthy within that window, CodeDeploy considers the deployment failed and automatically rolls back to the original blue fleet. This is the only condition that directly results in a rollback after the new instances are provisioned, making it the correct answer.

Why this answer

In a blue/green deployment with CodeDeploy, new instances are launched and must pass health checks before traffic is routed to them. If the health check grace period is not configured or is too short, the new instances may be deemed unhealthy before the application has fully started, triggering a rollback. This is the most likely cause because the health check grace period directly controls how long CodeDeploy waits before evaluating instance health.

Exam trap

The trap here is that candidates often assume the CodeDeploy agent is missing (Option D) because it's a common issue, but the agent must be present for the deployment to even start—health check failures occur after the agent has successfully installed the application.

How to eliminate wrong answers

Option B is wrong because if the application were not registered with an Elastic Load Balancer, health checks would not be performed at all, and the deployment would not fail due to health check failures—it would either succeed or fail for another reason. Option C is wrong because the deployment group must be configured to use an Auto Scaling group for a blue/green deployment to work; if it were not, the deployment would fail at the start, not during health checks. Option D is wrong because if the CodeDeploy agent were not installed on the new instances, the deployment would fail during the Install phase, not during health checks, and the error would be about agent connectivity, not health check failures.

282
MCQhard

A company is using AWS CodeBuild to compile a Java application. The build takes over 30 minutes, which is too long. The project uses the standard build environment. The source code is stored in an S3 bucket. What is the most effective way to reduce build time?

A.Use a custom build environment with pre-installed Java.
B.Enable local caching for dependencies in the buildspec.yml.
C.Store the source code in AWS CodeCommit instead of S3.
D.Increase the compute type to a larger instance.
AnswerB

Enabling local caching in the buildspec.yml stores resolved dependencies (e.g., Maven ~/.m2 or Gradle caches) in a local cache directory on the build host, which persists across builds for the same project. This avoids re-downloading artifacts from repositories like Maven Central on every build, which is typically the most significant variable in Java build time. The correct configuration uses the 'cache' section with 'paths' pointing to the dependency directories and a 'local' cache type; unlike S3 caching, local caching has zero network latency and is ideal for short-lived, high-frequency builds.

Why this answer

Enabling local caching in the buildspec.yml allows CodeBuild to reuse previously downloaded dependency files (e.g., Maven .m2 repository) across builds, significantly reducing the time spent on dependency resolution. Since the build takes over 30 minutes, caching avoids re-downloading dependencies on every build, which is the most effective optimization for a standard build environment.

Exam trap

The trap here is that candidates often assume increasing compute power (Option D) is the universal fix for slow builds, but the question specifically highlights a 30-minute build time in a standard environment, which typically indicates dependency download latency rather than CPU constraints.

How to eliminate wrong answers

Option A is wrong because using a custom build environment with pre-installed Java does not address the primary bottleneck of dependency downloads; it only saves a few seconds on environment setup. Option C is wrong because storing source code in CodeCommit instead of S3 does not reduce build time; both are source storage options with similar retrieval speeds, and the build time issue is not related to source code retrieval. Option D is wrong because increasing the compute type to a larger instance may improve CPU-bound tasks but does not solve the dependency download overhead, which is I/O-bound and network-bound; it would be a less effective and more costly solution.

283
MCQhard

A team uses AWS CodeBuild to run integration tests that require access to an Amazon RDS database. The database is in a private subnet. The CodeBuild project is configured to use a VPC. However, the builds are failing with a timeout connecting to the database. What could be the issue?

A.The CodeBuild project's VPC configuration does not include the subnet IDs where the database resides.
B.The security group for the CodeBuild project does not allow outbound traffic to the RDS database.
C.The security group for the RDS database does not allow inbound traffic from the security group assigned to the CodeBuild project.
D.The CodeBuild project does not have a route to the internet via an internet gateway, so it cannot reach the RDS endpoint.
AnswerC

This is the correct root cause because when CodeBuild runs in your VPC, it attaches the security group you specified to its ENI. For the build container to successfully connect to RDS, the database's security group must have an inbound rule that permits traffic on the database port from the source being the CodeBuild security group ID. If that rule is missing, all connection attempts will time out or be refused, regardless of other network configurations, making this the definitive security group misconfiguration to resolve.

Why this answer

The RDS database is in a private subnet and its security group must explicitly allow inbound traffic from the CodeBuild project's security group. Even though CodeBuild is configured with a VPC, the default security group rules deny all inbound traffic; without an inbound rule for the database port (e.g., 3306 for MySQL) from the CodeBuild security group, the connection is blocked, causing a timeout.

Exam trap

The trap here is that candidates often assume the issue is outbound traffic (Option B) or subnet configuration (Option A), but the real problem is the missing inbound rule on the database security group, which is a classic security group misconfiguration in VPC-connected services.

How to eliminate wrong answers

Option A is wrong because the CodeBuild project's VPC configuration does not need to include the subnet IDs where the database resides; it only needs to specify the VPC ID and the subnets where the build environment runs, and the database can be in a different subnet within the same VPC. Option B is wrong because security groups are stateful — if the CodeBuild project initiates outbound traffic, the return traffic is automatically allowed, so an explicit outbound rule is not required. Option D is wrong because the RDS database is in a private subnet and does not require internet access; CodeBuild can reach it via private IP within the VPC without an internet gateway.

284
MCQhard

Refer to the exhibit. A DevOps engineer deploys this CloudFormation template. The EC2 instance launches, but the httpd service does not start. The engineer connects to the instance and finds that the user data script did not run. What is the most likely cause?

A.The UserData is not base64 encoded correctly
B.The AMI does not have yum installed
C.The tags prevent user data from executing
D.The AMI uses a different init system than systemd
AnswerB

The `yum` command is specific to RPM-based distributions that use YUM as the package manager, such as older Amazon Linux (AL1/AL2) or CentOS 7. If the AMI is based on Amazon Linux 2023, which uses `dnf`, or on Ubuntu/Debian, which uses `apt`, the `yum` binary will not be present. When the UserData script runs `yum` on such an AMI, the shell returns a 'command not found' error, preventing the installation and causing the deployment to fail.

Why this answer

The most likely cause is that the AMI does not have yum installed. The CloudFormation template's UserData script uses yum to install httpd, but if the AMI is based on a distribution that does not use yum (e.g., Amazon Linux 2023 uses dnf, or Ubuntu uses apt), the script will fail silently or not execute as intended. Since the script itself is valid and the instance launched, the failure is due to the package manager not being available, preventing the httpd service from starting.

Exam trap

The trap here is that candidates often assume the issue is with base64 encoding or the init system, but the real problem is a mismatch between the package manager used in the UserData script and the one available on the AMI.

How to eliminate wrong answers

Option A is wrong because the UserData is automatically base64 encoded by CloudFormation when passed as a string in the template, so encoding is not an issue. Option C is wrong because tags do not affect the execution of user data scripts; tags are metadata and have no impact on the instance's initialization process. Option D is wrong because the init system (systemd vs.

SysVinit) does not prevent user data from running; user data scripts are executed by cloud-init, which works regardless of the init system, and the script itself does not rely on systemd commands.

285
MCQmedium

A DevOps engineer needs to automate the creation of an AWS CodeStar project for a new microservice. The engineer wants to use AWS CloudFormation to define the project and its resources. Which CloudFormation resource should be used?

A.AWS::CodeStar::Project
B.AWS::ServiceCatalog::CloudFormationProduct
C.AWS::CodePipeline::Pipeline
D.AWS::CodeBuild::Project
AnswerA

AWS::CodeStar::Project is the CloudFormation resource that directly provisions a CodeStar project, bundling the project's underlying CI/CD infrastructure (typically CodePipeline, CodeBuild, an S3 bucket, and IAM roles) into a managed unit. It also creates the CodeStar project entry that appears in the developer dashboard and supports team member management. This is the only resource among the options that represents the CodeStar project itself, rather than a single constituent service.

Why this answer

AWS::CodeStar::Project is the correct CloudFormation resource because it directly creates an AWS CodeStar project, which is a project management hub that integrates AWS services like CodeCommit, CodeBuild, CodeDeploy, and CodePipeline for continuous delivery. This resource allows you to define the project template, source repository, and other settings in a single CloudFormation stack, automating the entire CodeStar project creation.

Exam trap

The trap here is that candidates may confuse CodeStar with its underlying services (CodePipeline, CodeBuild) and select a resource that creates only a part of the CI/CD pipeline, rather than the integrated project resource that automates the entire CodeStar project setup.

How to eliminate wrong answers

Option B is wrong because AWS::ServiceCatalog::CloudFormationProduct is used to create a product in AWS Service Catalog, which is a service for creating and managing a catalog of approved IT services, not for creating a CodeStar project. Option C is wrong because AWS::CodePipeline::Pipeline creates a CodePipeline pipeline, which is a CI/CD pipeline resource, but it does not create the overarching CodeStar project that orchestrates multiple services. Option D is wrong because AWS::CodeBuild::Project creates a CodeBuild build project, which is a single build step, not the full CodeStar project that includes source, build, deploy, and pipeline orchestration.

286
Multi-Selectmedium

A DevOps engineer is managing infrastructure as code using AWS CloudFormation. The engineer wants to automatically update a stack when changes are pushed to a Git repository. Which THREE services can be used together to achieve this?

Select 3 answers
A.AWS CloudFormation
B.Amazon CloudWatch Events
C.AWS CodeBuild
D.AWS CodeCommit
E.AWS CodePipeline
AnswersA, D, E

AWS CloudFormation is the core service that declaratively provisions and updates the stack by processing the template. It manages the resource lifecycle, applies change sets, and handles rollbacks in a controlled manner, making it the essential target of the infrastructure-as-code pipeline.

Why this answer

AWS CloudFormation is the core service that manages the infrastructure as code stack. When combined with AWS CodeCommit as the Git repository and AWS CodePipeline as the CI/CD orchestrator, changes pushed to the repository trigger a pipeline that automatically updates the CloudFormation stack. CodePipeline can directly invoke CloudFormation actions (create, update, delete stacks) using its built-in deployment provider, eliminating the need for intermediate compute services.

Exam trap

The trap here is that candidates may think Amazon CloudWatch Events (EventBridge) alone can trigger stack updates, but it lacks the deployment orchestration and rollback capabilities that CodePipeline provides natively for CloudFormation.

287
MCQhard

A team uses AWS CodePipeline with multiple parallel actions in a stage. They notice that when one action fails, the entire stage fails and no further actions are attempted. They want the pipeline to continue with the remaining actions even if one fails, and then report the failure at the end. Which feature should they use?

A.Configure each action with a 'RunOrder' of 1 and set 'On failure' to 'ABORT'.
B.Configure each action with 'On failure' set to 'CONTINUE'.
C.Set the stage's 'On failure' to 'ROLLBACK'.
D.Use a custom Lambda function to catch failures and resume the pipeline.
AnswerB

Setting On failure to CONTINUE on each action is the native CodePipeline mechanism for making a parallel branch's failure non-blocking. When an action configured with CONTINUE fails, it is marked as failed but the pipeline proceeds to other actions and then to subsequent stages as long as they succeed. This allows a non-critical action (e.g., a test or scan) to fail without aborting the rest of the release process.

Why this answer

AWS CodePipeline allows you to set the 'On failure' property for each action to 'CONTINUE', which instructs the pipeline to proceed with subsequent actions even if that specific action fails. This ensures that all parallel actions in the stage are attempted, and the overall stage status reflects any failures at the end, rather than aborting immediately.

Exam trap

The trap here is that candidates may confuse the action-level 'On failure' setting with the stage-level failure behavior, or assume that a custom solution like Lambda is required when a native configuration option exists.

How to eliminate wrong answers

Option A is wrong because setting 'On failure' to 'ABORT' causes the pipeline to stop immediately when an action fails, which is the opposite of the desired behavior. Option C is wrong because setting the stage's 'On failure' to 'ROLLBACK' triggers a rollback of the entire stage upon any failure, not allowing other actions to continue. Option D is wrong because while a custom Lambda function could be used to handle failures, it is not a native feature of CodePipeline for this specific requirement; the 'CONTINUE' setting is the straightforward, built-in solution.

288
MCQeasy

A company wants to ensure that all code changes are reviewed before being merged to the main branch in AWS CodeCommit. Which feature should be enabled?

A.Configure a Lambda function to validate commits and block pushes.
B.Enable branch protection rules on the repository.
C.Create an approval rule template and associate it with the main branch.
D.Use CloudWatch Events to notify when a push occurs.
AnswerC

Create an approval rule template and associate it with the main branch to require one or more approved reviews before a pull request can be merged. The template can specify a minimum number of approvals and restrict which IAM principals can approve, and it applies automatically to every pull request targeting that branch. This is the only option that actually enforces the review gate as part of the merge workflow.

Why this answer

AWS CodeCommit does not natively support branch protection rules like GitHub or GitLab. Instead, you must create an approval rule template and associate it with the main branch to require at least one approved pull request before merging. This ensures all code changes are reviewed before being merged to the main branch.

Exam trap

The trap here is that candidates familiar with GitHub or GitLab mistakenly expect 'branch protection rules' (Option B) to exist in CodeCommit, but AWS CodeCommit requires approval rule templates instead, and the exam tests this platform-specific difference.

How to eliminate wrong answers

Option A is wrong because AWS CodeCommit does not support pre-push hooks or blocking pushes via Lambda; Lambda can only react to events asynchronously, not intercept or block a push in real time. Option B is wrong because AWS CodeCommit does not have a built-in 'branch protection rules' feature; that concept exists in GitHub and GitLab, not in CodeCommit. Option D is wrong because CloudWatch Events can notify when a push occurs but cannot enforce a review requirement before the merge; it is purely a notification mechanism.

289
MCQeasy

Refer to the exhibit. A team uses this buildspec.yml in AWS CodeBuild. The build fails because the 'dist' directory does not exist after the build phase. What is the most likely cause?

A.The build command outputs to a 'build' directory, but the artifacts base-directory is set to 'dist'.
B.The buildspec version is incorrect.
C.The Python runtime version 3.8 is not available in CodeBuild.
D.The requirements.txt file is missing from the source code.
AnswerA

The buildspec's build phase likely executes a command such as `npm run build` that writes the compiled application into a directory named `build` (the default for many frameworks like React or Vue). However, the `artifacts` section specifies `base-directory: dist`, which instructs CodeBuild to look for artifacts in the `dist` folder. Because the actual output is in `build` and `dist` either does not exist or is empty, CodeBuild fails during the artifact upload phase with a 'missing dist' error. To resolve this, you must align `base-directory` with the real build output directory.

Why this answer

The buildspec's build phase runs `python setup.py build`, which by default writes compiled output into a `build` directory at the project root (distutils/setuptools default build_base). However, the `artifacts` section specifies `base-directory: dist`, so CodeBuild looks for output in a `dist` folder that setup.py build never creates (that name is used by `setup.py sdist`/`bdist_wheel`, not the plain `build` subcommand). Because the actual output lives in `build` and `dist` is empty or missing, CodeBuild fails during artifact upload.

To fix this, either point base-directory at `build` or change the build command to produce output under `dist`.

Exam trap

The trap here is that candidates may assume the build failed due to a missing file or runtime issue, rather than recognizing the directory mismatch between the build output and the artifacts base-directory declaration.

How to eliminate wrong answers

Option B is wrong because the buildspec version (0.2) is valid and widely used; an incorrect version would cause a parsing error, not a missing directory. Option C is wrong because Python 3.8 is a standard runtime available in CodeBuild; if it were unavailable, the error would be a runtime selection failure, not a missing directory. Option D is wrong because a missing requirements.txt would cause a pip install failure during the install phase, not a missing 'dist' directory after the build phase.

290
MCQeasy

A company uses AWS CodeDeploy with a blue/green deployment configuration. The engineer wants to automatically roll back the deployment if the new instances fail the health check for 5 minutes. Which setting should the engineer configure?

A.Create a CloudWatch alarm that monitors the health check endpoint
B.Configure the deployment group to roll back when a CloudWatch alarm is triggered
C.Set the Auto Scaling group health check grace period to 5 minutes
D.Set the deployment configuration's 'timeout' to 5 minutes
AnswerB

Configuring the deployment group to roll back when a CloudWatch alarm is triggered is the correct action because CodeDeploy natively supports this as a rollback trigger. An alarm can monitor any custom metric—including a health check endpoint—and when it transitions to ALARM, CodeDeploy automatically rolls back the deployment to the last known-good revision. This mechanism directly ties the health check's failure signals to the deployment lifecycle, enabling the desired rollback behavior.

Why this answer

AWS CodeDeploy blue/green deployments can be configured to automatically roll back when a CloudWatch alarm is triggered. By creating a CloudWatch alarm that monitors the health check endpoint and associating it with the deployment group, the engineer can ensure that if the alarm state persists for 5 minutes (as defined in the alarm's period and evaluation periods), CodeDeploy will automatically initiate a rollback to the previous working version.

Exam trap

The trap here is that candidates confuse the Auto Scaling group health check grace period (which delays EC2 health checks) with the application-level health check monitoring needed for CodeDeploy rollbacks, leading them to incorrectly select Option C.

How to eliminate wrong answers

Option A is wrong because simply creating a CloudWatch alarm that monitors the health check endpoint does not cause an automatic rollback; the alarm must be associated with the deployment group's rollback configuration. Option C is wrong because the Auto Scaling group health check grace period (default 300 seconds) only delays when EC2 health checks begin, but does not trigger a CodeDeploy rollback based on application-level health check failures. Option D is wrong because the deployment configuration's 'timeout' setting controls how long CodeDeploy waits for the deployment to complete before marking it as failed, not a health-check-based rollback trigger.

291
MCQeasy

A developer wants to automatically run unit tests when a pull request is created in AWS CodeCommit. Which AWS service should be used to trigger the tests?

A.AWS CodePipeline with source polling.
B.AWS CodeBuild with webhooks from CodeCommit.
C.AWS CloudWatch Logs subscription filter for repository logs.
D.Amazon EventBridge rule for CodeCommit pull request state changes targeting AWS Lambda.
AnswerD

Amazon EventBridge natively captures CodeCommit events, including the 'CodeCommit Pull Request State Change' detail type, and invokes Lambda via an event rule. This event-driven pattern eliminates polling and reacts the moment a pull request transitions to a state such as Approved or Merged. The Lambda function can run unit tests and then post results back to the pull request, and you can optionally route results to other services like SNS for notifications.

Why this answer

Amazon EventBridge can capture CodeCommit pull request state changes (e.g., created, updated, merged) via a rule and route them to a target like AWS Lambda. The Lambda function can then invoke unit tests in response to the pull request creation event. This provides a serverless, event-driven trigger without polling or webhooks.

Exam trap

The trap here is that candidates often confuse CodeCommit webhooks (which only support push events) with EventBridge events (which support pull request state changes), leading them to incorrectly select AWS CodeBuild with webhooks.

How to eliminate wrong answers

Option A is wrong because AWS CodePipeline with source polling periodically checks the repository for changes, but it cannot directly react to a pull request creation event; it is designed for continuous delivery pipelines, not event-driven triggers for specific pull request actions. Option B is wrong because AWS CodeBuild with webhooks from CodeCommit supports triggers on push events to branches, not on pull request creation events; webhooks in CodeBuild are configured for branch or tag changes, not for pull request state changes. Option C is wrong because AWS CloudWatch Logs subscription filter for repository logs would require CodeCommit to emit logs for pull request events (which it does not by default) and is not designed to trigger actions based on repository events; it is meant for real-time log processing.

292
MCQeasy

A DevOps engineer is tasked with automating the deployment of a microservices architecture. Each service is packaged as a Docker container. The team wants to use AWS CodePipeline and AWS CodeBuild to build Docker images and push them to Amazon ECR, then deploy to Amazon ECS. What should the CodeBuild buildspec file include to push the image to ECR?

A.A call to the AWS CodeDeploy API to push the image.
B.An invocation of the AWS ECS RunTask API.
C.A buildspec phase with 'ecr-push' action.
D.Docker build and docker push commands with AWS CLI to authenticate to ECR.
AnswerD

The correct approach is to authenticate the local Docker daemon to the private ECR registry using 'aws ecr get-login-password' piped to 'docker login', then build your image with 'docker build', tag it with the ECR repository URI, and run 'docker push'. This satisfies ECR's token-based authentication and uploads Docker layers directly to the registry's S3-backed storage. It is the only way among the choices that actually moves image data into ECR.

Why this answer

To push a Docker image to Amazon ECR, the buildspec must first authenticate Docker to the ECR registry using the AWS CLI's `aws ecr get-login-password` command piped to `docker login`, then build the image with `docker build`, tag it with the ECR repository URI, and finally push it with `docker push`. CodeBuild does not have a built-in 'ecr-push' action; it relies on executing these standard Docker and AWS CLI commands in the build phases.

Exam trap

The trap here is that candidates may assume CodeBuild has a native 'ecr-push' action or that ECS APIs are involved in image pushing, when in fact the process relies on standard Docker commands and AWS CLI authentication within the buildspec.

How to eliminate wrong answers

Option A is wrong because the AWS CodeDeploy API is used for deploying applications to EC2, on-premises, or Lambda, not for pushing Docker images to ECR; pushing images is a registry operation, not a deployment action. Option B is wrong because the ECS RunTask API is used to run a standalone task in ECS, not to push images to ECR; pushing images must happen before any ECS task can reference them. Option C is wrong because CodeBuild does not have a built-in 'ecr-push' action or phase; the buildspec phases are 'install', 'pre_build', 'build', 'post_build', and custom commands must be written to perform Docker operations.

293
MCQeasy

A development team uses AWS CodeCommit for source control and AWS CodePipeline for CI/CD. They have configured a CodeBuild project that triggers on pushes to the 'develop' branch. The build runs unit tests and packages the application. However, developers report that the pipeline fails intermittently with a 'BUILD_FAILED' status due to test failures, but the tests pass locally. What is the MOST likely cause of this discrepancy?

A.The CodeBuild project is configured with a VPC that restricts access to external dependency repositories.
B.The CodePipeline has a timeout setting that causes the build to be terminated before tests complete.
C.The CodePipeline is configured with a branch filter that only triggers on the 'main' branch.
D.The CodeBuild project has different environment variables or dependency versions compared to the local environment.
AnswerD

CodeBuild executes in a managed build environment that uses a specified image (e.g., Amazon Linux with a particular JDK, Node.js, or Python version) and its own set of environment variables and pre-installed tool versions, which may differ from the developer's local machine. Dependency resolution without strict lockfiles can pull different minor or patch versions of libraries in CodeBuild than those present locally, leading to behavioral changes that break tests intermittently. Similarly, environment variables such as API endpoints, feature flags, or locale settings can alter application logic at runtime. This environmental divergence is the classic 'works on my machine' problem and directly explains why tests pass locally but intermittently fail in CodeBuild.

Why this answer

The most common cause of tests passing locally but failing in CodeBuild is environment inconsistency. CodeBuild runs in a managed environment with specific runtime versions, environment variables, and dependency caches that may differ from the developer's local machine. This discrepancy can lead to test failures due to different library versions, missing environment variables, or platform-specific behaviors.

Exam trap

The trap here is that candidates may focus on network or timeout issues (options A and B) instead of recognizing that environment inconsistency is the classic cause of 'works on my machine' failures in CI/CD pipelines.

How to eliminate wrong answers

Option A is wrong because while a VPC restriction could cause network issues, it would typically result in build failures due to dependency download errors, not test failures that pass locally. Option B is wrong because a pipeline timeout would terminate the entire build process, not cause specific test failures; the error would be 'BUILD_TIMEOUT' or similar, not 'BUILD_FAILED' with test failures. Option C is wrong because the question states the pipeline triggers on pushes to the 'develop' branch, so a branch filter for 'main' would prevent the pipeline from triggering at all, not cause intermittent failures.

294
MCQmedium

A development team is using AWS CodeCommit as a source control repository. They want to automate the creation of a new feature branch whenever a developer creates a new Jira issue with a specific label. Which AWS service should be used to listen for Jira webhooks and trigger the branch creation?

A.Amazon EventBridge to schedule a rule every minute
B.AWS Lambda with Amazon API Gateway to receive the webhook
C.AWS CodePipeline to poll for new Jira issues
D.AWS CodeBuild to run a build when a webhook is received
AnswerB

This is the correct pattern: API Gateway exposes a public HTTPS endpoint that the Jira webhook POSTs to, and API Gateway invokes a Lambda function to process the payload. The Lambda function can then validate the webhook signature, extract branch metadata, and use the AWS CodeCommit SDK (e.g., CreateBranch with the target commit ID) to perform the branch creation in real time. This serverless design gives you a low-latency, exactly-once-ish webhook receiver without needing to run persistent infrastructure.

Why this answer

AWS Lambda with Amazon API Gateway is the correct choice because API Gateway can expose a public HTTPS endpoint that Jira can send webhook POST requests to. The Lambda function then processes the incoming payload, checks for the specific label, and uses the AWS SDK to create a new branch in CodeCommit. This provides a real-time, event-driven integration without polling or scheduled checks.

Exam trap

The trap here is that candidates often confuse AWS services that can receive webhooks (API Gateway + Lambda) with services that only react to internal AWS events (EventBridge) or that require polling (scheduled rules), leading them to choose a polling-based or build-based solution that cannot directly create branches in CodeCommit.

How to eliminate wrong answers

Option A is wrong because Amazon EventBridge scheduled rules run on a fixed interval (e.g., every minute) and cannot natively receive webhooks from external services like Jira; they are designed for internal AWS events or scheduled cron jobs, not real-time HTTP callbacks. Option C is wrong because AWS CodePipeline does not have a built-in capability to poll for Jira issues; it relies on source actions (e.g., CodeCommit, S3) or webhooks for specific services (e.g., GitHub), not arbitrary issue trackers. Option D is wrong because AWS CodeBuild is a build service that runs when triggered by a webhook, but it cannot directly create a branch in CodeCommit; it is designed to execute build commands, not perform repository management actions like branch creation.

295
MCQhard

Refer to the exhibit. The above buildspec.yml is used in AWS CodeBuild. The build is failing during the 'build' phase with a 'FileNotFoundError: setup.py' error. What is the MOST likely cause?

A.The source code does not contain a setup.py file in the root directory.
B.The unit tests in the post_build phase are failing.
C.The Python version 3.8 is not supported by CodeBuild.
D.The artifacts configuration discarding paths is causing the error.
AnswerA

The build phase executes `python setup.py build`, which requires a `setup.py` file to be present in the current working directory (the root of the source checkout). If the repository lacks this file—for instance, if it uses `pyproject.toml` or is a plain script—the Python interpreter exits with `python: can't open file 'setup.py': [Errno 2] No such file or directory`, causing the build to fail. This error occurs during the build phase, so no later phases are reached.

Why this answer

The error 'FileNotFoundError: setup.py' indicates that the build process is attempting to run a command (likely `python setup.py install` or `pip install -e .`) that requires a `setup.py` file in the root directory of the source code. Since the buildspec.yml does not explicitly override the default build commands, CodeBuild uses the default build command for Python, which expects `setup.py` to be present. Option A is correct because the most likely cause is that the source code repository lacks a `setup.py` file in its root directory, causing the build phase to fail.

Exam trap

The trap here is that candidates may confuse the build phase error with post_build test failures or artifact configuration issues, but the specific 'FileNotFoundError: setup.py' message directly points to a missing source file, not a runtime or configuration problem.

How to eliminate wrong answers

Option B is wrong because the error occurs during the 'build' phase, not the 'post_build' phase; failing unit tests in post_build would not produce a 'FileNotFoundError: setup.py' error. Option C is wrong because Python 3.8 is fully supported by CodeBuild; the error is about a missing file, not an unsupported runtime version. Option D is wrong because the artifacts configuration with `discard-paths` only affects how artifacts are stored after a successful build; it does not cause a missing file error during the build phase.

296
Multi-Selectmedium

Which THREE steps are required to set up a continuous deployment pipeline using AWS CodePipeline that deploys a Docker-based application to Amazon ECS? (Choose three.)

Select 3 answers
A.Create a deploy stage that uses AWS CodeDeploy to deploy to Amazon ECS
B.Create a source stage that uses AWS CodeCommit as the source provider
C.Create a deploy stage that uses Amazon ECS as the deploy provider with an imagedefinitions.json file
D.Create an invoke stage that uses AWS Lambda to update the ECS service
E.Create a build stage that uses AWS CodeBuild to build a Docker image and push it to Amazon ECR
AnswersB, C, E

Creating a source stage with AWS CodeCommit as the source provider is required because the pipeline needs a trigger and a location for the application source code, including the Dockerfile and any build specifications. CodeCommit is the native Git repository service on AWS, and integrating it with CodePipeline allows automatic pipeline execution on every push to the configured branch. This provides version-controlled source securely within AWS, avoiding the need for external credentials or additional network access.

Why this answer

AWS CodePipeline requires a source stage to detect changes in the source code repository. AWS CodeCommit is a fully managed source control service that integrates natively with CodePipeline, allowing automatic pipeline execution when new commits are pushed to the specified branch. This is a fundamental step in establishing a continuous delivery workflow.

Exam trap

The trap here is that candidates often confuse the deploy provider options and incorrectly select AWS CodeDeploy for ECS deployments, not realizing that CodePipeline has a dedicated ECS deploy provider that uses imagedefinitions.json instead.

297
MCQmedium

A company uses AWS Elastic Beanstalk to deploy a web application. They have set up a CI/CD pipeline using AWS CodePipeline. The pipeline has a source stage from GitHub (using the GitHub source action) and a deploy stage that deploys to Elastic Beanstalk. The deployment is configured to use the 'Immutable' deployment policy. Recently, the deployment started failing with the error: 'The environment is in an unhealthy state. The deployment failed.' The developer checks the Elastic Beanstalk environment and sees that the new instances are not passing health checks. The application logs show that the new instances cannot connect to the existing Amazon RDS database. What is the most likely cause?

A.The RDS database is not available because it is being updated during the deployment.
B.The deployment policy should be changed to 'Rolling' to ensure instances are updated in place.
C.The security group attached to the Elastic Beanstalk environment does not allow the new instances to connect to the RDS database.
D.The application code has a bug that causes the health check to fail.
AnswerC

This is correct. When Elastic Beanstalk performs a deployment that replaces instances (such as an immutable or rolling update with a new Auto Scaling group), the new instances are launched with the environment's current security group. If that security group is not explicitly added as an allowed source in the RDS database's security group inbound rules, the new instances will be denied TCP (or PostgreSQL/MySQL) connections, even though the application code and database settings are unchanged. You must authorize the Elastic Beanstalk environment's security group ID (or its attached load balancer's security group) in the RDS security group to allow traffic from the latest instance replacements.

Why this answer

With the Immutable deployment policy, Elastic Beanstalk launches a fresh set of instances in a new Auto Scaling group; if those new instances cannot reach the RDS database, the most likely cause is that the environment's security group (or the RDS security group's inbound rules) does not permit the new instances to connect. Since the old instances worked, a security group rule scoped to the old instances or a missing rule for the new group is the classic culprit.

Exam trap

DOP-C02 often tests whether candidates blame the deployment policy or application code when the real issue is a security group/network rule that only manifests for newly launched instances.

How to eliminate wrong answers

Option A is wrong because an RDS maintenance window would affect all instances, not selectively block only the newly launched ones, and the error pattern points to connectivity from new instances. Option B is wrong because switching to Rolling would not fix a security group connectivity problem and Rolling updates instances in place, which is unrelated to the root cause. Option D is wrong because an application code bug would typically fail health checks regardless of deployment policy, and the logs specifically show a database connection failure, pointing to network/security configuration rather than code.

298
MCQmedium

A company uses AWS CloudFormation to manage infrastructure. The DevOps engineer wants to implement a CI/CD pipeline that builds and tests a CloudFormation template and then deploys it across multiple AWS accounts. Which combination of services should the engineer use?

A.Use CodeBuild to run cfn-lint and then use AWS Lambda to deploy stacks across accounts.
B.Use CodePipeline with separate CodeBuild projects for validation and CloudFormation deployment actions assuming IAM roles in target accounts.
C.Use CodePipeline with CodeDeploy to deploy CloudFormation stacks across accounts.
D.Use CodePipeline with a single CodeBuild project to run cfn-lint and deploy to all accounts.
AnswerB

CodePipeline natively orchestrates cross-account deployments through its CloudFormation action, which can be configured with a role ARN to assume in each target account. A dedicated CodeBuild project running cfn-lint performs static validation in an isolated build stage, while subsequent CloudFormation deployment actions use that assumed role to create or update stacks per account. This separation allows you to add manual approvals, run parallel deployments, and reuse the same artifact across accounts without embedding cloud logic in a single script.

Why this answer

It uses CodePipeline to orchestrate the CI/CD workflow, with separate CodeBuild projects for template validation (e.g., cfn-lint) and deployment actions that assume IAM roles in target accounts. This design ensures cross-account access via role assumption, which is the recommended pattern for multi-account deployments, and separates validation from deployment for better control and rollback.

Exam trap

The trap here is that candidates often confuse CodeDeploy with CloudFormation deployment actions, or assume that a single CodeBuild project can handle cross-account deployments without understanding the need for IAM role assumption and pipeline-level orchestration.

How to eliminate wrong answers

Option A is wrong because using Lambda to deploy stacks across accounts lacks the orchestration, rollback, and approval capabilities of CodePipeline, and it does not natively support cross-account IAM role assumption for deployment. Option C is wrong because CodeDeploy is designed for deploying applications (e.g., EC2, Lambda, ECS) and does not have native actions to deploy CloudFormation stacks; CloudFormation deployment actions in CodePipeline are separate. Option D is wrong because a single CodeBuild project that both validates and deploys to all accounts violates the principle of least privilege and separation of concerns, and CodeBuild cannot natively assume IAM roles in multiple target accounts without complex scripting, whereas CodePipeline actions can directly assume roles.

299
MCQeasy

A developer wants to automate the testing of a serverless application built with AWS Lambda and Amazon API Gateway. Which AWS service is best suited for running integration tests as part of a CI/CD pipeline?

A.AWS CodeDeploy
B.AWS CodeBuild
C.Amazon CloudWatch
D.AWS CloudFormation
AnswerB

AWS CodeBuild is a fully managed continuous integration service that compiles code, runs test suites, and produces build artifacts in a scalable, ephemeral environment. Its buildspec configuration can install dependencies, execute unit and integration tests against a serverless app (using frameworks like Jest or Mocha), and publish test reports to AWS services. CodeBuild integrates naturally with AWS CodePipeline, making it the correct choice for automating testing of a serverless application.

Why this answer

AWS CodeBuild is best suited for running integration tests as part of a CI/CD pipeline because it is a fully managed continuous integration service that can compile source code, run tests, and produce software packages. For a serverless application using Lambda and API Gateway, CodeBuild can execute integration tests against deployed API endpoints, validate Lambda function responses, and integrate seamlessly with other AWS developer tools like CodePipeline. It supports custom build environments and can run test frameworks (e.g., Postman/Newman, Jest) directly in the pipeline.

Exam trap

The trap here is that candidates often confuse AWS CodeBuild with AWS CodeDeploy, assuming that deployment services inherently include testing capabilities, but CodeDeploy only handles the deployment process and does not execute test scripts or validate application behavior.

How to eliminate wrong answers

Option A is wrong because AWS CodeDeploy is a deployment service that automates code deployments to compute services like EC2, Lambda, or ECS, but it does not have built-in capabilities to run integration tests or execute test scripts as part of a CI/CD pipeline. Option C is wrong because Amazon CloudWatch is a monitoring and observability service for logs, metrics, and alarms; it cannot run integration tests or execute code, making it unsuitable for automated testing in a pipeline. Option D is wrong because AWS CloudFormation is an Infrastructure as Code (IaC) service used to provision and manage AWS resources; while it can deploy the serverless application, it lacks the ability to execute integration tests or validate application behavior after deployment.

300
MCQmedium

A DevOps engineer notices that a CodePipeline execution fails at the deploy stage when deploying a Lambda function using AWS CloudFormation. The error message indicates that the stack update failed because the Lambda function's code is too large. What is the most likely cause?

A.The IAM role used by CloudFormation does not have sufficient permissions to update the Lambda function.
B.The CloudFormation template exceeds the maximum size limit for templates.
C.The artifact stored in the pipeline's S3 bucket exceeds the maximum allowed size for CodePipeline artifacts.
D.The Lambda function deployment package exceeds the maximum allowed size for Lambda.
AnswerD

Lambda enforces hard quotas on deployment package size: 50 MB for a direct .zip upload, 250 MB for a .zip uploaded from an S3 bucket, and 250 MB for the uncompressed size including layers. In a CodePipeline/CloudFormation deployment, the Lambda code is staged in S3 and then referenced by CloudFormation; if that package exceeds Lambda's 250 MB uncompressed limit, the underlying API call returns a RequestEntityTooLargeException, which exactly matches the size-related failure observed.

Why this answer

The error message explicitly states that the Lambda function's code is too large, which directly points to the Lambda deployment package exceeding the maximum allowed size. AWS Lambda has a hard limit of 50 MB for zipped direct uploads (or 250 MB for container images), and CloudFormation will fail the stack update if the package exceeds this limit during a deploy stage.

Exam trap

The trap here is that candidates may confuse CodePipeline artifact size limits (which are much larger) with Lambda deployment package size limits, or incorrectly attribute the failure to CloudFormation template size limits or IAM permissions, when the error message directly indicates the Lambda code size is the issue.

How to eliminate wrong answers

Option A is wrong because insufficient IAM permissions would produce an 'access denied' or 'unauthorized' error, not a 'code is too large' error. Option B is wrong because CloudFormation template size limits (1 MB for templates, 51,200 bytes for parameters) are unrelated to the Lambda function code size; the error is about the function's code, not the template. Option C is wrong because CodePipeline artifact size limits (default 2 GB per artifact) are much larger than Lambda's code size limit, and the error message specifically mentions the Lambda function's code, not the pipeline artifact.

← PreviousPage 4 of 5 · 316 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Sdlc Automation questions.