Courseiva

CCNA SDLC Automation Questions

75 of 316 questions · Page 1/5 · SDLC Automation · Answers revealed

1
MCQeasy

A team uses AWS CloudFormation to manage infrastructure. They want to deploy a stack that creates an S3 bucket and a DynamoDB table. The S3 bucket name must be unique across all AWS accounts. Which CloudFormation intrinsic function should be used to generate a unique bucket name?

A.!Ref 'AWS::StackName'
B.!GetAtt S3Bucket.Arn
C.!Sub 'mybucket-${AWS::AccountId}'
D.!Select [0, !Split ['-', !Ref 'AWS::Region']]
AnswerC

AWS::AccountId is a true pseudo parameter that is resolved during template evaluation, providing a unique, numeric identifier for the current AWS account. When combined with a fixed prefix like 'mybucket-', the resulting bucket name is globally unique across all accounts and regions because each account has a distinct ID, satisfying S3's global namespace requirement. This approach is deterministic, readable, and avoids the circular dependency issues of resource attributes, making it a widely adopted best practice for naming resources.

Why this answer

The `!Sub 'mybucket-${AWS::AccountId}'` intrinsic function substitutes the AWS::AccountId pseudo parameter, which is guaranteed to be unique per AWS account. Since S3 bucket names must be globally unique across all AWS accounts, appending the account ID ensures the generated name does not conflict with buckets in other accounts. This approach is a common pattern for creating unique resource names in CloudFormation.

Exam trap

The trap here is that candidates may think `!Ref 'AWS::StackName'` or `!Ref 'AWS::Region'` provide sufficient uniqueness, but they overlook the requirement for global uniqueness across all AWS accounts, which only `AWS::AccountId` guarantees.

How to eliminate wrong answers

Option A is wrong because `!Ref 'AWS::StackName'` returns the name of the CloudFormation stack, which is not guaranteed to be unique across AWS accounts—multiple accounts can have stacks with the same name. Option B is wrong because `!GetAtt S3Bucket.Arn` returns the Amazon Resource Name of the S3 bucket, which is only available after the bucket is created, and cannot be used to generate a name before creation. Option D is wrong because `!Select [0, !Split ['-', !Ref 'AWS::Region']]` extracts the first part of the region name (e.g., 'us' from 'us-east-1'), which is not unique across accounts or even across regions within the same account.

2
MCQhard

A company runs a critical e-commerce application on AWS. They use AWS CodePipeline to manage deployments. The pipeline has a source stage (CodeCommit), a build stage (CodeBuild), and a deploy stage (CodeDeploy to an Auto Scaling group). Recently, a deployment caused a 5-minute outage because the new application version had a bug that caused the health checks to fail. The Auto Scaling group marked instances as unhealthy and replaced them, but during the replacement, traffic was routed to the remaining instances, which also failed health checks, causing a full outage. The company wants to implement a deployment strategy that prevents any traffic from being routed to unhealthy instances and automatically rolls back if the deployment fails. They also want to minimize deployment time and cost. Which solution should the DevOps team implement?

A.Add a manual approval step in CodePipeline before deploy
B.Use CodeDeploy in-place deployment with automatic rollback enabled
C.Use CodeDeploy blue/green deployment with automatic rollback enabled
D.Increase the health check grace period in the Auto Scaling group
AnswerC

Blue/green shifts traffic to a new fleet only after it passes health checks, so no traffic reaches unhealthy instances, and CodeDeploy automatic rollback reverts on failure. This satisfies the zero-traffic-to-unhealthy-instances and automatic rollback constraints while avoiding full in-place replacement cost.

Why this answer

The correct solution is to use a blue/green deployment with CodeDeploy and automatic rollback enabled. In a blue/green deployment, a new Auto Scaling group (green) is created alongside the existing one (blue). Traffic is shifted to the green group only after all health checks pass.

If health checks fail, the deployment is automatically rolled back by terminating the green group, ensuring no traffic is routed to unhealthy instances. This prevents any outage. Option B (in-place deployment with rollback) updates instances in place, which can cause downtime if instances fail health checks, as the Auto Scaling group replaces them sequentially, potentially routing traffic to unhealthy instances.

Option A (manual approval) slows down deployment and does not automate rollback based on health checks. Option D (increasing health check grace period) only delays detection of failures and does not prevent traffic from being routed to unhealthy instances.

3
MCQeasy

A company uses AWS CodePipeline to automate the deployment of a static website hosted on Amazon S3. The pipeline includes a source stage that pulls from a CodeCommit repository and a deploy stage that uses CodeBuild to sync the files to an S3 bucket. The team noticed that the website is not updating after a successful pipeline run. The CodeBuild logs show that the 'aws s3 sync' command completed successfully. However, the website still shows the old content. What is the MOST likely cause?

A.The CodeBuild project does not have permission to write to the S3 bucket.
B.The S3 bucket is not configured for static website hosting.
C.The website is fronted by Amazon CloudFront, which is caching the old content.
D.The S3 bucket policy is blocking public access to the updated objects.
AnswerC

When CloudFront fronts an S3 static website, edge locations serve cached objects until they expire or are invalidated. CodePipeline's S3 sync updates the origin, but CloudFront does not automatically know about those changes; it continues returning the old objects as long as they remain in the cache. To serve the new content, you must create a CloudFront invalidation for the changed paths (e.g., /*) or use versioned filenames to bypass the cache. This directly matches the symptom of a successful deployment that still shows stale content in the browser.

Why this answer

The most likely cause is that Amazon CloudFront is caching the old content at edge locations. Even though CodeBuild successfully synced new files to S3, CloudFront continues to serve cached objects until the TTL expires or an invalidation is created. The pipeline must include a CloudFront invalidation step (or use versioned object keys) to force edge locations to fetch the updated content.

Exam trap

DOP-C02 often tests the trap that a successful S3 sync means the website is updated, ignoring CloudFront caching, so candidates blame IAM or bucket policies instead of the CDN layer.

How to eliminate wrong answers

Option A is wrong because the CodeBuild logs show 'aws s3 sync' completed successfully, which means the IAM permissions allowed the write; a permission failure would have produced an AccessDenied error. Option B is wrong because if static website hosting were not configured, the website would not load at all, not show old content. Option D is wrong because a bucket policy blocking public access would cause 403 errors for new objects, not stale content; also, the old content is still being served, indicating the objects are reachable.

4
MCQeasy

A company uses AWS CloudFormation to manage a stack that includes an Amazon SQS queue. The queue name must be unique. The developer wants to define the queue name in the CloudFormation template. Which intrinsic function should be used to generate a unique name?

A.Fn::Sub
B.Fn::Select
C.AWS::NoValue
D.Fn::GetAtt
AnswerA

Fn::Sub is the correct choice because it performs variable and pseudo-parameter substitution on a string literal, allowing you to embed ${AWS::StackName} and other pseudo parameters like ${AWS::AccountId} directly into a bucket name. This creates a predictable, globally unique S3 bucket name that is automatically tied to the stack, eliminating the need to hardcode a name and reducing the risk of collisions when the stack is deployed in multiple environments.

Why this answer

A is correct because `Fn::Sub` can embed a pseudo parameter like `AWS::StackName` or `AWS::AccountId` into a string to generate a unique queue name. By using `Fn::Sub` with a reference to the stack name or a random string, you can create a name that avoids collisions across accounts or regions, satisfying the uniqueness requirement for SQS queue names.

Exam trap

The trap here is that candidates confuse `Fn::GetAtt` (which retrieves attributes like ARN or URL) with the ability to generate a unique name, but `Fn::GetAtt` cannot create or modify a name string—it only reads existing resource properties.

How to eliminate wrong answers

Option B is wrong because `Fn::Select` returns a single element from a list based on an index, which does not generate or modify a string to ensure uniqueness. Option C is wrong because `AWS::NoValue` is used to conditionally omit a property from a template, not to produce a unique name. Option D is wrong because `Fn::GetAtt` retrieves an attribute value from a resource (e.g., the ARN of an SQS queue), but it cannot generate a unique name; it only returns existing attributes of already-created resources.

5
MCQhard

A company uses AWS CodeBuild to compile and test their Java application. The build takes about 20 minutes. They have enabled Amazon S3 cache to store the Maven repository to speed up subsequent builds. However, they notice that the build time has not improved significantly. The buildspec file includes the 'cache' section with 'paths' pointing to '/root/.m2'. The CodeBuild project has cache type set to 'S3' and a valid bucket. The build logs show that the cache is being downloaded and uploaded, but the Maven dependencies are still being downloaded from the internet each time. What is the most likely cause?

A.The cache is too large and takes as long to download as the build itself.
B.The S3 bucket is in a different region than the CodeBuild project.
C.The buildspec file does not include the 'cache' section correctly.
D.The Maven dependencies are not being stored in the local repository path specified in the cache.
AnswerD

If the Maven local repository is overridden (e.g., via a custom settings.xml, the -Dmaven.repo.local flag, or a different user's home directory), the path declared in CodeBuild's cache section will not contain the downloaded dependencies. The build will then re-download artifacts every time because the restore phase puts files into a location Maven never reads. The fix is to ensure the cache path exactly matches the effective local repository path used by the Maven build.

Why this answer

The cache is being downloaded and uploaded, but Maven still fetches dependencies from the internet, which means the dependencies are not actually landing in /root/.m2 during the build. This typically happens when the build runs as a non-root user (e.g., the CodeBuild default user), so Maven writes to a different local repository path such as /home/codebuild/.m2 or a path defined by settings.xml. The cache section is syntactically correct, so the fix is to align the cached path with the actual Maven local repository location.

Exam trap

The trap is assuming the cache section is misconfigured when the logs prove it is working — the real issue is a path mismatch between the cached directory and Maven's actual local repository.

How to eliminate wrong answers

Option A is wrong because the logs show the cache is being downloaded and uploaded successfully, and a 20-minute Java build's Maven cache is typically tens to low hundreds of MB — not large enough to negate the benefit. Option B is wrong because CodeBuild S3 cache works cross-region; a region mismatch would cause cache upload/download failures, not silent re-downloads of Maven dependencies. Option C is wrong because the question states the buildspec includes the cache section with paths pointing to /root/.m2, and the logs confirm cache activity — so the section is present and functional.

6
Multi-Selecthard

Which THREE factors should be considered when designing a deployment strategy using AWS CodeDeploy to minimize downtime during updates? (Choose three.)

Select 3 answers
A.Configure a load balancer to deregister instances before deployment.
B.Use a blue/green deployment to switch traffic instantly.
C.Use canary deployments to shift traffic gradually.
D.Deploy to all instances simultaneously to reduce total time.
E.Use the same instance type for all instances.
AnswersA, B, C

Deregistering instances from the load balancer before deployment engages connection draining, allowing in-flight requests to finish before the instance is stopped. Combined with health check grace periods, users never reach a terminating instance, preventing 5xx errors and dropped connections during rolling or batch replacements. This is the core of a zero-downtime rolling update.

Why this answer

Deregistering instances from a load balancer before deployment ensures that traffic is not routed to instances that are being updated, preventing downtime during the deployment process. AWS CodeDeploy integrates with Elastic Load Balancing to automatically deregister instances, wait for in-flight requests to complete, and then register them back after the deployment succeeds.

Exam trap

The trap here is that candidates may think deploying to all instances simultaneously (Option D) reduces total time and thus minimizes downtime, but they overlook that without traffic management, this approach can cause complete service interruption during the update window.

7
MCQmedium

A company uses AWS CodePipeline with a GitHub source action. The pipeline is configured to trigger on changes to the main branch. After a recent commit, the pipeline did not trigger. The DevOps engineer verified that the webhook is configured correctly and the IAM role has the necessary permissions. What is the most likely cause?

A.The GitHub personal access token used for authentication has expired.
B.The pipeline is set to manual execution only.
C.The source action's branch filter is set to a different branch.
D.The GitHub webhook endpoint URL is incorrect.
AnswerA

The PAT is the credential CodePipeline uses to authenticate to GitHub for API calls, including the initial webhook registration and every source-revision lookup (e.g., GetCommit, ListCommits). When the token expires, CodePipeline receives 401/403 responses, so webhook events cannot be processed successfully and the Source stage fails or is skipped, which matches the observed post-push behavior.

Why this answer

The most likely cause is that the GitHub personal access token used for authentication has expired. CodePipeline uses this token to authenticate with GitHub and trigger the webhook; when the token expires, GitHub rejects the webhook call, preventing the pipeline from starting even though the webhook configuration and IAM permissions are correct.

Exam trap

The trap here is that candidates may focus on webhook configuration or IAM permissions, overlooking that the GitHub personal access token is a separate authentication mechanism that can expire independently of the webhook setup.

How to eliminate wrong answers

Option B is wrong because if the pipeline were set to manual execution only, it would never trigger automatically, but the question states the pipeline is configured to trigger on changes to the main branch, implying automatic execution is expected. Option C is wrong because the branch filter is explicitly set to the main branch, and the DevOps engineer verified the webhook is configured correctly; a different branch filter would prevent triggering only if the commit were to a different branch, but the commit was to main. Option D is wrong because the engineer verified the webhook is configured correctly, which includes the endpoint URL; an incorrect URL would be a configuration error that would have been caught during verification.

8
MCQmedium

A company is using AWS CodeDeploy to deploy a web application to an Auto Scaling group. The deployment fails with the error 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available, or some instances in your deployment group are experiencing problems.' The deployment configuration uses a linear traffic shifting with a 10-minute interval. The application logs show that the new version of the application crashes on startup. What is the MOST effective way to handle this situation to ensure successful future deployments?

A.Increase the interval in the linear traffic shifting to 30 minutes to allow more time for instances to stabilize.
B.Configure the deployment to automatically roll back when a failure occurs and ignore the error.
C.Switch to a blue/green deployment strategy to minimize the impact on existing instances.
D.Add a script in the AppSpec file's 'Validate Service' lifecycle hook to check the application health and fail the deployment if the application does not start successfully.
AnswerD

Adding a script to the ValidateService lifecycle hook is the correct solution because this hook executes after ApplicationStart and is designed to verify application readiness. When the script detects that the application did not start successfully—for example, it curls a local endpoint or checks the listening port—it returns a nonzero exit code, causing CodeDeploy to fail the deployment immediately. This check ensures unhealthy instances are identified before any production traffic is shifted, preventing user-facing outages and allowing you to fix the root cause.

Why this answer

The 'Validate Service' lifecycle hook in the AppSpec file runs after the application is installed and started, allowing you to execute a custom script that verifies the application is healthy. If the script detects that the new version crashes on startup, it can return a non-zero exit code, which causes CodeDeploy to mark that instance as failed and trigger the deployment failure. This provides an early, automated validation that prevents the deployment from proceeding with a broken application, directly addressing the root cause of the crash.

Exam trap

The trap here is that candidates often confuse recovery mechanisms (like rollback or blue/green) with prevention mechanisms, failing to realize that the most effective solution is to catch the failure early using the ValidateService lifecycle hook, which directly validates application health before traffic is shifted.

How to eliminate wrong answers

Option A is wrong because increasing the linear traffic shifting interval to 30 minutes does not fix the underlying issue of the application crashing on startup; it only delays the inevitable failure and wastes time. Option B is wrong because configuring automatic rollback is a recovery mechanism, not a prevention strategy, and ignoring the error would mask the problem, leading to repeated failures without addressing the root cause. Option C is wrong because switching to a blue/green deployment strategy does not prevent the new application version from crashing; it only isolates the impact on existing instances, but the deployment would still fail if the new version is broken.

9
MCQhard

Refer to the exhibit. A developer is troubleshooting a failed AWS CodeBuild build. The buildspec file contains the following build commands: 'pre_build' - run linting, 'build' - './gradlew build', 'post_build' - package artifact. The error occurs in the build phase. Which of the following is the MOST likely cause?

A.The Gradle build encountered compilation or test errors.
B.The build environment ran out of disk space.
C.The artifact packaging step failed.
D.The linting step failed.
AnswerA

The failing command `./gradlew build` invokes Gradle's primary lifecycle task, which compiles all production and test sources and then executes the test suite. Any compilation error or failed test causes Gradle to abort with a non-zero exit code (typically 1), producing a 'BUILD FAILED' status. Since this failure occurs in the `build` phase and the exit code originates from the Gradle process itself, this is the direct and correct explanation.

Why this answer

The error occurs in the build phase, which executes './gradlew build'. Gradle's build task compiles source code and runs tests by default. If compilation fails or tests fail, Gradle exits with a non-zero exit code, causing AWS CodeBuild to mark the build phase as failed.

The error message in the build logs would typically show compilation errors or test failures.

Exam trap

The trap here is that candidates may confuse the phase in which each command runs (pre_build, build, post_build) and attribute the error to a step that executes in a different phase, rather than recognizing that the error occurs specifically in the build phase where './gradlew build' runs.

How to eliminate wrong answers

Option B is wrong because disk space exhaustion would typically cause a different error (e.g., 'No space left on device') and would likely affect all phases, not just the build phase. Option C is wrong because the artifact packaging step runs in the post_build phase, which occurs after the build phase; if the build phase fails, post_build never executes. Option D is wrong because linting runs in the pre_build phase; if linting failed, the error would occur in pre_build, not build.

10
MCQhard

A company uses AWS CodeBuild to run builds for a Java application. The buildspec includes a 'mvn test' command. The build succeeds but the tests fail. The team wants to fail the build if any test fails. What should they do?

A.Add a 'post_build' phase that fails the build if tests fail.
B.Add a 'test' phase in the buildspec before the 'build' phase.
C.Ensure the buildspec's 'build' phase includes the test command and that the command returns a non-zero exit code on failure.
D.Configure the build project to use batch builds.
AnswerC

The correct approach is to run the test command (for example, mvn test or gradle test) inside the build phase of the buildspec. CodeBuild executes each command in a shell where a non-zero exit code causes that phase to be marked failed and the overall build to be FAILED. Because Maven/Gradle test goals already return non-zero when tests fail, this single change ensures the build pipeline stops immediately. Any subsequent build phases, such as post_build artifact packaging, still run, but the final build status will reflect the failure.

Why this answer

CodeBuild determines build success or failure based on the exit code of commands in the buildspec. The 'mvn test' command returns a non-zero exit code when tests fail, which causes the build to fail if placed in the 'build' phase. By ensuring the test command is in the 'build' phase and not suppressed (e.g., with '|| true'), the build will fail on test failure.

Exam trap

The trap here is that candidates confuse the 'post_build' phase with a phase that can retroactively fail the build, or invent a 'test' phase that does not exist in CodeBuild's buildspec schema.

How to eliminate wrong answers

Option A is wrong because the 'post_build' phase runs after the 'build' phase and does not affect the build's final status; it is intended for cleanup or notifications, and commands there cannot retroactively fail a build that already succeeded. Option B is wrong because the 'test' phase does not exist in CodeBuild's buildspec schema; valid phases are 'install', 'pre_build', 'build', and 'post_build'. Option D is wrong because batch builds are used to run multiple builds concurrently or sequentially, not to change how individual build phases handle exit codes or test failures.

11
MCQmedium

Refer to the exhibit. A DevOps engineer ran the above AWS CLI command after a CloudFormation stack update. What does the status 'ROLLBACK_COMPLETE' indicate?

A.The stack update is in progress.
B.The stack was deleted successfully.
C.The stack was created successfully.
D.The stack update failed and CloudFormation reverted to the previous stack.
AnswerD

When an update operation fails, CloudFormation automatically initiates a rollback to the stack's previous template and resources, and ROLLBACK_COMPLETE is the final state after that restoration finishes. The stack is still present and functional from its prior state, but the attempted changes were discarded. This is the only status in the output that matches both the 'update' command and the terminal rollback outcome, so it directly confirms a failed update followed by a rollback.

Why this answer

The 'ROLLBACK_COMPLETE' status indicates that the CloudFormation stack update operation failed, and CloudFormation automatically reverted the stack to its previous stable state. This is a built-in safety mechanism: if any resource fails to update, CloudFormation triggers a rollback to undo all changes made during the update, ensuring the stack returns to its last known good configuration.

Exam trap

The trap here is that candidates confuse 'ROLLBACK_COMPLETE' with a successful operation or a deletion, when in fact it specifically means the update failed and the stack was reverted to its prior state.

How to eliminate wrong answers

Option A is wrong because 'ROLLBACK_COMPLETE' is a terminal state, not an in-progress state; an update in progress would show 'UPDATE_IN_PROGRESS' or 'UPDATE_ROLLBACK_IN_PROGRESS'. Option B is wrong because a successful deletion would show 'DELETE_COMPLETE', not 'ROLLBACK_COMPLETE'. Option C is wrong because a successful creation would show 'CREATE_COMPLETE', not 'ROLLBACK_COMPLETE'.

12
MCQhard

Refer to the exhibit. A CodePipeline deployment fails at the CloudFormation stage. The Lambda function creation is cancelled. What is the MOST likely cause?

A.The buildspec.yml file contains an invalid command.
B.The Lambda function is configured in a VPC without a NAT gateway or VPC endpoints, causing deployment timeout.
C.The Lambda function's execution role lacks permissions to create ENIs.
D.The CodeCommit branch is not configured correctly in the pipeline.
AnswerC

If the Lambda execution role were missing ec2:CreateNetworkInterface or related ENI permissions, the Lambda service would fail to create an elastic network interface during function initialization, producing a different error such as 'InvalidParameterValueException' or a resource creation failure. This would prevent the function from running at all, rather than causing a timeout on the deployment's wait condition. Since the observed failure is a timeout, the role likely has the required ENI permissions, but the network route is missing.

Why this answer

When a Lambda function is configured in a VPC, the Lambda service must create an Elastic Network Interface (ENI) in the VPC on behalf of the function. The function's execution role must have permissions for ec2:CreateNetworkInterface, ec2:DescribeNetworkInterfaces, and ec2:DeleteNetworkInterface. Without these permissions, the Lambda service cannot create the ENI, and the Lambda function creation fails.

A missing NAT gateway or VPC endpoints only affects internet access for the running function, not the creation process. Therefore, Option C is the correct answer.

Exam trap

The trap is that candidates often attribute the failure to a lack of internet access (NAT gateway/VPC endpoints) or to the buildspec, but the actual cause is that the Lambda execution role is missing the required EC2 permissions to create network interfaces inside the VPC.

How to eliminate wrong answers

Option A is wrong because the buildspec.yml file is used in the CodeBuild stage, not the CloudFormation stage; an invalid command would cause a CodeBuild failure, not a CloudFormation deployment failure. Option C is wrong because the Lambda function's execution role lacking permissions to create ENIs would cause a different error, such as 'EC2 access denied' or 'Failed to create ENI', not a generic timeout or cancellation during CloudFormation deployment. Option D is wrong because a misconfigured CodeCommit branch would cause the pipeline to fail at the source stage, not at the CloudFormation stage.

13
Multi-Selectmedium

A DevOps engineer is designing a CI/CD pipeline for a Python application using AWS CodeBuild and AWS CodeDeploy. The application is deployed to an Auto Scaling group of EC2 instances. The engineer wants to ensure that the deployment does not impact availability. Which TWO strategies can be used? (Choose 2.)

Select 2 answers
A.In-place deployment with a large batch size.
B.Rolling deployment with a small batch size.
C.Immutable deployment.
D.Blue/green deployment.
E.Canary deployment.
AnswersB, D

Rolling deployment with a small batch size updates only a handful of instances at a time while the rest of the fleet continues serving live traffic, so the application remains available throughout the pipeline. AWS CodeDeploy moves the entire ASG to the new revision in incremental batches, and it uses health checks to verify each batch before proceeding; if a batch fails, the deployment is halted and can be rolled back. This is the correct choice when you need a zero-downtime update on an Auto Scaling group.

Why this answer

Rolling deployment with a small batch size (Option B) updates a limited number of instances at a time, ensuring that the majority of the Auto Scaling group remains available throughout the deployment. Blue/green deployment (Option D) creates a separate, fully-provisioned environment (green) and switches traffic to it only after validation, which eliminates downtime during the cutover. Both strategies directly preserve application availability by avoiding full-scale disruption.

Exam trap

The trap here is that candidates confuse 'canary' (a traffic-shifting pattern for Lambda/ECS) with 'rolling' (an instance-by-instance update for EC2), or incorrectly assume immutable deployment is available in CodeDeploy for Auto Scaling groups, when it is not a supported deployment type in that service.

14
Multi-Selecthard

A company uses AWS CodePipeline with multiple stages: Source (CodeCommit), Build (CodeBuild), Test (CodeBuild), and Deploy (CodeDeploy to EC2). The Test stage runs integration tests that require network access to a private database in a VPC. The CodeBuild project is configured to use a VPC. However, the Test stage fails intermittently with timeout errors. Which TWO actions would MOST likely resolve the issue? (Choose 2)

Select 2 answers
A.Remove the VPC configuration from the CodeBuild project and use a public subnet instead.
B.Increase the timeout for the Test stage in the CodeBuild project to accommodate network delays.
C.Ensure the CodeBuild project's VPC configuration includes a NAT gateway for internet access.
D.Use a larger compute type for the CodeBuild project to improve network performance.
E.Configure the security group for the CodeBuild project to allow outbound traffic to the database security group on the required port.
AnswersB, C

Increasing the Test stage timeout in the CodeBuild project is a pragmatic mitigation when network congestion intermittently causes dependencies or database connections to be slower than the default limit. CodeBuild has a default timeout of 60 minutes for a build, but the pipeline's stage timeout may be shorter, and network retries during peak usage can push a stage over its configured limit without an underlying configuration error. This accommodates transient network delays rather than masking a permanent misconfiguration, making it a valid, if not root-cause, fix.

Why this answer

The intermittent timeout errors suggest that the Test stage's integration tests are occasionally taking longer than the configured timeout. Increasing the timeout accommodates these delays, preventing premature failures. Option C is correct because a NAT gateway is required for CodeBuild in a VPC to access resources outside the VPC, such as the private database, if the database is in a different subnet or requires internet-routable traffic.

Exam trap

The trap here is that candidates may focus on security group rules (Option E) as the primary fix, but the intermittent nature of the timeout points to network path delays or missing NAT gateway, not a static misconfiguration.

15
Multi-Selectmedium

Which TWO actions should a DevOps engineer take to implement a CI/CD pipeline that automatically deploys a containerized application to Amazon ECS using AWS CodePipeline and AWS CodeBuild? (Choose TWO.)

Select 2 answers
A.Use AWS CloudFormation to deploy the ECS service
B.Use AWS CodeDeploy to deploy the container to ECS with a blue/green deployment
C.Store the Docker image in AWS CodeCommit
D.Use CodeBuild to build the Docker image and push it to Amazon ECR
E.Configure CodePipeline to use Amazon ECR as a source for the container image
AnswersD, E

CodeBuild should be used to build the Docker image because it can execute a buildspec that runs 'docker build' and then uses 'aws ecr put-image' or 'docker push' to store the image in ECR. This step is the pipeline's build stage, converting source code into an immutable container artifact tagged with a version or commit hash. Without this action, the pipeline would have no image to deploy, making it the essential first of the two required actions.

Why this answer

AWS CodeBuild can be configured to build the Docker image from source code and then push it to Amazon ECR using the `post_build` phase with commands like `docker push`. This is a standard pattern for containerized CI/CD pipelines, as ECR serves as the private registry for storing and versioning container images. Option E is correct because CodePipeline can use Amazon ECR as a source action, which triggers the pipeline automatically when a new image is pushed to the specified repository, enabling continuous deployment to ECS.

Exam trap

The trap here is that candidates often confuse the role of CodeDeploy (which is for EC2/on-premises deployments) with ECS deployment mechanisms, or mistakenly think CodeCommit can store Docker images instead of source code, leading them to select options B or C.

16
Multi-Selecteasy

A company uses AWS CodeCommit for source control. Developers need to automatically run tests on every push to a feature branch, but only if the push includes changes to the 'src/' directory. Which TWO AWS services can be used together to achieve this?

Select 2 answers
A.Amazon CloudWatch Logs
B.AWS CodePipeline
C.AWS CodeDeploy
D.AWS Lambda
E.AWS CodeBuild
AnswersB, D

AWS CodePipeline is a fully managed continuous delivery service that can be configured with CodeCommit as a source action, automatically detecting new commits and triggering the pipeline execution. It supports path filters in the source action (e.g., requiring changes only in a specific folder) to avoid unnecessary runs. This makes it the native, event-driven orchestration service to start automated tests (via a CodeBuild build stage) exactly when developers push code.

Why this answer

AWS CodePipeline can be configured to trigger a pipeline execution when a push occurs to a specific branch in CodeCommit, and it supports path-based filtering using the 'PathFilter' condition in the source action. By combining CodePipeline with AWS Lambda, you can run custom validation logic (e.g., checking if changes are within the 'src/' directory) before invoking further actions like tests. This pair allows you to conditionally run tests only when the push includes changes to 'src/'.

Exam trap

The trap here is that candidates often assume AWS CodeBuild alone can handle event-driven triggers with path filtering, but it requires an orchestrator like CodePipeline or a Lambda-based custom trigger to implement conditional execution based on directory changes.

17
MCQhard

A company runs a microservices architecture on Amazon ECS with Fargate launch type. Each microservice is deployed using AWS CodePipeline with a source stage from CodeCommit, a build stage in CodeBuild, and a deploy stage that updates the ECS service. The team wants to implement a blue/green deployment strategy to reduce downtime and enable quick rollbacks. Which combination of AWS services and configurations should be used?

A.Use AWS CloudFormation with a 'DeploymentPreference' set to 'BlueGreen' for the ECS service.
B.Use AWS CodeDeploy with a deployment group configured for blue/green deployment, and an Application Load Balancer (ALB) to shift traffic between the blue and green target groups.
C.Use the ECS service's built-in rolling update with a 'minimumHealthyPercent' of 100 and 'maximumPercent' of 200.
D.Configure the ECS service with an 'AutoScaling' policy that replaces instances gradually.
AnswerB

AWS CodeDeploy natively supports blue/green deployments for ECS services when integrated with an Application Load Balancer. During deployment, CodeDeploy registers the new task set with a 'green' target group while the existing 'blue' task set remains registered with the original target group; the ALB listener's traffic is then shifted from blue to green using either a canary, linear, or all-at-once traffic-shifting configuration. CodeDeploy also runs lifecycle hooks (BeforeInstall, AfterInstall, etc.) and preserves the original task set for instant rollback if the deployment fails. This is the only option that provides immutable infrastructure and controlled traffic shifting, making it the correct answer.

Why this answer

AWS CodeDeploy natively supports blue/green deployments for Amazon ECS (Fargate) by orchestrating traffic shifting between two target groups behind an Application Load Balancer (ALB). This allows the new task set (green) to be validated before production traffic is fully shifted, and enables instant rollback by reverting traffic to the original (blue) target group. CodePipeline can integrate CodeDeploy as a deploy action to automate this workflow.

Exam trap

The trap here is that candidates confuse the ECS rolling update configuration (minimumHealthyPercent/maximumPercent) with a blue/green strategy, but rolling updates do not provide separate target groups or instant rollback, which are key requirements for the scenario.

How to eliminate wrong answers

Option A is wrong because AWS CloudFormation does not support a 'DeploymentPreference' property set to 'BlueGreen' for ECS services; CloudFormation's 'DeploymentController' only supports 'ECS' (rolling update) or 'EXTERNAL' (external deployment), and blue/green for ECS requires CodeDeploy. Option C is wrong because setting 'minimumHealthyPercent' to 100 and 'maximumPercent' to 200 still performs a rolling update, not a blue/green deployment; it replaces tasks incrementally without maintaining two separate environments for traffic shifting, and does not support instant rollback. Option D is wrong because ECS Auto Scaling policies adjust the desired count of tasks based on metrics (e.g., CPU/memory) and do not implement deployment strategies; they cannot shift traffic between distinct task sets or provide blue/green rollback capabilities.

18
MCQmedium

A DevOps team is designing a deployment pipeline for a microservices application on Amazon ECS using AWS CodePipeline. They want to implement a canary deployment strategy where a small percentage of traffic is routed to the new version before fully promoting it. Which AWS service or feature should they use to achieve this?

A.Amazon ECS Service Auto Scaling
B.AWS CodeDeploy with ECS blue/green deployment
C.Amazon Route 53 weighted routing
D.AWS App Mesh with traffic shifting
AnswerB

AWS CodeDeploy with ECS blue/green deployment is the native AWS service that performs canary traffic shifting for an ECS service. It creates a replacement task set from a new task definition, shifts traffic through load balancer target group weights (for example, 10 percent initially), waits a specified interval, and then shifts the remaining traffic after validation. It also supports lifecycle hooks, CloudWatch alarm rollback, and automatic cleanup of the old task set, making it the complete answer for a canary deployment.

Why this answer

AWS CodeDeploy with ECS blue/green deployment is the correct choice because it natively supports canary traffic shifting for Amazon ECS services. When integrated with AWS CodePipeline, CodeDeploy can route a small percentage of traffic (e.g., 10%) to the new task set, monitor it with CloudWatch alarms, and then automatically shift the remaining traffic after a specified interval. This is the only option that directly provides the canary deployment lifecycle within the ECS and CodePipeline context.

Exam trap

The trap here is that candidates often confuse Route 53 weighted routing (which operates at the DNS level and cannot shift traffic within a single ECS service) with the application-level traffic shifting needed for canary deployments, or they assume App Mesh is required when CodeDeploy already provides the native integration.

Why the other options are wrong

A

Auto Scaling adjusts the number of tasks, not traffic shifting between versions.

C

Route 53 can distribute traffic across multiple endpoints, but it's not the native way for ECS service deployments.

D

App Mesh provides traffic splitting, but ECS natively integrates with CodeDeploy for canary deployments.

19
Multi-Selectmedium

Which THREE actions should a DevOps team take to ensure a CI/CD pipeline using AWS CodePipeline is secure? (Choose three.)

Select 3 answers
A.Require multi-factor authentication (MFA) for pipeline executions.
B.Use AWS KMS to encrypt artifacts in the pipeline.
C.Use AWS CodePipeline with a customer-managed S3 bucket for artifacts and restrict bucket access.
D.Enable pipeline-level IAM permissions to restrict who can modify the pipeline.
E.Enable AWS CloudTrail to log pipeline executions.
AnswersB, C, D

AWS KMS encryption for artifacts ensures that every source zip, build output, and deployment package stored in CodePipeline’s artifact bucket is encrypted with a customer-managed key using SSE-KMS (envelope encryption). This gives you granular control over who can decrypt artifacts via kms:Decrypt permissions on the key, and it provides a tamper-evident audit trail of key usage through AWS CloudTrail. Unlike default AWS-managed S3 encryption, a customer-managed KMS key lets you enforce key rotation, define cross-account access rules, and revoke access immediately in response to a threat, which directly protects sensitive artifacts at rest and during transit.

Why this answer

AWS CodePipeline can use AWS KMS customer-managed keys (CMKs) to encrypt artifacts stored in S3 or other supported stores. This ensures that pipeline artifacts are encrypted at rest and in transit, protecting sensitive data from unauthorized access. By default, CodePipeline uses an AWS-managed key, but using a customer-managed KMS key gives the team full control over encryption, key rotation, and access policies.

Exam trap

The trap here is that candidates often confuse logging (CloudTrail) with security controls, or assume MFA can be directly enforced on pipeline executions, when in fact the correct security measures involve encryption, access control on artifacts, and IAM permissions on the pipeline resource itself.

20
MCQhard

A team uses AWS CodePipeline with multiple stages: Source, Build, Test, and Deploy. The Test stage runs integration tests against a staging environment. Occasionally, the tests fail due to environment issues, not code issues. The team wants to automatically retry the Test stage up to two times if it fails, but not the Deploy stage. How can this be achieved?

A.Create a CloudWatch Events rule that triggers a Lambda function to retry the failed stage.
B.Configure the Retry setting in the Test stage's action configuration.
C.Enable the 'Retry on failure' option in the CodePipeline pipeline settings.
D.Use AWS Step Functions to orchestrate the pipeline and implement retries.
AnswerA

This is correct because CodePipeline emits Amazon CloudWatch Events/EventBridge events on stage state changes, including a 'FAILED' state for a stage. A rule can filter for `detail-type: 'CodePipeline Stage Execution State Change'` with `detail.state: 'FAILED'` and trigger a Lambda function that invokes the `RetryStageExecution` API, passing the `pipelineExecutionId` and `stageName` from the event. This automates the same retry a user would otherwise click, and can include backoff logic or retry counts within the Lambda handler.

Why this answer

The correct approach is to use Amazon EventBridge (formerly CloudWatch Events) to detect a stage failure in CodePipeline and trigger an AWS Lambda function that calls the RetryStageExecution API. This provides automatic retries without manual intervention. CodePipeline's built-in retry setting on a stage action is not automatic; it only allows manual retries via the console or API.

Option D (Step Functions) is a valid alternative but adds unnecessary complexity for this use case.

Exam trap

The trap is that candidates may mistakenly believe CodePipeline supports automatic per-stage retries through a built-in configuration, when in fact the retry setting only enables manual retries. Automatic retries require external services like EventBridge and Lambda.

How to eliminate wrong answers

Option A is wrong because creating a CloudWatch Events rule to trigger a Lambda function for retrying a failed stage is overly complex and not the native solution; CodePipeline already provides built-in retry capabilities at the stage level. Option C is wrong because there is no global 'Retry on failure' option in CodePipeline pipeline settings; retries must be configured per stage action, not pipeline-wide. Option D is wrong because using AWS Step Functions to orchestrate the pipeline and implement retries would add unnecessary complexity and cost, as CodePipeline natively supports stage-level retries without external orchestration.

21
MCQmedium

A company uses AWS CodeDeploy to deploy a web application to an Auto Scaling group of Amazon EC2 instances. The deployment fails with the error 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.' The application is deployed to the instances using an in-place deployment. The instances are running Amazon Linux 2. What should the DevOps engineer check first?

A.Check the security group rules for the EC2 instances.
B.Check the application's port availability.
C.Verify that the AWS CodeDeploy agent is installed and running on each EC2 instance.
D.Verify that the IAM instance profile associated with the instances has the correct permissions.
AnswerC

In-place deployments depend on the CodeDeploy agent polling the service on each instance; if it is absent or stopped, lifecycle events never execute, triggering the too-many-instances-failed error. Verifying the agent on every Amazon Linux 2 instance is therefore the first diagnostic step.

Why this answer

The error message indicates that individual instances failed deployment, which is most commonly caused by the AWS CodeDeploy agent not running or not being installed on the EC2 instances. For an in-place deployment on Amazon Linux 2, the CodeDeploy agent must be installed and actively running to receive and execute deployment commands from the CodeDeploy service. If the agent is missing or stopped, the instance cannot participate in the deployment, leading to the 'too many individual instances failed' error.

Exam trap

The trap here is that candidates often jump to IAM permissions (Option D) as the first troubleshooting step, but the error message's reference to 'individual instances failed' directly points to the agent not running on the instances, which is a more immediate and common cause than permission issues.

How to eliminate wrong answers

Option A is wrong because security group rules control network traffic to/from the instances, but they do not affect the CodeDeploy agent's ability to communicate with the service or execute deployment scripts; the agent uses HTTPS outbound to the CodeDeploy endpoints, which is typically allowed by default. Option B is wrong because port availability relates to the application's ability to serve traffic after deployment, not to the deployment process itself; the error occurs during deployment, not after the application starts. Option D is wrong because while the IAM instance profile must have correct permissions for the agent to call CodeDeploy APIs, the error message specifically points to individual instance failures, which is more directly tied to the agent's presence and operational status; incorrect permissions would typically cause a different error (e.g., 'AccessDeniedException') rather than a generic instance failure.

22
Multi-Selectmedium

A company wants to implement a CI/CD pipeline for an application that runs on Amazon ECS with Fargate. The pipeline should build a Docker image, push it to Amazon ECR, and deploy a new task definition to ECS. Which THREE AWS services are required to build this pipeline?

Select 3 answers
A.Amazon S3
B.AWS CodeDeploy
C.AWS CodePipeline
D.AWS CodeCommit
E.AWS CodeBuild
AnswersB, C, E

AWS CodeDeploy is the correct service for deploying the new task definition to Amazon ECS. It uses a blue/green deployment strategy when configured with the ECS deployment controller, allowing traffic to be shifted gradually from the old task set to the new one while monitoring health and supporting automatic rollbacks. CodeDeploy accepts a versioned task definition and an AppSpec file, making it the service that actually performs the deployment to ECS.

Why this answer

AWS CodeDeploy is required because it manages the deployment of the updated task definition to the ECS service, supporting strategies like blue/green and canary deployments. It integrates with AWS CodePipeline to orchestrate the deployment step, ensuring minimal downtime and rollback capabilities.

Exam trap

The trap here is that candidates often assume AWS CodeCommit is mandatory for source control in a CI/CD pipeline, but the pipeline can use any Git repository or S3 bucket as a source, making CodeCommit optional.

23
Multi-Selectmedium

Which TWO best practices should be followed when configuring AWS CodeBuild projects to improve build performance and security? (Choose TWO.)

Select 2 answers
A.Run builds as the root user to avoid permission errors
B.Use the AWS managed policy 'AdministratorAccess' for the CodeBuild service role to avoid permission issues
C.Configure the build project to use a custom VPC to access resources like private Amazon RDS databases
D.Always use the 'latest' tag for the build environment image to ensure up-to-date software
E.Enable Amazon S3 cache to store dependencies and reuse them across builds
AnswersC, E

Configuring the build project to use a custom VPC is a best practice because it allows CodeBuild to securely access resources that are not publicly reachable, such as private Amazon RDS databases, internal load balancers, or AWS services via VPC endpoints. Without a VPC configuration, CodeBuild runs in AWS-managed compute and cannot resolve or connect to private IP addresses, forcing you to either expose those resources to the internet or use a NAT gateway with complex routing. By placing the build into a private subnet with proper security group rules, you can control both inbound and outbound traffic, ensuring the build only communicates with approved internal services and does not depend on the public internet.

Why this answer

Configuring a CodeBuild project to use a custom VPC allows it to access resources that are not publicly accessible, such as private Amazon RDS databases or internal services, which is essential for building applications that depend on those resources. This also enhances security by keeping traffic within the VPC and avoiding exposure to the public internet.

Exam trap

The trap here is that candidates may confuse 'improving performance' with 'simplifying configuration' and choose options like using the 'latest' tag or granting broad permissions, overlooking the security and determinism trade-offs.

24
MCQhard

A large enterprise uses a multi-account AWS strategy with a centralized DevOps account. The DevOps account hosts an AWS CodePipeline that deploys a critical application to production account (111111111111) using AWS CodeDeploy. The pipeline has three stages: Source (CodeCommit), Build (CodeBuild), and Deploy (CodeDeploy). The deploy stage uses a cross-account role (arn:aws:iam::111111111111:role/CrossAccountDeployRole) to perform the deployment. The trust policy on that role allows the DevOps account's CodePipeline service role (arn:aws:iam::222222222222:role/CodePipelineServiceRole) to assume it. The pipeline has been working for months, but after a recent security audit, the security team tightened permissions. Now the deploy stage fails with the error: 'User: arn:aws:sts::222222222222:assumed-role/CodePipelineServiceRole/AWS-CodePipeline-xxx is not authorized to perform: codedeploy:CreateDeployment on resource: arn:aws:codedeploy:us-east-1:111111111111:deploymentgroup:MyApp/MyDG'. The DevOps team has verified that the CrossAccountDeployRole has a permissions policy that allows 'codedeploy:*' on all resources. The CodePipelineServiceRole has a permissions policy that allows 'sts:AssumeRole' on the CrossAccountDeployRole. What is the most likely cause and what action should be taken to resolve the issue?

A.Add 'sts:AssumeRole' to the permissions policy of CodePipelineServiceRole.
B.Create the deployment group in the production account again to reset permissions.
C.Check the permissions boundary on CrossAccountDeployRole and add a boundary that allows CodeDeploy actions.
D.Update the trust policy of CrossAccountDeployRole to include the DevOps account ID.
AnswerC

A permissions boundary on CrossAccountDeployRole acts as an additional filter on the role's effective permissions, and if it does not explicitly allow CodeDeploy actions, those actions are denied even when the role's permissions policy grants them. Because the effective permission is the intersection of the identity-based policy and the boundary, the boundary must include all required codedeploy:* or specific actions. Adding or updating the boundary to allow CodeDeploy actions is the correct way to restore authorization in this cross-account deployment.

Why this answer

The error indicates that the assumed role (CrossAccountDeployRole) is not authorized to perform codedeploy:CreateDeployment, despite having a permissions policy that allows codedeploy:* on all resources. This typically occurs when a permissions boundary is attached to the role that restricts the effective permissions, overriding the permissions policy. Adding a permissions boundary that allows CodeDeploy actions resolves the issue by ensuring the role's effective permissions include the necessary CodeDeploy operations.

Exam trap

The trap here is that candidates often assume the error is due to missing sts:AssumeRole or trust policy misconfiguration, but the role was already assumed successfully (as shown by the assumed-role ARN in the error), so the real issue is a permissions boundary or service control policy limiting the role's effective permissions.

How to eliminate wrong answers

Option A is wrong because the CodePipelineServiceRole already has sts:AssumeRole in its permissions policy (as stated in the scenario), so adding it again would not resolve the issue. Option B is wrong because recreating the deployment group does not address the underlying permission restriction; the error is about authorization, not resource existence or configuration. Option D is wrong because the trust policy already allows the DevOps account's CodePipelineServiceRole to assume the role (the error shows the role was assumed successfully), so updating the trust policy is unnecessary.

25
MCQmedium

An organization uses AWS CodePipeline with multiple stages: Source, Build, Test, and Deploy. The Test stage runs integration tests in CodeBuild. Recently, the pipeline failed because the Test stage took longer than expected, causing a pipeline execution timeout. The pipeline has a default timeout of 7 days. What is the MOST efficient way to set a maximum execution time for the Test stage without affecting other stages?

A.Create an AWS Lambda function that stops the pipeline if the Test stage exceeds 1 hour.
B.Set the pipeline execution timeout to 1 hour in the pipeline settings.
C.Use Amazon CloudWatch Events to detect when the Test stage runs for more than 1 hour and then stop the pipeline.
D.Modify the CodeBuild project's build timeout (e.g., 1 hour) in the buildspec or project configuration.
AnswerD

In the CodeBuild project configuration (or in the buildspec's timeout-in-minutes field), you can set a build timeout that applies specifically to the build used by the Test stage. When the build exceeds the configured timeout, CodeBuild automatically stops the build and the pipeline transitions to Failed, giving a proactive, stage-scoped limit without affecting the Deploy stage. This is the recommended way to prevent a test job from hanging indefinitely because the timeout is enforced by CodeBuild's execution manager.

Why this answer

The CodeBuild project's build timeout setting directly controls the maximum duration a build can run before it is stopped. By setting this timeout to 1 hour in the CodeBuild project configuration or buildspec, the Test stage will automatically fail if it exceeds that limit, without affecting the pipeline's overall timeout or other stages. This is the most efficient and targeted approach, as it leverages a native CodeBuild feature rather than adding external monitoring or changing pipeline-wide settings.

Exam trap

The trap here is that candidates may confuse the pipeline-level execution timeout with stage-level or action-level timeouts, assuming that adjusting the pipeline timeout is the correct way to limit a specific stage, when in fact CodeBuild's own timeout is the precise and efficient mechanism for controlling build duration.

How to eliminate wrong answers

Option A is wrong because creating an AWS Lambda function to stop the pipeline adds unnecessary complexity, cost, and maintenance overhead; it is not the most efficient solution when a native CodeBuild timeout exists. Option B is wrong because setting the pipeline execution timeout to 1 hour applies to the entire pipeline, not just the Test stage, which would cause the entire pipeline to fail if any stage (e.g., Source, Build, or Deploy) takes longer than 1 hour, even if they are functioning correctly. Option C is wrong because using Amazon CloudWatch Events to detect a long-running Test stage and stop the pipeline introduces additional latency, complexity, and potential race conditions; it is less efficient than directly configuring the CodeBuild project's timeout.

26
MCQmedium

Refer to the exhibit. After a deployment at 10:00, the error rate increases steadily. What is the MOST likely cause?

A.An external dependency became unavailable after the deployment.
B.A bug in the new release causes errors to accumulate over time.
C.The database connection limit was reached immediately after deployment.
D.The deployment triggered a scaling event that overloaded the application.
AnswerB

A bug in the new release that causes errors to accumulate over time fits the exhibit's steady upward slope perfectly. For example, a memory leak, unreleased file descriptor, or growing goroutine/thread count raises resource pressure with every additional request, so failure probability increases as a function of cumulative traffic. This pattern is distinct from an immediate fault because the defect is latent, and the error rate worsens as the application's internal state becomes progressively corrupted or exhausted.

Why this answer

A steadily increasing error rate that begins right after a deployment and grows over time is the signature of a bug in the new release that accumulates state — for example, a memory leak, connection leak, unbounded cache, or counter that eventually corrupts behavior. Because the errors ramp up gradually rather than spiking immediately, the cause is inside the deployed code, not an external dependency or a hard resource ceiling hit at t=0. This pattern points to the new release as the root cause.

Exam trap

The trap is confusing 'gradual increase over time' with 'external dependency failure' — candidates pick A because dependency outages are common, but the temporal shape (steady ramp vs. step change) is the discriminator the exam is testing.

How to eliminate wrong answers

Option A is wrong because an external dependency becoming unavailable typically causes an immediate step-change in errors, not a steady ramp starting at deployment. Option C is wrong because hitting a database connection limit produces a sudden, sharp error spike when the pool is exhausted, not a gradual increase over hours. Option D is wrong because a scaling event triggered by deployment would cause a one-time capacity adjustment, not a continuously rising error rate; and if scaling were the issue, errors would correlate with load, not with time since deploy.

27
Multi-Selecteasy

A team uses AWS CodeBuild to build a Node.js application. The buildspec.yml file is at the root of the repository. The build fails with 'Error: Cannot find module 'aws-sdk''. Which TWO actions could resolve the issue? (Choose TWO.)

Select 2 answers
A.Ensure 'aws-sdk' is listed in the 'dependencies' section of package.json.
B.Specify a different Node.js runtime version in the buildspec.
C.Add a 'pre_build' phase that runs 'npm test'.
D.Add a 'install' phase that runs 'npm install'.
E.Add a 'build' phase command to compile the code.
AnswersA, D

The 'aws-sdk' package is a runtime dependency, and CodeBuild's npm install phase installs only the modules declared in package.json. If it is missing from the 'dependencies' section, npm will not fetch it, so your Node.js code cannot require it regardless of the environment. Adding it there ensures it is installed with the default dependency installation step, and pinning a version avoids unexpected updates.

Why this answer

The 'aws-sdk' module must be declared in the 'dependencies' section of package.json for npm to install it during the build. Without this declaration, npm install will not download the module, causing the 'Cannot find module' error at runtime. Option D is correct because CodeBuild does not automatically run npm install; you must explicitly include an 'install' phase in buildspec.yml to execute 'npm install' and populate node_modules.

Exam trap

The trap here is that candidates assume CodeBuild automatically runs 'npm install' or that the 'aws-sdk' is always available in the build environment, when in fact both the dependency declaration and explicit install phase are required.

28
MCQeasy

A development team uses AWS CodeCommit for source control and wants to automatically run unit tests on every push to the main branch. Which AWS service should they use to trigger the tests?

A.AWS CodeBuild
B.Amazon CloudWatch Events
C.AWS CodePipeline
D.AWS CodeDeploy
AnswerC

AWS CodePipeline is the correct choice because it natively integrates with CodeCommit as a source action and automatically starts a pipeline execution on every push to the configured branch. It can then invoke test actions (e.g., CodeBuild or third-party test tools) in a defined stage, with options for parallel actions, approvals, and rollback—making it the standard CI/CD orchestrator for this use case.

Why this answer

AWS CodePipeline is the correct service because it provides a fully managed continuous delivery service that can be configured to automatically trigger a build action (such as running unit tests in AWS CodeBuild) whenever a change is pushed to a specified branch in AWS CodeCommit. This is achieved by setting the source stage to the CodeCommit repository and branch, and then adding a build stage that invokes CodeBuild to execute the tests, enabling an automated CI/CD workflow.

Exam trap

The trap here is that candidates often confuse AWS CodeBuild as a standalone trigger because it can run tests, but they overlook that CodeBuild lacks native event-driven triggers and requires an orchestrator like CodePipeline or EventBridge to automate the start on a repository push.

How to eliminate wrong answers

Option A is wrong because AWS CodeBuild is a build service that compiles source code and runs tests, but it does not have native event-driven triggers to automatically start on a CodeCommit push; it requires an external trigger like CodePipeline or Amazon EventBridge. Option B is wrong because Amazon CloudWatch Events (now part of Amazon EventBridge) can capture CodeCommit repository events (e.g., push to branch) but cannot directly run unit tests; it would need to invoke a target like AWS Lambda or CodeBuild, making it an indirect and less integrated solution compared to CodePipeline. Option D is wrong because AWS CodeDeploy is a deployment service that automates application deployments to compute services (e.g., EC2, Lambda) and does not include functionality to run unit tests or trigger builds from source code changes.

29
MCQmedium

A company uses AWS Elastic Beanstalk for deploying web applications. They want to automate deployments whenever a new commit is pushed to the master branch of their CodeCommit repository. Which AWS service should they use to trigger the deployment?

A.AWS CloudTrail
B.AWS OpsWorks
C.Amazon CloudWatch Events
D.AWS CodePipeline
AnswerD

AWS CodePipeline is a fully managed continuous delivery service that orchestrates the stages required to build, test, and deploy your application automatically. It includes a native CodeCommit source action that watches the repository for new commits and completes the deployment by invoking Elastic Beanstalk as a deployment provider, which creates and deploys a new application version to the environment. The service handles sequencing, failure handling, and manual approval gates without requiring custom glue code. Therefore, CodePipeline is the correct answer because it directly integrates the version control and deployment services in a single automated pipeline.

Why this answer

AWS CodePipeline is a fully managed continuous delivery service that can be configured to automatically trigger a deployment pipeline when a new commit is pushed to a CodeCommit repository's master branch. It integrates directly with CodeCommit as a source action and Elastic Beanstalk as a deployment provider, enabling end-to-end automation without custom scripting.

Exam trap

The trap here is that candidates confuse CloudWatch Events (EventBridge) as a direct trigger for Elastic Beanstalk deployments, but it lacks the built-in pipeline orchestration and artifact management that CodePipeline provides for CI/CD workflows.

How to eliminate wrong answers

Option A is wrong because AWS CloudTrail is an auditing service that records API calls for governance and compliance, not a service for triggering automated deployments. Option B is wrong because AWS OpsWorks is a configuration management service using Chef or Puppet, not designed for event-driven deployment triggers from CodeCommit. Option C is wrong because Amazon CloudWatch Events (now Amazon EventBridge) can detect CodeCommit events but requires a custom target (e.g., a Lambda function) to invoke Elastic Beanstalk; it does not natively orchestrate the deployment pipeline as CodePipeline does.

30
MCQeasy

A DevOps team uses AWS CodeBuild to compile a Java application. The build environment is managed by AWS and runs on Linux. The team wants to speed up the build process by caching dependency directories across builds. Which configuration should the team use?

A.Configure the buildspec file to use Docker layer caching
B.Use the CodeBuild cache configuration to store the entire build output in a custom Docker image
C.Store dependencies in an Amazon S3 bucket and download them at the start of each build
D.Enable local caching in the CodeBuild project and specify the cache location as /root/.m2
AnswerD

Enabling local caching in the CodeBuild project and specifying /root/.m2 as the custom cache location precisely tells CodeBuild to preserve and restore the Maven local repository onto the same build agent across runs. This way, already-downloaded JARs are reused and Maven won't fetch them again, dramatically reducing build time. This is the documented approach for caching Maven dependencies with CodeBuild.

Why this answer

AWS CodeBuild supports local caching, which stores specified directories on the build host's local instance storage. By configuring the cache type as 'local' and specifying the cache location as `/root/.m2` (the default Maven local repository), the team can persist downloaded Maven dependencies across builds, significantly reducing build time by avoiding re-downloading dependencies.

Exam trap

The trap here is that candidates may confuse Docker layer caching (used for container image builds) with local caching for dependency directories, or assume that S3 caching is the only option, overlooking the simpler and faster local cache feature.

How to eliminate wrong answers

Option A is wrong because Docker layer caching is used for Docker builds (e.g., when using `docker build`), not for caching Maven dependencies in a Java build; it does not apply to the dependency directory caching scenario. Option B is wrong because storing the entire build output in a custom Docker image is not a caching mechanism for dependencies; it would create unnecessary image bloat and does not leverage CodeBuild's built-in cache configuration for local or S3 caching. Option C is wrong because manually downloading dependencies from S3 at the start of each build adds network latency and complexity, whereas CodeBuild's local caching provides faster, host-local storage without the overhead of S3 transfers.

31
Multi-Selecthard

A company is using AWS CodeBuild to compile and test code. The buildspec.yml file includes a pre_build phase that installs dependencies and a build phase that runs the compilation. The tests are run in the post_build phase. The team wants to improve the security of the build process by ensuring that sensitive information such as database passwords is not exposed in the build logs. Which TWO actions should the team take? (Choose two.)

Select 2 answers
A.Use AWS Systems Manager Parameter Store to store the secrets and reference them in the buildspec using the 'parameter-store' field.
B.Use AWS Secrets Manager to store the secrets and reference them in the buildspec using the 'secrets-manager' field.
C.Restrict access to the build logs by using IAM policies to only allow specific users to view them.
D.Enable encryption at rest for the CodeBuild project's S3 logs.
E.Store the secrets as plain-text environment variables in the CodeBuild project.
AnswersA, B

AWS Systems Manager Parameter Store with the 'parameter-store' field in buildspec is correct because CodeBuild retrieves the SecureString value during build and injects it as an environment variable without ever displaying it in the build log. The value itself is encrypted with KMS and access is controlled by IAM, so this satisfies the requirement to keep secrets out of logs without additional steps.

Why this answer

Option A is correct because CodeBuild natively supports the 'parameter-store' field in buildspec.yml, which retrieves values from AWS Systems Manager Parameter Store at build time and injects them as environment variables without printing them in the logs; the build's service role needs ssm:GetParameters permissions. Option B is correct because CodeBuild also supports the 'secrets-manager' field, which fetches secrets from AWS Secrets Manager during the build and masks them in the logs, requiring secretsmanager:GetSecretValue permissions. Option C is not correct because restricting who can view logs does not prevent secrets from being written into the logs in the first place, so the exposure risk remains.

Option D is not correct because S3 encryption at rest protects stored log objects but does not stop secrets from appearing in plaintext within the logs. Option E is not correct because plain-text environment variables are visible in the CodeBuild console and can be echoed into build logs, directly exposing the sensitive values.

Exam trap

The trap here is that candidates often think restricting log access (Option C) or encrypting logs (Option D) is sufficient to protect secrets, but the core requirement is to prevent secrets from ever being written to logs in the first place.

32
MCQmedium

A development team uses AWS CodeCommit as a source repository for their AWS CodePipeline. They want to automatically trigger a pipeline execution when a new branch is created. Which solution should they implement?

A.Create an S3 event notification to invoke the pipeline when a branch is created.
B.Use Amazon CloudWatch Events to trigger the pipeline on a CodeCommit 'Reference Created' event.
C.Configure a webhook in CodePipeline to detect branch creation events.
D.Set up a polling mechanism in CodePipeline to check for new branches every minute.
AnswerB

Amazon CloudWatch Events (now Amazon EventBridge) natively captures CodeCommit API events, including a 'Reference Created' event when a branch or tag is created. You can configure a rule that matches the repository name and reference type 'branch', then target it to the CodePipeline pipeline for automatic execution. This is the recommended push-based integration because it is serverless, near-real-time, and does not require any external endpoint or polling.

Why this answer

AWS CodePipeline can be configured to start execution automatically when a new branch is created in CodeCommit by using Amazon CloudWatch Events (now part of Amazon EventBridge) to listen for the 'Reference Created' event type. This event is emitted by CodeCommit whenever a new Git reference (such as a branch or tag) is created, and it can directly target a CodePipeline pipeline as a rule target, triggering a new execution without any custom polling or webhook setup.

Exam trap

The trap here is that candidates often confuse webhooks (which are for external Git providers) with native AWS event-driven triggers, leading them to incorrectly select Option C, or they mistakenly think S3 notifications can be used for CodeCommit events (Option A) due to a general familiarity with S3 event-driven architectures.

How to eliminate wrong answers

Option A is wrong because S3 event notifications cannot be generated by CodeCommit branch creation events; S3 events are specific to object-level operations in an S3 bucket, not to Git repository actions. Option C is wrong because CodePipeline webhooks are designed to listen for external events from third-party providers like GitHub or Bitbucket, not for native AWS CodeCommit events, and CodeCommit does not support outgoing webhooks to CodePipeline. Option D is wrong because CodePipeline does not have a built-in polling mechanism to check for new branches; polling would require a custom solution (e.g., a Lambda function) and is not a native feature of CodePipeline.

33
MCQmedium

The exhibit shows the output of the AWS CLI command 'batch-get-builds' for a CodeBuild build. The build failed. What is the most likely cause of the failure?

A.The source code has compilation errors.
B.The buildspec file is malformed.
C.The build project does not have sufficient memory.
D.The S3 bucket 'my-bucket' does not exist or the build project lacks permissions to access it.
AnswerD

CodeBuild reports a client error when it cannot retrieve source artefacts, and the build log shows an S3 access failure. Either the bucket 'my-bucket' is absent or the service role lacks s3:GetObject permission, so the build fails before compilation begins.

Why this answer

The `batch-get-builds` output shows a failure in the DOWNLOAD_SOURCE phase, with an error indicating that the build could not access the S3 bucket `my-bucket`. The error details, such as 'Access Denied' or 'NoSuchBucket', imply that the CodeBuild service role lacks the required `s3:GetObject` permission on the bucket, or the bucket does not exist. This is a common misconfiguration when the source code is stored in an S3 bucket and the build project is not properly configured to retrieve it.

Exam trap

The trap here is that candidates often assume a build failure is always due to code errors or buildspec issues, but the error message in the CLI output directly points to an S3 permission problem during the DOWNLOAD_SOURCE phase. Unlike artifact uploads which require s3:PutObject, source downloads require s3:GetObject, and candidates must distinguish between the two.

How to eliminate wrong answers

Option A is wrong because compilation errors would produce a different error message in the build logs, typically showing compiler output or exit code 1, not an S3 access-related error. Option B is wrong because a malformed buildspec file would cause a `BUILD_FAILURE` with a YAML parse error or 'Invalid buildspec' message, not an S3 permission error. Option C is wrong because insufficient memory would manifest as an out-of-memory (OOM) kill or a build timeout, not an S3 access denied error.

34
MCQhard

A company uses AWS CodePipeline with an Amazon S3 source action. The pipeline deploys to an Amazon ECS Fargate service. The engineer notices that the pipeline does not automatically start when a new object is uploaded to the S3 bucket. The S3 bucket versioning is enabled. What is the most likely cause?

A.The pipeline has manual approval required before the source stage
B.The S3 bucket does not have event notifications configured for the pipeline
C.S3 versioning is not enabled on the bucket
D.The ECS service is not configured for blue/green deployments
AnswerB

CodePipeline does not automatically poll an Amazon S3 source bucket for new objects unless the bucket has event notifications enabled to emit s3:ObjectCreated:* events to the pipeline. Without an Amazon CloudWatch Events rule or an S3 event notification configured to invoke the pipeline on object writes, the pipeline will only run manually or when explicitly started from the console, CLI, or SDK. This is the standard prerequisite for automatic triggering from an S3 source, and its absence explains why the pipeline remains idle after an upload.

Why this answer

AWS CodePipeline with an S3 source action does not automatically detect new object uploads unless the S3 bucket is configured with event notifications that trigger the pipeline. Without these notifications, the pipeline must be started manually or via a webhook. Since versioning is enabled, the issue is not related to versioning but to the missing event notification configuration.

Exam trap

The trap here is that candidates assume S3 versioning alone enables automatic pipeline triggers, but versioning only ensures object version tracking, not event-driven execution.

How to eliminate wrong answers

Option A is wrong because manual approval is a stage-level action that occurs after the source stage, not a condition that prevents the pipeline from starting; it would block execution but not the trigger itself. Option C is wrong because the question explicitly states that S3 bucket versioning is enabled, so this cannot be the cause. Option D is wrong because blue/green deployments are a deployment strategy for ECS, unrelated to how the pipeline is triggered by S3 events.

35
Multi-Selectmedium

Which TWO options are valid ways to trigger an AWS CodePipeline execution automatically? (Choose two.)

Select 2 answers
A.A scheduled CloudWatch Logs metric filter.
B.Completion of a CodeDeploy deployment.
C.Changes to a CodeCommit repository.
D.Manual approval action in the pipeline.
E.Upload of a new object to an S3 bucket.
AnswersC, E

CodePipeline can be configured to automatically start an execution when a push occurs to a branch (or tag) in a CodeCommit repository. The console sets up a CloudWatch Events rule that matches actions like reference creation or update, and the pipeline's source stage polls for that event; this is a built-in, first-class trigger mechanism for Git-based sources

Why this answer

AWS CodePipeline can automatically start a pipeline execution when a change is detected in a CodeCommit repository. This is achieved through CloudWatch Events that monitor the repository for specific events like push to a branch, and then trigger the pipeline. This integration allows for continuous delivery by automatically building and deploying code changes.

Exam trap

The trap here is confusing pipeline stage actions (like manual approval or deployment completion) with external event sources that automatically start the pipeline; candidates often think any pipeline activity can trigger itself, but only source changes from CodeCommit, S3, or third-party sources like GitHub (via webhooks) are valid automatic triggers.

36
MCQhard

A DevOps engineer is setting up an AWS CodeBuild project to build a Node.js application. The buildspec.yml file includes a pre_build phase that runs npm install and a build phase that runs npm run build. The build is failing with an error indicating that the 'node' command is not found. The CodeBuild project uses a standard Ubuntu image with the 'aws/codebuild/standard:5.0' image. What is the most likely cause of the failure?

A.The CodeBuild service role lacks permissions to download Node.js from the internet.
B.The build phase is using a different shell that does not have Node.js in its PATH.
C.The buildspec.yml file is missing a runtime-versions section specifying Node.js.
D.The pre_build phase must include a command to install Node.js manually using apt-get.
AnswerC

In CodeBuild standard images, the runtime-versions section in the buildspec.yml is required to install and set up the desired runtime, such as Node.js. Without it, the image may not have Node.js pre-installed or may not be in the PATH. The error indicates that the node command is not found, which is resolved by specifying the runtime version.

Why this answer

CodeBuild standard images require the runtime-versions section in the buildspec.yml to install and configure the desired runtime, such as Node.js. Without it, the image may not have Node.js installed, leading to a 'command not found' error. Specifying runtime-versions ensures the correct version is available in the PATH for all phases.

Exam trap

The trap here is assuming that the standard image includes Node.js by default, when it actually requires explicit runtime version specification in the buildspec.

37
MCQmedium

Refer to the exhibit. A CloudFormation stack has been deployed. A developer wants to use the S3 bucket name in a subsequent AWS CLI command. Which command will correctly retrieve the bucket name?

A.aws s3 ls | grep my-stack
B.aws cloudformation describe-stack-resources --stack-name my-stack --logical-resource-id BucketName --query "StackResources[0].PhysicalResourceId" --output text
C.aws cloudformation describe-stacks --stack-name my-stack --query "Stacks[0].Outputs[?OutputKey=='BucketName'].OutputValue" --output text
D.aws cloudformation describe-stacks --stack-name my-stack --query "Stacks[0].Outputs[OutputKey='BucketName'].OutputValue" --output text
AnswerC

This command is correct because it uses `aws cloudformation describe-stacks` to retrieve the stack's metadata, then JMESPath `Stacks[0].Outputs[?OutputKey=='BucketName'].OutputValue` filters the outputs array for the output whose `OutputKey` exactly equals `BucketName` and extracts its `OutputValue`. The `--output text` renders the result as plain text (the actual bucket name). This directly matches the exhibit, which shows the stack's outputs, and is the intended way to programmatically retrieve a CloudFormation output value.

Why this answer

The developer can use the --query parameter with the describe-stacks command to extract the OutputValue for the specific OutputKey 'BucketName'. Option C uses the correct JMESPath syntax with the filter [?OutputKey=='BucketName'] to select the matching output and then retrieves its OutputValue. Option A attempts to list all S3 buckets and grep for 'my-stack', which is unreliable and not the intended method.

Option B uses describe-stack-resources but incorrectly assumes the bucket name is a physical resource ID when it is actually an output value. Option D uses incorrect JMESPath syntax (single bracket with equality) which is invalid.

38
Multi-Selectmedium

A DevOps team is designing a CI/CD pipeline for a microservices application that runs on Amazon ECS. They need to implement automated canary deployments. Which TWO AWS services would be essential for this implementation?

Select 2 answers
A.AWS CodeDeploy
B.AWS CloudFormation
C.AWS CodeBuild
D.Amazon CloudWatch
E.Amazon EC2 Auto Scaling
AnswersA, D

AWS CodeDeploy is the native AWS service for performing canary deployments on Amazon ECS. It shifts a specified percentage of production traffic to the new task set (e.g., 10% for 5 minutes) while the old version continues to serve the rest, then gradually increases the new version's traffic until 100%. CodeDeploy orchestrates the entire traffic-shifting process using the AppSpec file, target groups, and optional LifecycleEventHooks such as BeforeAllowTraffic and AfterAllowTraffic, making it the correct choice for a microservices CI/CD pipeline requiring canary releases.

Why this answer

AWS CodeDeploy is essential because it natively supports canary deployments for Amazon ECS through its ECS blue/green deployment type, allowing you to specify a canary traffic shift (e.g., 10% for 5 minutes) before full promotion. This enables automated, controlled rollouts with built-in rollback capabilities based on CloudWatch alarms.

Exam trap

The trap here is that candidates often confuse AWS CodeDeploy with AWS CloudFormation for deployment strategies, or mistakenly think EC2 Auto Scaling is needed for ECS canary deployments, when in fact CodeDeploy and CloudWatch are the essential pair for traffic shifting and monitoring.

39
MCQeasy

A development team uses AWS CodeBuild to compile a Java application. The build fails during the 'Install' phase with an error: 'Error: JAVA_HOME is not set'. How should the team fix this?

A.Set the environment variable 'JAVA_HOME' in the buildspec file's 'env' section.
B.Use the managed image 'aws/codebuild/standard:5.0' which has Java pre-installed.
C.Install Java in the pre_build phase using a command.
D.Use a custom Docker image that has Java pre-installed.
AnswerA

Setting JAVA_HOME in the buildspec's env section ensures the variable is exported into every build phase's shell before commands run. This resolves the 'invalid JAVA_HOME' error because Maven or Gradle translates this variable into the absolute path of the JDK installation, which is needed for compilation. It's the canonical fix and works regardless of which base image CodeBuild uses.

Why this answer

The error 'JAVA_HOME is not set' indicates that the build environment lacks the required environment variable pointing to the Java installation. In AWS CodeBuild, the buildspec file's 'env' section allows you to define environment variables, including 'JAVA_HOME', which can be set to the path of the Java runtime (e.g., '/usr/lib/jvm/java-11-openjdk-amd64'). This ensures the variable is available during the Install phase, resolving the error without altering the build image or adding installation steps.

Exam trap

The trap here is that candidates assume using a managed image with Java pre-installed automatically sets JAVA_HOME, but AWS CodeBuild images do not always export this variable by default, requiring explicit definition in the buildspec.

How to eliminate wrong answers

Option B is wrong because using a managed image like 'aws/codebuild/standard:5.0' does not guarantee that JAVA_HOME is set; while Java is pre-installed, the environment variable may not be defined by default, leading to the same error. Option C is wrong because installing Java in the pre_build phase is unnecessary if Java is already present, and it does not address the root cause—JAVA_HOME not being set; the variable must be explicitly defined. Option D is wrong because using a custom Docker image with Java pre-installed still requires setting JAVA_HOME in the buildspec or Dockerfile; otherwise, the variable may be missing, causing the same failure.

40
Multi-Selectmedium

A company uses AWS CodePipeline to automate deployments. The pipeline consists of Source, Build, and Deploy stages. The Build stage uses CodeBuild, and the Deploy stage uses CodeDeploy. Recently, the pipeline failed at the Deploy stage with an error: 'The deployment group does not exist'. Which TWO actions should the team take to resolve this issue?

Select 2 answers
A.Verify that the deployment group name specified in the pipeline's Deploy stage matches the actual deployment group name in CodeDeploy.
B.Confirm that the pipeline and the CodeDeploy deployment group are in the same AWS Region.
C.Increase the timeout for the Deploy stage to allow more time for the deployment group to be created.
D.Ensure that the CodeBuild project has permissions to access the CodeDeploy deployment group.
E.Check that the CodeDeploy application exists in the same AWS account as the pipeline.
AnswersA, B

The `Deploy` stage action stores a literal `DeploymentGroupName` string that must exactly match the name of an existing deployment group in the target CodeDeploy application. This string is case-sensitive and cannot include trailing spaces or a mangled formatted name. When CodeDeploy receives the pipeline's `CreateDeployment` API call, it validates the deployment group against the application in the region; if no exact match exists, it returns the 'Deployment group not found' error. To resolve it, open the pipeline's Deploy stage action and compare the `DeploymentGroupName` value to the deployment group name shown in the CodeDeploy console.

Why this answer

The error 'The deployment group does not exist' directly indicates a mismatch between the deployment group name specified in the CodePipeline Deploy stage configuration and the actual deployment group name defined in CodeDeploy. The pipeline's Deploy stage action references a deployment group by name; if that name does not match an existing group in CodeDeploy, the deployment fails. Verifying and correcting this name resolves the issue.

Exam trap

The trap here is that candidates often confuse the deployment group name with the CodeDeploy application name, or assume that the pipeline will automatically create the deployment group, leading them to choose irrelevant options like increasing timeout or checking CodeBuild permissions.

41
MCQhard

A company uses AWS CodePipeline with multiple stages: Source (Amazon S3), Build (AWS CodeBuild), and Deploy (AWS CodeDeploy). The build stage runs a series of tests, and if they pass, the pipeline proceeds to deploy. Recently, a developer committed a change that passed all tests but caused a production outage. The team wants to add an approval step before the deploy stage, but they also want to ensure that only changes from specific branches can be deployed. What is the MOST secure and maintainable way to enforce this?

A.Use a Lambda function in the pipeline to check the branch name and fail if not allowed.
B.Add a manual approval step in the pipeline and rely on the approver to verify the branch.
C.Create a separate pipeline for each allowed branch, with the approval step only in the production pipeline.
D.Tag the source artifacts with the branch name and use a condition in CodePipeline to allow only specific tags.
AnswerC

Creating a separate pipeline per allowed branch makes the pipeline definition itself the security boundary. Only branches that have an explicitly defined pipeline can ever proceed through the release stages, so committing to an unauthorized branch simply does not trigger a deployment even if the code is structurally valid. The production pipeline includes a manual approval step, and because that pipeline sources solely from an approved branch (e.g., main), the approval verifies the intended deployable artifact rather than attempting to check a branch name at runtime. This isolation prevents accidental or malicious deployment from unapproved branches without relying on inline validation or easily modified Lambda actions.

Why this answer

It enforces branch-based deployment at the pipeline level, ensuring that only changes from specific branches trigger the production pipeline with the approval step. This approach is secure and maintainable as it leverages AWS CodePipeline's native ability to trigger on branch events, avoiding custom logic or manual verification. By isolating production deployments to a dedicated pipeline, the team reduces the risk of unauthorized or untested code reaching production.

Exam trap

The trap here is that candidates often overestimate the flexibility of CodePipeline's built-in filtering or underestimate the security and maintainability benefits of using separate pipelines per branch, leading them to choose a custom Lambda solution (Option A) that introduces unnecessary complexity and risk.

How to eliminate wrong answers

Option A is wrong because using a Lambda function to check the branch name and fail the pipeline introduces custom code that must be maintained, tested, and secured, increasing complexity and potential failure points; it also fails the pipeline after the build stage, wasting resources. Option B is wrong because relying on a manual approver to verify the branch is error-prone and not automated, violating the principle of secure, maintainable enforcement; it depends on human diligence rather than system-level controls. Option D is wrong because CodePipeline does not support conditions that filter based on artifact tags; tagging source artifacts with branch names does not natively restrict pipeline execution, and such a condition would require custom logic, making it less secure and maintainable.

42
MCQmedium

A DevOps engineer is setting up an AWS CodePipeline for a serverless application. The source code is in AWS CodeCommit, and the build and deploy stages use AWS CodeBuild and AWS CloudFormation respectively. The engineer wants to ensure that the pipeline automatically creates a new stack for each feature branch and deletes the stack when the branch is deleted. Which combination of actions should the engineer take to achieve this with minimal operational overhead?

A.Configure the pipeline to trigger on all branches and use a single CloudFormation stack with a parameter that includes the branch name.
B.Use AWS CodePipeline with a source action that triggers on all branches, and configure the build stage to pass the branch name to CloudFormation, creating a stack per branch with a naming convention, and use a cleanup Lambda triggered by CodeCommit branch deletion events.
C.Create a separate pipeline for each branch using AWS CloudFormation templates and AWS Lambda to manage stack creation and deletion.
D.Configure CodePipeline to use a single stage that deploys to AWS Elastic Beanstalk environments named after each branch, and rely on Elastic Beanstalk's environment lifecycle policies to delete environments when branches are deleted.
AnswerB

This approach leverages CodePipeline's ability to trigger on all branches and dynamically create CloudFormation stacks per branch using the branch name as part of the stack name. A Lambda function triggered by CodeCommit branch deletion events can delete the corresponding stack. This automates stack lifecycle management with minimal overhead, as the pipeline and Lambda handle creation and deletion. It provides isolation and scalability across branches.

Why this answer

To automatically create and delete CloudFormation stacks per feature branch, the engineer should use CodePipeline's branch-based triggering and pass the branch name to CloudFormation to create uniquely named stacks. A Lambda function triggered by CodeCommit branch deletion events can then delete the corresponding stack. This leverages native AWS services for automation, minimizing operational overhead.

The other options either use inappropriate services, lack automation, or do not provide isolation.

Exam trap

The trap here is assuming that a single stack with a branch parameter or manual pipelines can handle multiple branches efficiently, when in fact isolation and automated cleanup require per-branch stacks and event-driven deletion.

43
MCQeasy

A development team uses AWS CodeBuild to compile a Java application and run unit tests. The build takes 30 minutes, but the team wants to reduce build time. The codebase has not changed significantly, and dependencies are stable. Which action would be MOST effective in reducing build time?

A.Configure CodeBuild to cache dependencies in an Amazon S3 bucket.
B.Move the build process to a local developer machine to avoid CodeBuild overhead.
C.Reduce the number of unit tests executed in the build phase.
D.Increase the compute type of the build environment to a larger instance.
AnswerA

Configure CodeBuild with cache.type set to S3 and specify an S3 bucket as cache.location, then declare the Java dependency directory (e.g., /root/.m2 for Maven) in the buildspec cache.paths. This creates a persistent, shared cache that is uploaded at the end of each build and downloaded at the start of the next, so dependencies are fetched from S3 instead of being downloaded one-by-one from public repositories on every run. By keying the cache appropriately (e.g., including a hash of the buildspec or source), you retain a valid cache while invalidating it when dependencies or build parameters change.

Why this answer

Caching dependencies in an Amazon S3 bucket allows CodeBuild to reuse previously downloaded Maven/Gradle dependencies across builds, eliminating the need to re-download them each time. Since the codebase and dependencies are stable, this directly reduces the build time by avoiding repeated network transfers of large artifact repositories.

Exam trap

The trap here is that candidates assume a larger compute instance always speeds up builds, overlooking that network-bound operations like dependency downloads are not significantly improved by CPU or memory upgrades.

How to eliminate wrong answers

Option B is wrong because moving the build to a local developer machine sacrifices consistency, scalability, and auditability, and does not address the core issue of dependency download overhead in CodeBuild. Option C is wrong because reducing unit tests compromises code quality and test coverage, and the question states the team wants to reduce build time without changing the codebase significantly — removing tests is not a valid optimization. Option D is wrong because increasing the compute type primarily accelerates CPU-bound tasks (compilation), but the bottleneck here is likely network-bound dependency downloads; a larger instance does not reduce the time spent downloading unchanged dependencies.

44
MCQhard

An organization uses AWS CodePipeline with multiple stages: Source, Build, Deploy to Test, Deploy to Prod. They want to implement a canary deployment strategy for the production deployment. Which approach should they use?

A.Use a Lambda function in CodePipeline to manually adjust weights in Route53.
B.Use CodeDeploy with a canary deployment configuration in the Deploy to Prod stage.
C.Use an Elastic Load Balancer to gradually shift traffic using weighted target groups.
D.Use CloudFormation with a canary update policy in the Deploy to Prod stage.
AnswerB

CodeDeploy is the AWS-native service designed for controlled software rollouts, and its canary deployment configuration is fully supported as a CodePipeline deploy action. For example, a configuration like Canary10Percent5Minutes shifts 10% of traffic to the new task set or instance fleet, waits five minutes, then shifts the remaining 90%, while monitoring health via lifecycle hooks. Because CodeDeploy owns the traffic-shifting logic, it automatically detects failures, stops the deployment, and can roll back to the previous version. This directly satisfies the requirement for a built-in canary strategy in the Deploy to Prod stage with no custom scripting.

Why this answer

AWS CodePipeline integrates natively with CodeDeploy, which supports canary deployments by shifting a percentage of traffic to the new revision over a specified time interval (e.g., 10% every 5 minutes). Using CodeDeploy with a canary configuration in the Deploy to Prod stage directly implements the desired canary strategy within the pipeline, leveraging CodeDeploy's built-in traffic shifting and health monitoring.

Exam trap

The trap here is that candidates often confuse traffic routing mechanisms (like ELB weighted target groups) with deployment strategies (like CodeDeploy canary), failing to recognize that CodeDeploy provides the orchestration, lifecycle hooks, and automated rollback that a true canary deployment requires.

How to eliminate wrong answers

Option A is wrong because manually adjusting weights in Route53 via a Lambda function is not a native CodePipeline integration for canary deployments; it requires custom scripting, lacks automated rollback capabilities, and does not leverage CodeDeploy's deployment lifecycle hooks. Option C is wrong because an Elastic Load Balancer with weighted target groups can shift traffic, but it does not provide the deployment orchestration, health checks, or rollback features that CodeDeploy offers; it is a lower-level traffic routing mechanism, not a deployment strategy. Option D is wrong because CloudFormation's canary update policy (UpdatePolicy with AutoScalingRollingUpdate) is for rolling updates to Auto Scaling groups, not for canary traffic shifting in a CodePipeline deployment; it does not support percentage-based traffic shifting to a new application version.

45
MCQmedium

A team uses AWS CodePipeline to deploy a microservices application. The pipeline has a deploy action that uses AWS CloudFormation. The CloudFormation template creates an Amazon ECS service. The deployment fails because the ECS service cannot be updated. What is the most likely cause?

A.The CloudFormation stack already exists and is in a previous failed state.
B.The ECS service is in a steady state and cannot be modified.
C.The CodePipeline deploy action is configured with the wrong action type.
D.The IAM role used by CloudFormation does not have permission to update ECS services.
AnswerA

The CloudFormation stack referenced by the CodePipeline deploy action already exists and remains in a failed state (e.g., ROLLBACK_COMPLETE, UPDATE_ROLLBACK_COMPLETE, or CREATE_FAILED). CloudFormation refuses to perform an update on a stack that has not successfully reached a stable state (CREATE_COMPLETE or UPDATE_COMPLETE), so the deploy action fails immediately. A failed stack must be deleted (if resource policy allows) or updated/remediated using a change set to move it back to a stable, updatable state before CodePipeline can retry.

Why this answer

When a CloudFormation stack update fails, the stack enters a ROLLBACK_COMPLETE or UPDATE_ROLLBACK_COMPLETE state. In this state, the stack is considered to be in a 'failed' state and cannot be updated again until it is either deleted or the stack is manually continued with a rollback. CodePipeline's CloudFormation deploy action will attempt to perform a stack update, but CloudFormation rejects the request because the existing stack is in a non-updatable state, causing the pipeline deployment to fail.

Exam trap

The trap here is that candidates often assume the error is due to missing IAM permissions or a misconfigured action type, but the real issue is CloudFormation's requirement that stacks be in a valid state before updates can proceed.

How to eliminate wrong answers

Option B is wrong because an ECS service in a steady state (e.g., ACTIVE) can be modified via CloudFormation updates; the error is not due to the service being immutable. Option C is wrong because the deploy action type (CloudFormation) is correct for deploying infrastructure; the failure is not related to a misconfigured action type. Option D is wrong because if the IAM role lacked permissions, the error would be an access denied or authorization failure, not a generic 'cannot be updated' error from CloudFormation.

46
MCQeasy

A team uses AWS CodeDeploy to deploy an application to an Auto Scaling group. The deployment fails with the error: 'The overall deployment failed because too many individual instances failed deployment.' The instances are healthy and can connect to the CodeDeploy service. What is the most likely cause?

A.The Auto Scaling group launch configuration is incorrect.
B.The deployment group is not configured with the correct service role.
C.The appspec.yml file or lifecycle event scripts have errors.
D.The target revision is not accessible from the instances.
AnswerC

The appspec.yml file controls the order and content of lifecycle events such as ApplicationStop, BeforeInstall, and AfterInstall. If the file is malformed, references a nonexistent script, or a referenced hook script exits with a non-zero status, CodeDeploy treats that instance as failed and reports 'ScriptFailed' or 'InvalidLifecycleEventName'. Because the deployment reaches the script execution stage and then errors, the appspec definition and its scripts are the most direct cause.

Why this answer

The error 'too many individual instances failed deployment' indicates that the deployment failed on the instances themselves, not at the infrastructure level. Since the instances are healthy and can connect to CodeDeploy, the most likely cause is that the appspec.yml file or the lifecycle event scripts (e.g., hooks like BeforeInstall, AfterInstall) contain errors that cause the deployment to fail on each instance. This is a common issue when scripts have syntax errors, missing dependencies, or incorrect paths.

Exam trap

The trap here is that candidates often assume the error is due to network or permissions issues (like S3 access or IAM roles) because those are common causes, but the question explicitly states instances are healthy and can connect to CodeDeploy, shifting the root cause to the application-level scripts or configuration.

How to eliminate wrong answers

Option A is wrong because an incorrect Auto Scaling group launch configuration would typically prevent instances from launching or cause them to be unhealthy, but the question states instances are healthy and can connect to CodeDeploy, so the launch configuration is not the issue. Option B is wrong because if the deployment group were not configured with the correct service role, CodeDeploy would fail to perform actions on the instances (e.g., cannot read from S3 or call APIs), but the instances can connect to CodeDeploy, indicating the service role is correctly assigned. Option D is wrong because if the target revision were not accessible from the instances, CodeDeploy would report a specific error about failing to download the revision (e.g., S3 bucket permissions or network issues), but the instances are healthy and can connect, so accessibility is not the problem.

47
MCQmedium

A company uses AWS CodePipeline to deploy a static website to an S3 bucket. The pipeline includes a source stage (S3), a build stage (CodeBuild) that minifies assets, and a deploy stage that copies files to the production S3 bucket. The deploy stage uses 's3 sync' command. After a recent deployment, some users report seeing old content. What is the MOST likely cause?

A.The website is served through Amazon CloudFront, and the CloudFront distribution cache was not invalidated after the deployment.
B.The S3 bucket policy blocks public read access, so users get a 403 error.
C.The IAM role for CodeBuild does not have permissions to write to the S3 bucket.
D.The deploy stage uses 's3 cp' instead of 's3 sync', so new files are not uploaded.
AnswerA

Although CodePipeline updates the S3 origin with the new static files, CloudFront edge locations continue to serve stale content until the cache TTL expires or an explicit invalidation is submitted. A CloudFront distribution does not automatically detect origin content changes; it caches objects based on the Cache-Control/Expires headers. Without creating an invalidation for '/*' (or for the changed paths) after the deployment, users will still see the previous version of the website, which matches the reported symptom. This is the only option that explains outdated content being served while the pipeline itself succeeds.

Why this answer

The most likely cause is that the static website is served through Amazon CloudFront, and the CloudFront distribution cache was not invalidated after the deployment. Even though the S3 bucket contents are updated via 's3 sync', CloudFront caches objects at edge locations based on TTL settings. Without a cache invalidation request, users continue to receive the old cached content until the TTL expires or the cache is manually cleared.

Exam trap

The trap here is that candidates may focus on S3 permissions or the sync command, overlooking the common real-world scenario where a CDN like CloudFront caches content and requires explicit invalidation after updates.

How to eliminate wrong answers

Option B is wrong because a bucket policy blocking public read access would result in a 403 Forbidden error, not users seeing old content. Option C is wrong because if the IAM role for CodeBuild lacked write permissions to the S3 bucket, the deployment would fail entirely, not partially serve old content. Option D is wrong because the question explicitly states the deploy stage uses 's3 sync', not 's3 cp', so this is a misreading of the scenario.

48
MCQmedium

A company uses AWS CodeCommit for source control. Developers frequently push large binary files (e.g., compiled JARs) to the repository, causing the repository size to grow rapidly and slowing down clone operations. The team wants to enforce a policy to reject pushes that contain files larger than 50 MB. Which approach should be used?

A.Configure a CodeCommit trigger that invokes an AWS Lambda function to validate file sizes and reject the push.
B.Set up an Amazon CloudWatch Events rule to monitor repository size and alert when it exceeds a threshold.
C.Create an IAM policy that denies the `codecommit:GitPush` action if the file size exceeds 50 MB.
D.Use a pre-receive hook in the repository to reject large files by generating an S3 pre-signed URL.
AnswerA

A CodeCommit trigger configured for push events can launch a Lambda function that inspects the incoming commits's metadata and calculates the size of each file. While native triggers are asynchronous, the Lambda can quickly delete the offending branch reference or tag, effectively rejecting the large-file push from a server-side governance perspective. This is the only option that applies custom validation logic that actually sees file content and can act to block the push, unlike IAM conditions, which cannot inspect Git payloads, or pre-receive hooks, which CodeCommit does not support.

Why this answer

AWS CodeCommit supports custom triggers that invoke AWS Lambda functions on repository events, including pushes. By configuring a trigger for the 'push' event, a Lambda function can inspect each file in the push payload, check its size against the 50 MB threshold, and programmatically reject the push by returning an error response. This approach enforces the policy at the repository level without requiring client-side changes.

Exam trap

The trap here is that candidates confuse CodeCommit triggers with Git hooks (like pre-receive hooks) or assume IAM policies can enforce content-based rules, when in fact IAM cannot inspect file contents and CodeCommit does not support server-side Git hooks.

How to eliminate wrong answers

Option B is wrong because Amazon CloudWatch Events can monitor repository metrics and send alerts, but it cannot actively reject a push; it only provides post-hoc notification after the push has already occurred. Option C is wrong because IAM policies evaluate permissions based on the principal, action, and resource, but they cannot inspect the content or size of files being pushed; the `codecommit:GitPush` action does not support condition keys for file size. Option D is wrong because CodeCommit does not support pre-receive hooks; that feature is specific to self-managed Git servers or AWS CodeCommit's hosted Git does not expose hook mechanisms like pre-receive scripts, and generating an S3 pre-signed URL is unrelated to rejecting pushes.

49
MCQeasy

A DevOps engineer is troubleshooting a failed build in AWS CodeBuild. The build log shows: 'Error: Cannot find module 'lodash'.' The buildspec.yml file lists 'npm install' as a command. What is the most likely cause?

A.The npm install command is running before the source is downloaded.
B.The lodash package is not compatible with the Node.js version.
C.The package.json file is missing or does not include lodash.
D.The build environment does not have internet access to download packages.
AnswerC

`npm install` reads the `dependencies` and `devDependencies` fields in `package.json` and installs exactly the packages listed there. If lodash is not specified in that file, it will not be installed, and any subsequent `require('lodash')` or `import ... from 'lodash'` will throw `MODULE_NOT_FOUND`. A missing `package.json` would cause `npm install` to fail outright, but either way, the root cause is that lodash was not properly declared as a dependency.

Why this answer

The error 'Cannot find module 'lodash'' indicates that the lodash package is not installed. Since the buildspec includes 'npm install', the most likely cause is that the package.json file is missing or does not list lodash as a dependency. Without package.json or with incorrect dependencies, npm install will not install lodash, leading to the error.

50
MCQhard

A company is using AWS CodeDeploy to deploy a web application to an Auto Scaling group of Amazon EC2 instances. The deployment strategy is Blue/Green. After a successful deployment, the team notices that the new instances are receiving traffic but the application returns errors. The old instances are still serving traffic correctly. The team wants to roll back immediately. What should be done?

A.Stop the current deployment using the AWS CLI.
B.Manually update the Auto Scaling group to associate new instances with the old launch configuration.
C.Configure the deployment group to automatically roll back when a deployment fails, then manually trigger a rollback.
D.Redeploy the same application revision to the same Auto Scaling group.
AnswerC

The correct approach is to leverage CodeDeploy's rollback capability: configure the deployment group to automatically roll back on deployment failure (or on a CloudWatch alarm), which causes CodeDeploy to track the last known good revision. Triggering the rollback—either through the console's rollback action or by redeploying the previous successful revision—makes CodeDeploy deploy that good revision to the green fleet and shift traffic back to the original blue environment, restoring the known-good service. This is the only option that actively reverses the faulty deployment and restores live traffic, rather than merely affecting future instances or repeating the defect.

Why this answer

To roll back a CodeDeploy Blue/Green deployment, you should initiate a rollback deployment with the previous application revision. This can be done via the AWS CLI (`aws deploy create-deployment` with the old revision) or via the CodeDeploy console. Configuring automatic rollback on deployment failure is a separate setting and is not a prerequisite for manual rollback.

The explanation should be corrected to state that the rollback process creates a new replacement environment with the previous revision (or reuses the original if still available) and shifts traffic to it, not that automatic rollback must be configured first.

Exam trap

The trap is that candidates may think stopping a deployment or manually modifying Auto Scaling groups will revert traffic. However, the correct method is to use CodeDeploy's rollback feature for the deployment. Automatic rollback configuration is not required for manual rollback.

How to eliminate wrong answers

Option A is wrong because stopping a deployment in progress does not roll back the environment; it leaves the new instances in place and does not restore traffic to the old instances. Option B is wrong because you cannot manually associate instances with a different launch configuration in an Auto Scaling group; the launch configuration is immutable and applies only to new instances launched by the group, and the old instances are in a separate Auto Scaling group in a Blue/Green deployment. Option D is wrong because redeploying the same application revision will repeat the same failure; it does not revert to the previous working revision or restore the old instances.

51
MCQhard

An organization uses AWS CodePipeline to deploy a web application to Amazon EC2 instances behind an Application Load Balancer. The deployment uses a CodeDeploy action with an in-place deployment configuration. After a recent deployment, some instances are running the old version while others are running the new version. What is the most likely cause?

A.The deployment group is associated with an Auto Scaling group that launched new instances during the deployment.
B.The deployment group was configured with the 'AllAtOnce' deployment configuration, and the deployment failed partway through.
C.A lifecycle hook is configured to pause the deployment until manual approval.
D.The deployment was configured to use a blue/green strategy, but the target group is misconfigured.
AnswerB

With the AllAtOnce deployment configuration, CodeDeploy targets every instance in the deployment group simultaneously, but if a failure occurs partway through, the deployment stops without rolling back unless you explicitly enabled automatic rollback. Instances that already received and ran the new revision keep it, while instances that were not yet updated remain on the old revision, yielding a mixed state across the fleet. This is exactly the situation that would leave some instances running the previous version and others running the new version.

Why this answer

B is correct because the 'AllAtOnce' deployment configuration instructs CodeDeploy to deploy to all instances simultaneously. If the deployment fails partway through, some instances may have received the new version while others remain on the old version, resulting in a mixed state. This is the most likely cause given the symptom of a split between old and new versions across instances.

Exam trap

The trap here is that candidates often assume a failed deployment would affect all instances equally, but they overlook that 'AllAtOnce' can leave a mixed state because CodeDeploy does not roll back instances that already received the new version when the deployment fails partway through.

How to eliminate wrong answers

Option A is wrong because if an Auto Scaling group launched new instances during the deployment, those new instances would typically be provisioned with the latest launch template or user data, not necessarily the old version; moreover, CodeDeploy would still attempt to deploy to them, and the inconsistency described is more directly explained by a partial failure. Option C is wrong because a lifecycle hook configured to pause the deployment until manual approval would halt the entire deployment process, not cause a partial rollout where some instances get the new version and others do not. Option D is wrong because a blue/green strategy would create a separate set of instances (the green environment) and shift traffic only after the new version is fully deployed and tested; a misconfigured target group might cause routing issues, but it would not result in a mix of old and new versions on the same set of instances.

52
MCQeasy

A DevOps engineer needs to automate the creation of a new AWS CodeCommit repository when a new project starts. The engineer wants to use infrastructure as code. Which service should be used?

A.AWS CloudFormation
B.AWS CodePipeline
C.AWS CodeStar
D.AWS CodeBuild
AnswerA

AWS CloudFormation is the correct choice because it is a declarative Infrastructure as Code (IaC) service that can directly model and provision AWS resources, including AWS CodeCommit repositories. You define a repository in a CloudFormation template using the AWS::CodeCommit::Repository resource type, specifying properties such as RepositoryName and Code, and CloudFormation will create, update, and delete the repository as part of stack lifecycle management, making it ideal for automating resource creation.

Why this answer

AWS CloudFormation is the correct service because it allows you to define and provision AWS infrastructure as code using templates. You can declare an AWS::CodeCommit::Repository resource in a CloudFormation template, which will automatically create the CodeCommit repository when the stack is created, enabling fully automated and repeatable infrastructure deployment.

Exam trap

The trap here is that candidates may confuse AWS CodeStar's project templates (which can include a CodeCommit repository) with the ability to define infrastructure as code, but CodeStar does not provide the same declarative, version-controlled infrastructure management that CloudFormation offers.

How to eliminate wrong answers

Option B (AWS CodePipeline) is wrong because it is a continuous delivery service for building, testing, and deploying code changes, not for provisioning infrastructure resources like a CodeCommit repository. Option C (AWS CodeStar) is wrong because it is a project management and collaboration service that provides a unified interface for CI/CD pipelines, but it does not directly create CodeCommit repositories via infrastructure as code templates. Option D (AWS CodeBuild) is wrong because it is a fully managed build service that compiles source code and runs tests, not a service for defining or creating infrastructure resources.

53
Multi-Selectmedium

A team wants to run a CodeBuild project that builds a container image and pushes it to Amazon ECR, but the build currently fails with an access denied error when calling ecr:InitiateLayerUpload. The CodeBuild project uses a service role and runs in a VPC. Which TWO actions should the engineer take to resolve the error while keeping the build functional? (Choose two.)

Select 2 answers
A.Set the CodeBuild project's privileged mode to true so the Docker daemon can authenticate to Amazon ECR.
B.Change the buildspec to use the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables stored in plaintext.
C.Attach an IAM policy to the CodeBuild service role granting the required Amazon ECR push actions on the target repository.
D.Disable the CodeBuild service role and switch the project to use an IAM user's access keys for authentication.
E.If the build runs in a VPC, ensure a NAT gateway or VPC endpoint allows connectivity to Amazon ECR and its dependent services.
AnswersC, E

The access denied error indicates the build's AWS credentials lack permission for ECR push operations. Granting ecr:InitiateLayerUpload along with the related push actions such as ecr:PutImage and ecr:UploadLayerPart on the specific repository authorizes the docker push and directly resolves the failure.

Why this answer

The failure is an authorization and connectivity issue, not a Docker capability issue. Adding the required ECR push permissions to the CodeBuild service role authorizes the API calls, and ensuring the VPC can reach ECR endpoints allows the push to complete. Together these address both the permission and network dimensions of the error without introducing static credentials or unnecessary privileges.

Exam trap

The trap here is assuming privileged mode or static credentials fix an access denied error, when the error is about missing IAM permissions and, for VPC builds, missing network paths to ECR.

54
Multi-Selecteasy

Which THREE AWS services can be used as a source action in AWS CodePipeline? (Choose three.)

Select 3 answers
A.Amazon S3
B.Amazon DynamoDB
C.AWS CodeCommit
D.AWS CloudFormation
E.GitHub (via webhook)
AnswersA, C, E

Amazon S3 is a fully supported source action in AWS CodePipeline. You can store a single zip file or a set of files in an S3 bucket, and CodePipeline detects changes when the object version changes or via Amazon CloudWatch Events. The bucket must have versioning enabled so that each upload creates a new source artifact, which is then downloaded and extracted in the Source stage for subsequent build and deploy actions.

Why this answer

Amazon S3 is a supported source action in AWS CodePipeline because you can configure a pipeline to use an S3 bucket as a source location for your application code or artifacts. When you upload a new version of a file to the specified S3 bucket, CodePipeline can automatically detect the change (via Amazon CloudWatch Events or S3 event notifications) and start the pipeline execution. This is commonly used for deploying static websites or integrating with third-party CI/CD tools that output artifacts to S3.

Exam trap

The trap here is that candidates often confuse services that can be used as source actions (where code/artifacts originate) with services that can be used as deploy or test actions, leading them to incorrectly select CloudFormation (a deploy action) or DynamoDB (a database service) as source options.

55
MCQeasy

A DevOps engineer is designing a CI/CD pipeline for a serverless application using AWS Lambda and Amazon API Gateway. The team wants to automate deployment across multiple environments (dev, test, prod) with environment-specific configuration. Which approach should the engineer use?

A.Use the AWS Serverless Application Model (SAM) with CodePipeline, and pass environment parameters as CloudFormation parameter overrides.
B.Use CodeBuild to package the Lambda code and then use CloudFormation with parameters for each environment.
C.Use CodeDeploy with a deployment configuration that deploys to all environments sequentially.
D.Use CodePipeline with separate CodeBuild projects for each environment.
AnswerA

SAM is the only option that natively pairs with CodePipeline for serverless deployments: the pipeline can run `sam build` and `sam package` in a CodeBuild stage, then use a CloudFormation change set via the `CreateReplaceChangeSet` action. By specifying a `ParameterOverrides` JSON file (e.g., `stageName`, `environment`, `vpcConfig`) on that action, each environment (dev, test, prod) reuses the same pipeline definition yet receives its own configuration without duplicating stages or using manual scripts. SAM also generates the Lambda function, event sources, and permissions as a CloudFormation template, so environment-specific values propagate consistently through `AWS::Serverless::Function` properties and `!Ref` parameters.

Why this answer

AWS SAM is purpose-built for serverless applications and integrates natively with CodePipeline and CodeBuild. SAM templates are transformed into CloudFormation, so environment-specific values (memory, env vars, API stages) can be injected via CloudFormation parameter overrides at deploy time. This gives one template, many environments, with no custom scripting.

Exam trap

DOP-C02 often tests whether candidates confuse build orchestration (CodeBuild) with deployment orchestration (CodePipeline + CloudFormation/SAM), leading them to pick per-environment build projects instead of a single pipeline with parameter overrides.

How to eliminate wrong answers

Option B is wrong because CodeBuild only packages artifacts; it does not orchestrate multi-environment deployment or provide the SAM transform that simplifies Lambda/API Gateway resource definitions. Option C is wrong because CodeDeploy is for EC2/ECS/Lambda traffic shifting, not for sequential multi-environment pipeline orchestration, and it has no concept of environment parameters. Option D is wrong because separate CodeBuild projects per environment duplicate build logic and still lack a deployment mechanism that understands serverless resources or parameter overrides.

56
MCQhard

A company uses AWS CodePipeline to deploy a serverless application. The pipeline has a source stage (CodeCommit), a build stage (CodeBuild), and a deploy stage (CloudFormation). The deployment consistently fails because the Lambda function's IAM role is not created before the function. The team uses a single CloudFormation template. Which action should be taken to resolve this dependency issue?

A.Add a DependsOn attribute in the CloudFormation template to ensure the IAM role is created before the Lambda function.
B.Create the IAM role in a separate CodeBuild action before the deploy stage.
C.Add a wait condition in the CloudFormation template.
D.Separate the IAM role into a nested stack and reference it.
AnswerA

DependsOn is the correct CloudFormation mechanism to explicitly control resource creation order when there is no implicit dependency. Even though CloudFormation automatically creates a dependency when you use Ref or GetAtt in a resource property, there are cases where the Lambda function's IAM role ARN is substituted indirectly (e.g., via a parameter or a Fn::Sub in a string), so CloudFormation cannot infer the ordering. Adding DependsOn: IamRole to the Lambda function resource guarantees that the IAM role is fully created before the Lambda function is provisioned, preventing the deployment failure that occurs when Lambda tries to use a role that does not yet exist.

Why this answer

The CloudFormation template lacks an explicit dependency between the IAM role resource and the Lambda function resource. By adding a `DependsOn` attribute to the Lambda function resource, you ensure CloudFormation creates the IAM role first, resolving the deployment failure. This is the standard way to handle resource creation order within a single CloudFormation template.

Exam trap

The trap here is that candidates may assume CloudFormation automatically resolves all dependencies via intrinsic references, but when resources are referenced by name strings rather than logical IDs, explicit `DependsOn` is required to enforce creation order.

How to eliminate wrong answers

Option B is wrong because creating the IAM role in a separate CodeBuild action introduces unnecessary complexity and does not guarantee the role is available before the CloudFormation deploy stage; the role must exist in the same account and region before the template is applied. Option C is wrong because wait conditions are used to pause stack creation until an external signal is received, not to define resource dependencies within the same template. Option D is wrong because separating the IAM role into a nested stack does not inherently enforce creation order; you would still need a DependsOn or explicit reference to ensure the nested stack completes before the Lambda function is created.

57
MCQeasy

A company uses AWS Systems Manager Automation to patch EC2 instances. The automation document 'AWS-RunPatchBaseline' runs successfully but some instances are not patched because they are not managed by Systems Manager. What is the most likely reason?

A.The instances are running Windows Server 2012 or older.
B.The instances are in a VPC without internet access.
C.The instances do not have the AWS Systems Manager Agent (SSM Agent) installed and the required IAM role attached.
D.The automation document is not compatible with the instance's operating system.
AnswerC

The SSM Agent is the software component that executes Systems Manager requests on the instance, and the instance must also have an instance profile with IAM permissions to call Systems Manager APIs and download patch content. Without the agent or a role such as AmazonSSMManagedInstanceCore, the instance will not show up as a managed node and the automation cannot even target or initiate patching. This is the definitive prerequisite that is missing in this scenario.

Why this answer

Systems Manager Automation can only patch instances that are managed by Systems Manager. For an instance to be managed, it must have the SSM Agent installed and running, and it must have an IAM role that grants the necessary permissions (e.g., AmazonSSMManagedInstanceCore) to communicate with the Systems Manager service. Without these prerequisites, the instance is not registered as a managed node, so the automation document cannot target or patch it.

Exam trap

The trap here is that candidates may assume patching failures are due to network connectivity or OS compatibility, when the root cause is almost always the missing SSM Agent or missing IAM role that prevents the instance from being managed by Systems Manager.

How to eliminate wrong answers

Option A is wrong because Windows Server 2012 or older is still supported by Systems Manager Patch Manager as long as the SSM Agent is installed and the instance is managed; the OS version alone does not prevent management. Option B is wrong because instances in a VPC without internet access can still be managed by Systems Manager if they use a VPC endpoint (interface or gateway endpoint) for Systems Manager and Amazon S3, or if they use a proxy or NAT gateway; lack of internet access does not inherently block management. Option D is wrong because the 'AWS-RunPatchBaseline' document is compatible with both Windows and Amazon Linux operating systems; incompatibility is not the reason for instances being unmanaged.

58
MCQeasy

A startup is using AWS CodeBuild to build and test their application. The build process takes about 10 minutes. Recently, they noticed that some builds are failing randomly with the error 'Could not download dependencies'. The build environment uses a custom Docker image stored in Amazon ECR. The team suspects that the issue is due to network connectivity problems when pulling the Docker image or dependencies from the internet. They want to ensure reliable and faster builds. Which solution should they implement?

A.Switch to using a public Docker image from Docker Hub
B.Increase the build timeout in CodeBuild project settings
C.Use a larger compute type for the CodeBuild project
D.Configure CodeBuild to use a VPC with a NAT gateway
AnswerD

Configuring CodeBuild to use a VPC with a NAT gateway is the correct solution because it provides a deterministic, controlled egress path for outbound internet traffic. By running the build in private subnets behind a NAT gateway that routes via an Internet Gateway, the build environment can reliably pull layers from Docker Hub, install packages, and access private VPC resources. This overrides the default AWS-managed network's unpredictable connectivity and gives you proper security group and routing control, making the build network behavior explicit and dependable.

Why this answer

To improve reliability and speed, configure CodeBuild to use a VPC with a NAT gateway. This provides consistent internet access for pulling dependencies and Docker images, and allows using VPC endpoints for Amazon ECR, reducing network failures. Option D is correct.

Option A (using a public Docker Hub) does not address the underlying network issues and may introduce additional points of failure. Option B (increasing build timeout) does not fix the root cause of connectivity problems. Option C (using a larger compute type) does not resolve network connectivity issues.

59
MCQmedium

A DevOps engineer is designing a CI/CD pipeline for a serverless application using AWS Lambda. They want to automatically deploy the latest version of the Lambda function to production after running integration tests. The source code is in AWS CodeCommit. Which pipeline configuration should they use?

A.CodeCommit -> CodeBuild (test) -> CodeDeploy (Lambda deployment) -> Lambda.
B.CodeCommit -> CodeBuild (test) -> Lambda (deploy via update-function-code).
C.CodeCommit -> Lambda (deploy via S3 trigger) -> CodeBuild (test) -> production.
D.CodeCommit -> CodeBuild (test and deploy) -> Lambda via AWS CLI in buildspec.
AnswerA

This is correct because CodeDeploy natively supports Lambda deployment with canary, linear, and all-at-once traffic-shifting strategies, letting you validate a new version before promoting it. CodeBuild runs automated tests first, then CodeDeploy updates the Lambda alias gradually, monitoring CloudWatch alarms for automatic rollback. This is the AWS-recommended managed deployment path for serverless applications.

Why this answer

It uses CodeDeploy's built-in Lambda deployment support, which enables safe, gradual traffic shifting (e.g., canary or linear deployments) and automatic rollback on CloudWatch alarm failures. This pipeline integrates CodeCommit for source, CodeBuild for integration tests, and CodeDeploy to orchestrate the Lambda update with minimal risk, aligning with AWS best practices for serverless CI/CD.

Exam trap

The trap here is that candidates assume any pipeline that runs tests before deploying to Lambda is sufficient, but the exam specifically tests the need for managed deployment strategies (CodeDeploy) over direct API calls or CLI commands to ensure production safety and rollback capabilities.

How to eliminate wrong answers

Option B is wrong because calling Lambda's update-function-code API directly from CodeBuild bypasses deployment safety features like traffic shifting, rollback, and pre/post-traffic hooks, which are critical for production deployments. Option C is wrong because triggering a Lambda deployment via an S3 trigger before running tests violates the CI/CD principle of testing before deployment, and S3 triggers are asynchronous and lack deployment orchestration. Option D is wrong because using the AWS CLI in a buildspec to deploy Lambda functions lacks the managed deployment strategies (e.g., canary, linear) and automatic rollback capabilities that CodeDeploy provides, making it error-prone for production.

60
MCQeasy

A DevOps engineer is setting up a CI/CD pipeline using AWS CodePipeline and AWS CodeBuild. The build environment requires specific software packages that are not available in the default CodeBuild environment. What is the MOST efficient way to customize the build environment?

A.Create a separate pipeline to pre-build the environment.
B.Add install commands in the buildspec file to install the packages during each build.
C.Modify the buildspec file to set environment variables that include the software packages.
D.Create a custom Docker image with the required software and push it to Amazon ECR.
AnswerD

Creating a custom Docker image that includes all required software and pushing it to Amazon ECR lets you reference that image in the CodeBuild project's environment, so CodeBuild launches build containers from a pre-baked image. This avoids repeated package installation on every run, significantly reducing build time and removing dependence on internet-accessible package repositories during the build. The image provides a deterministic and immutable toolchain, which improves reproducibility, and you can version the image (using tags or image digests) and update it via its own build pipeline for rolling upgrades.

Why this answer

Creating a custom Docker image with the required software and pushing it to Amazon ECR allows you to pre-configure the build environment with all necessary packages. This approach avoids the overhead of installing packages during each build, reduces build time, and ensures consistency across builds. AWS CodeBuild supports custom images from Amazon ECR, making this the most efficient method for customizing the environment.

Exam trap

The trap here is that candidates often confuse environment variables with actual software installation, thinking that setting variables in the buildspec file can bring in packages, when in fact environment variables only affect runtime behavior, not the software available in the build environment.

How to eliminate wrong answers

Option A is wrong because creating a separate pipeline to pre-build the environment introduces unnecessary complexity and overhead; it does not directly customize the CodeBuild environment for the main pipeline. Option B is wrong because adding install commands in the buildspec file to install packages during each build is inefficient, as it repeats the installation process for every build, increasing build time and potential for failure. Option C is wrong because modifying the buildspec file to set environment variables does not install software packages; environment variables only configure runtime settings, not the software dependencies themselves.

61
MCQmedium

A company uses AWS CodePipeline with a manual approval stage before deploying to production. The approval notification is sent via Amazon SNS. The approvers report that they are not receiving the email notifications. What should the DevOps engineer check first?

A.Confirm that the email subscriptions to the SNS topic have been confirmed by clicking the link in the initial confirmation email.
B.Ensure that the IAM role for CodePipeline has permission to publish to the SNS topic.
C.Verify that the SNS topic's subscription has a filter policy that matches the approval event.
D.Check the email recipients' mailbox quota to see if it is full.
AnswerA

SNS email subscriptions start in the 'Pending Confirmation' state; SNS sends an initial confirmation email to the endpoint and no notifications are delivered until the recipient clicks the link in that message. If the recipient never confirms, the subscription stays inactive, so even though CodePipeline publishes approval messages to the topic, SNS discards them for that unconfirmed endpoint. Therefore, confirming the subscription is the correct first troubleshooting step.

Why this answer

Amazon SNS requires that email subscribers confirm their subscription by clicking the link in the initial confirmation email before they can receive notifications. If the approvers never confirmed the subscription, the SNS topic will not deliver any messages to them, even though the pipeline and IAM permissions are correctly configured. This is the most common cause of missing SNS email notifications and should be the first check.

Exam trap

The trap here is that candidates often jump to IAM permissions or SNS configuration details, overlooking the fundamental requirement that email subscriptions must be explicitly confirmed before any notifications can be delivered.

How to eliminate wrong answers

Option B is wrong because CodePipeline does not need an IAM role to publish to SNS; the pipeline uses an SNS topic ARN and the publish action is performed by the pipeline service itself, which already has the necessary permissions via the service-linked role. Option C is wrong because SNS filter policies are optional and used to filter messages based on attributes; the approval notification does not require a filter policy to be delivered, and a missing or mismatched filter policy would not prevent the initial subscription confirmation email. Option D is wrong because mailbox quota issues would cause bounce or rejection after delivery, but the core problem is that the subscription itself is not confirmed, so no emails are ever sent.

62
Multi-Selectmedium

A company uses AWS CloudFormation to provision infrastructure. They have a stack that creates an Amazon RDS DB instance. They want to update the stack to change the DB instance class from db.t2.micro to db.t3.medium. Which THREE of the following must be true for the update to succeed? (Choose three.)

Select 3 answers
A.The stack must not be in a state that prevents updates, such as ROLLBACK_COMPLETE.
B.Deletion protection must be disabled on the DB instance.
C.The new DB instance class must be available in the same VPC and subnet group as the existing DB instance.
D.The IAM role used by CloudFormation must have permissions to modify the RDS instance.
E.A change set must be created and executed for the update.
AnswersA, C, D

CloudFormation refuses to update any stack in a failed terminal state such as ROLLBACK_COMPLETE, because the stack's resources are in an inconsistent or partially provisioned state. The stack must be deleted and recreated (or, if applicable, brought back to a workable state via ContinueUpdateRollback for other rollback states) before an update operation can run.

Why this answer

CloudFormation stacks in a terminal failure state like ROLLBACK_COMPLETE cannot be updated; they must be deleted and recreated. This is a fundamental constraint of the CloudFormation service, as the stack is considered non-functional and unable to process further operations.

Exam trap

The trap here is that candidates often confuse deletion protection with modification protection, assuming it blocks all changes, when in fact it only blocks deletion operations.

63
MCQmedium

A company is using AWS CodeBuild to run integration tests. The tests require access to an Amazon RDS instance in a private subnet. The CodeBuild project is configured with a VPC ID, subnet IDs, and security group IDs. However, the tests fail with a connection timeout. What is the MOST likely cause?

A.The security group attached to the RDS instance does not allow inbound traffic from the CodeBuild security group.
B.The CodeBuild project does not have internet access to download packages.
C.The CodeBuild project is not associated with a VPC.
D.The RDS instance is not publicly accessible and requires a NAT gateway.
AnswerA

CodeBuild placed in the VPC uses its own security group as the traffic source. If the RDS security group lacks an inbound rule permitting that CodeBuild security group on the database port, connections time out, matching the stem's VPC-configured constraint.

Why this answer

The most likely cause is that the security group attached to the RDS instance does not allow inbound traffic from the CodeBuild security group. CodeBuild runs inside the VPC using the specified security group, so it sends traffic to the RDS instance on port 3306 (or the appropriate database port). If the RDS security group's inbound rules do not explicitly permit traffic from the CodeBuild security group (or its CIDR), the connection is dropped, resulting in a timeout.

Exam trap

The trap here is that candidates often assume a NAT gateway or internet access is required for VPC-based resources, but the core issue is security group ingress rules, not network connectivity to the internet.

How to eliminate wrong answers

Option B is wrong because CodeBuild projects configured with a VPC can access the internet via a NAT gateway or VPC endpoints if needed, but the failure here is a connection timeout to RDS, not a package download issue. Option C is wrong because the question states the CodeBuild project is configured with a VPC ID, subnet IDs, and security group IDs, so it is associated with a VPC. Option D is wrong because RDS instances in private subnets do not need to be publicly accessible; CodeBuild can reach them directly via the VPC without a NAT gateway, as long as security group rules and network ACLs permit the traffic.

64
MCQhard

An organization uses AWS CodePipeline to orchestrate deployments to multiple environments (dev, test, prod). Each environment uses a different AWS account. The pipeline uses cross-account actions with IAM roles. Recently, the pipeline failed at the deploy stage for the prod account with the error 'Access Denied' when assuming the cross-account role. The role ARN is correct and the trust policy allows the pipeline's service role. What is the MOST likely cause?

A.The EC2 instances in the prod account do not have an appropriate instance profile.
B.The pipeline's service role lacks the `sts:AssumeRole` permission for the cross-account role.
C.The cross-account role's permissions boundary denies the deploy action.
D.The pipeline's service role does not have permission to perform the deploy action in the prod account.
AnswerB

For cross-account deployments, the pipeline service role in the source account must contain a policy that explicitly grants the `sts:AssumeRole` action on the ARN of the destination account's cross-account role. This is in addition to the trust policy on the cross-account role that allows the service role to assume it. Without this permission, CodePipeline's attempt to switch into the production account fails with a 403 AccessDenied at the AssumeRole step, which is exactly the described symptom. This is the root cause of the deployment failure.

Why this answer

The pipeline's service role must have an `sts:AssumeRole` permission on the cross-account role to perform the role assumption. Even if the trust policy on the cross-account role allows the pipeline's service role, the pipeline's service role itself needs an IAM policy granting `sts:AssumeRole` for the cross-account role ARN. Without this permission, the `AssumeRole` API call fails with 'Access Denied', which is the exact error described.

Exam trap

The trap here is that candidates often focus on the cross-account role's trust policy or permissions, forgetting that the pipeline's service role also needs explicit `sts:AssumeRole` permission, which is a separate IAM policy requirement.

How to eliminate wrong answers

Option A is wrong because the error occurs during the cross-account role assumption, not during an EC2 instance action; instance profiles are irrelevant to CodePipeline cross-account deployments. Option C is wrong because a permissions boundary on the cross-account role would limit the maximum permissions of the assumed role, but the error is 'Access Denied' at the assumption step, not during the deploy action itself. Option D is wrong because the pipeline's service role does not directly perform deploy actions in the prod account; it assumes the cross-account role, and the cross-account role's permissions govern the deploy action.

65
Multi-Selecthard

A DevOps team is using AWS CodeBuild to run integration tests against a test database. The database is an Amazon RDS instance in a private subnet. The CodeBuild project is configured to run in a VPC. Which THREE steps are required to allow CodeBuild to access the RDS instance?

Select 3 answers
A.Place the RDS instance in a public subnet with a public IP.
B.Ensure the security group attached to the RDS instance allows inbound traffic from the CodeBuild security group.
C.Attach a NAT gateway to the VPC so that CodeBuild can route to RDS.
D.Ensure the VPC's route tables have routes to allow traffic between CodeBuild subnets and RDS subnets.
E.Configure the CodeBuild project to use a VPC that has access to the RDS instance.
AnswersB, D, E

Security groups act as a virtual firewall at the instance level. By referencing the CodeBuild project's security group as a source in the RDS security group's inbound rule, you allow traffic specifically from the Elastic Network Interfaces (ENIs) that CodeBuild uses when it runs inside the VPC. This is the most direct and least-privileged way to permit the integration tests to reach RDS, because it avoids opening the database to CIDR ranges or the entire VPC. It also updates automatically if CodeBuild's IP addresses change, as long as the security group ID remains the same.

Why this answer

The security group attached to the RDS instance must explicitly allow inbound traffic from the security group associated with the CodeBuild project's elastic network interfaces. This is a fundamental network access control in AWS: security groups act as virtual firewalls, and without an inbound rule permitting traffic from the CodeBuild security group on the database port (e.g., 3306 for MySQL), the connection will be blocked regardless of other network configurations.

Exam trap

The trap here is that candidates often confuse the need for a NAT gateway (which is for internet access) with the requirement for internal VPC routing, or they mistakenly think that placing RDS in a public subnet is necessary for CodeBuild to reach it, when in fact private subnet communication via security groups and route tables is the correct approach.

66
MCQmedium

A team uses AWS CloudFormation to manage infrastructure. They want to automatically update the stack when a new version of a Docker image is pushed to Amazon ECR. Which approach should they use?

A.Configure an Amazon EventBridge rule to detect ECR image pushes and invoke an AWS Lambda function that calls 'UpdateStack' with the new image URI.
B.Create a CodeBuild project that triggers on ECR push, and have the build execute an 'aws cloudformation update-stack' command.
C.Use AWS CodeDeploy with a trigger on ECR push to deploy the new image to a target group, and have the target group update the stack.
D.Set up an Amazon SNS topic subscribed to ECR image push events, and have the SNS topic send a notification to an AWS CloudFormation stack update endpoint.
AnswerA

This is correct because Amazon EventBridge natively captures ECR image push events (e.g., the 'ECR Image Action' event type) and can directly target an AWS Lambda function. Lambda can then call CloudFormation's UpdateStack API, passing the new image URI as a parameter to the stack, thereby updating the infrastructure in an event-driven, serverless manner. This pattern is simple, requires no persistent compute, and integrates seamlessly with CloudFormation's parameter-based updates.

Why this answer

Amazon EventBridge can detect ECR image push events and trigger an AWS Lambda function. The Lambda function can then call the CloudFormation UpdateStack API with the new image URI, automating the stack update. This approach is serverless, event-driven, and directly integrates with CloudFormation, making it the most efficient and least operational overhead solution.

Exam trap

DOP-C02 often tests the integration between AWS services for automation; candidates might incorrectly assume that SNS can directly trigger CloudFormation updates or that CodeBuild/CodeDeploy can natively respond to ECR events, overlooking the need for EventBridge and Lambda.

How to eliminate wrong answers

Option B is wrong because CodeBuild is not designed to trigger on ECR push events natively; it would require additional configuration like CloudWatch Events, and it adds unnecessary complexity. Option C is wrong because CodeDeploy is for deploying applications to EC2/on-premises or ECS, not for updating CloudFormation stacks; it does not have a direct mechanism to update a stack. Option D is wrong because SNS cannot directly invoke a CloudFormation stack update; CloudFormation does not provide an SNS endpoint for stack updates, and this approach would require additional compute to process the notification.

67
MCQhard

An organization uses AWS CloudFormation to manage infrastructure across multiple accounts using AWS Organizations. They want to enforce that all S3 buckets are encrypted with SSE-S3. A DevOps engineer creates a service control policy (SCP) to deny the creation of any S3 bucket without encryption. However, CloudFormation stack creation fails with an access denied error even when the template includes encryption. What is the most likely cause?

A.The CloudFormation template specifies SSE-KMS encryption, which is not allowed by the SCP.
B.The SCP is denying the s3:PutBucketPublicAccessBlock action, which is required for all bucket creation requests.
C.The SCP is incorrectly scoped to the management account instead of the member accounts.
D.The CloudFormation service role does not have permissions to create buckets in the target account.
AnswerA

Correct. SCPs are service control policies that set maximum permissions for all IAM principals in an account, and they can include conditions that deny S3 bucket creation when SSE-KMS is specified. If the organization's SCP only allows SSE-S3 encryption (or denies kms:GenerateDataKey or kms:CreateGrant), then any CloudFormation template that specifies SSE-KMS encryption for the bucket will be rejected with an AccessDenied error, regardless of the IAM service role or the target bucket configuration. This perfectly matches the scenario where the error occurs only when certain encryption settings are present in the template.

Why this answer

The SCP denies the creation of S3 buckets without encryption, but it specifically allows only SSE-S3 encryption. If the CloudFormation template specifies SSE-KMS encryption, the SCP will deny the request, causing an access denied error—even though encryption is present. This mismatch between the encryption type required by the SCP (SSE-S3) and what the template requests (SSE-KMS) is the most likely cause of the failure.

Exam trap

The trap is assuming that any encryption (SSE-S3 or SSE-KMS) satisfies the SCP requirement. However, SCPs can be very specific; if the SCP only allows SSE-S3, then using SSE-KMS will be denied. Candidates may overlook the distinction between encryption types.

How to eliminate wrong answers

Option A is wrong because SSE-KMS is a form of encryption; if the SCP denies bucket creation without encryption, specifying SSE-KMS would satisfy the encryption requirement, so it would not cause an access denied error. Option B is wrong because s3:PutBucketPublicAccessBlock is not required for all bucket creation requests; it is an optional action to block public access, and denying it would not prevent bucket creation—only the ability to set public access settings. Option D is wrong because the CloudFormation service role's permissions are separate from SCPs; if the role lacks permissions, the error would be an authorization failure, but the question explicitly states the SCP is the cause, and SCPs cannot be overridden by IAM roles—they act as a boundary, so the role's permissions are irrelevant if the SCP denies the action.

68
MCQmedium

An organization uses AWS CodeDeploy to deploy applications to Amazon EC2 instances. The deployment is failing consistently with the error 'ScriptMissing' for the AppSpec lifecycle hook 'ApplicationStop'. The scripts are located in the /opt/scripts directory on the instances. What is the most likely cause of this error?

A.The ApplicationStop hook is not defined in the AppSpec file.
B.The CodeDeploy agent is not the latest version.
C.The AppSpec file specifies a path to the script that does not exist on the instance.
D.The scripts have incorrect file permissions.
AnswerC

The AppSpec hooks section contains a location field that must point to a script actually present in the extracted application revision. During a lifecycle event, the agent resolves that path against the deployment archive's directory structure; if the file is not there—perhaps due to a typo, an absolute path instead of a relative one, or omitted from the bundle—the operating system returns ENOENT and CodeDeploy reports ScriptMissing. Fixing the AppSpec path to match the bundled script resolves the deployment.

Why this answer

The 'ScriptMissing' error in AWS CodeDeploy indicates that the deployment lifecycle hook (in this case, 'ApplicationStop') cannot find the script file at the path specified in the AppSpec file. Since the scripts are located in /opt/scripts, the most likely cause is that the AppSpec file's 'location' field for the ApplicationStop hook points to a path that does not match the actual file location on the instance, or the script file itself is missing from that directory.

Exam trap

The trap here is that candidates often confuse 'ScriptMissing' with permission errors or agent issues, but AWS specifically uses 'ScriptMissing' to indicate the file path is incorrect or the file is absent, not that the file exists but cannot be executed.

How to eliminate wrong answers

Option A is wrong because if the ApplicationStop hook were not defined in the AppSpec file, CodeDeploy would not attempt to run it and would not produce a 'ScriptMissing' error; instead, it would simply skip that hook. Option B is wrong because the CodeDeploy agent version does not affect script path resolution; 'ScriptMissing' is a file-not-found error, not an agent compatibility issue. Option D is wrong because incorrect file permissions would cause a 'ScriptFailed' or permission-denied error, not a 'ScriptMissing' error, which specifically indicates the script file cannot be located at the given path.

69
MCQmedium

Refer to the exhibit. A DevOps engineer runs the command to get the pipeline definition. The pipeline has a source stage from an S3 bucket and a build stage with CodeBuild. The CodeBuild project is configured to output artifacts to a specific S3 bucket. However, the pipeline fails at the build stage with an error: 'Artifact 'BuildArtifact' is not found'. What is the most likely cause?

A.The source stage is using CodeCommit instead of S3.
B.The source artifact is not being passed to the build stage.
C.The IAM role for CodePipeline does not have permissions to read from the S3 bucket.
D.The CodeBuild project is not configured to output the expected artifact named 'BuildArtifact'.
AnswerD

CodeBuild only produces output artifacts if the project (or buildspec `artifacts` section) is configured to do so with a matching name. The pipeline's Build action expects an output artifact literally named 'BuildArtifact'; if the CodeBuild project defines a different artifact name, or omits artifact output entirely, the build may succeed but the pipeline's build stage will fail when resolving the expected artifact. This mismatch is the most common reason for a Build stage failure when the build logs show a successful build.

Why this answer

The error 'Artifact 'BuildArtifact' is not found' indicates that CodePipeline expects an artifact named 'BuildArtifact' from the CodeBuild project, but the project's output artifact configuration does not include that name. In CodePipeline, the build stage must produce an artifact with the exact name specified in the pipeline definition; if the CodeBuild project's artifacts section (in buildspec.yml or console) omits or misnames it, the pipeline fails at that stage.

Exam trap

The trap here is that candidates often confuse permission errors (IAM) with artifact naming mismatches, or assume the source stage is misconfigured, when the real issue is a simple name mismatch between the pipeline's expected output artifact and the CodeBuild project's actual output artifact.

How to eliminate wrong answers

Option A is wrong because the source stage is explicitly configured with an S3 bucket (as per the exhibit), and using CodeCommit would not cause a 'BuildArtifact not found' error—it would affect source retrieval, not artifact naming. Option B is wrong because the source artifact is passed to the build stage by default via the pipeline's artifact store; the error is about the output artifact from CodeBuild, not the input. Option C is wrong because insufficient IAM permissions to read from the S3 bucket would produce an access denied error (e.g., 'AccessDenied' or '403 Forbidden'), not a 'not found' error for a named artifact.

70
MCQeasy

A DevOps team uses AWS CodeBuild to compile code and run unit tests. The team notices that builds are failing with a timeout error after 60 minutes. What is the most likely cause and solution?

A.The buildspec has syntax errors; validate the YAML.
B.The build environment is too small; increase compute type.
C.The source code repository is too large; use shallow clone.
D.The build timeout limit is exceeded; increase the timeout in CodeBuild project settings.
AnswerD

CodeBuild projects have a configurable 'Timeout' property (default 60 minutes) that caps the total time from build start to the last phase, including download, install, build, and post-build. When a build runs past this limit, CodeBuild forcibly terminates it and records a 'BUILD_TIMEOUT' error, which matches the scenario described. To resolve it, the DevOps team can increase the timeout in the CodeBuild project settings (via console, AWS CLI, or CloudFormation), setting it up to 480 minutes (8 hours) for standard builds. This directly addresses the root cause rather than masking a resource or syntax problem.

Why this answer

The default build timeout for AWS CodeBuild is 60 minutes. When a build runs longer than this limit, it fails with a timeout error. The correct solution is to increase the timeout value in the CodeBuild project settings, which can be set up to a maximum of 8 hours (480 minutes) for on-demand compute environments.

Exam trap

The trap here is that candidates may confuse a timeout error with resource constraints (like compute size) or source code issues, but the specific 60-minute failure point is a direct indicator of the default build timeout being exceeded.

How to eliminate wrong answers

Option A is wrong because syntax errors in the buildspec YAML would cause immediate build failures with parse errors, not a timeout after exactly 60 minutes. Option B is wrong because an undersized compute environment would manifest as slow performance or resource exhaustion errors (e.g., memory or disk), not a consistent timeout at the 60-minute mark. Option C is wrong because a large source repository would cause slow clone operations, but CodeBuild's default clone timeout is 10 minutes, and the overall build timeout is independent of clone time; shallow clone reduces clone time but does not address a 60-minute timeout on the entire build process.

71
MCQhard

Your company uses AWS CodePipeline to automate the deployment of a critical web application. The pipeline consists of a source stage (CodeCommit), a build stage (CodeBuild), and a deploy stage (CodeDeploy) that deploys to an Auto Scaling group of EC2 instances running Amazon Linux 2. The deployment strategy is 'AllAtOnce'. Recently, the team noticed that during deployments, the application becomes completely unavailable for a few minutes until the new instances are registered with the load balancer. The business requires zero downtime during deployments. You need to modify the deployment process to achieve zero downtime while minimizing cost and complexity. The Auto Scaling group currently has a minimum of 2 instances and a maximum of 4 instances. The application is stateless and sessions are stored in ElastiCache. Which solution should you implement?

A.Create a second Auto Scaling group, deploy to it, and then update Route 53 to point to the new group.
B.Change the deployment configuration to 'HalfAtATime' to update half the instances at a time.
C.Use CodeDeploy's blue/green deployment with an Application Load Balancer. Create a new Auto Scaling group for the green environment, deploy to it, and then shift traffic.
D.Increase the Auto Scaling group's minimum size to 4 so there are always extra instances.
AnswerC

CodeDeploy's blue/green deployment with an Application Load Balancer is the correct solution because it provisions a completely new Auto Scaling group (the green environment) running the new revision and registers it with a new or existing target group. The ALB only shifts traffic to the green target group after all instances pass health checks, while the blue instances continue serving requests during the entire setup and validation. After a configurable wait time, the original blue ASG is terminated, ensuring no point where users have no service. This architecture provides true zero downtime because the old fleet remains fully operational until the new fleet is verified.

Why this answer

CodeDeploy blue/green deployments with an ALB allow traffic to be shifted from the original (blue) Auto Scaling group to a newly provisioned green Auto Scaling group only after the new instances pass health checks, so the application never becomes unavailable. Because the app is stateless and sessions live in ElastiCache, no session affinity or state migration is required, making this both low-risk and low-complexity. This directly satisfies the zero-downtime requirement without over-provisioning capacity.

Exam trap

DOP-C02 often tests the misconception that changing the deployment configuration (e.g., HalfAtATime) or adding instances is sufficient for zero downtime, when in fact only blue/green (or a rolling strategy with proper connection draining) with a load balancer achieves it.

How to eliminate wrong answers

Option A is wrong because manually creating a second Auto Scaling group and repointing Route 53 DNS is a hand-rolled blue/green that introduces DNS TTL delays, lacks automated traffic shifting/rollback, and adds significant operational complexity compared to CodeDeploy's native blue/green. Option B is wrong because 'HalfAtATime' is an in-place deployment that terminates and replaces instances within the same Auto Scaling group; during replacement the remaining instances may still be deregistering or warming up, and with a min of 2 instances, taking half offline can still cause availability gaps and does not guarantee zero downtime. Option D is wrong because simply raising the minimum size to 4 does not change the AllAtOnce deployment behavior — CodeDeploy still replaces all instances simultaneously, so the app still goes down; it only adds cost without solving the availability problem.

72
MCQeasy

A company uses AWS CodeBuild to run unit tests and package a Node.js application. The buildspec.yml file includes commands to install dependencies using npm. The build is failing with the error: 'npm ERR! code EACCES'. How should a DevOps engineer resolve this issue?

A.Configure the CodeBuild project to use a custom VPC with a NAT gateway for internet access
B.Configure the buildspec to run npm install with sudo
C.Add a command to change the ownership of the node_modules directory to the current user
D.Use 'npm ci' instead of 'npm install' and ensure a package-lock.json is present
AnswerD

Running `npm ci` instead of `npm install` is the recommended fix because it performs a clean, lockfile-driven installation and never attempts to modify the global package cache, thus eliminating the permission conflict. The presence of a valid `package-lock.json` ensures that exact dependency versions are resolved and installed without npm calculating a new dependency tree, which can trigger hidden writes to system locations. This approach is purpose-built for CI/CD pipelines and greatly reduces the chance of inconsistent state or permission failures.

Why this answer

The EACCES error in CodeBuild indicates a permission issue when npm tries to write to the node_modules directory. The default CodeBuild user (usually 'codebuild-user') lacks write permissions to the project root, which is owned by root. Using 'npm ci' (clean install) is the correct resolution because it bypasses the permission issue by using the package-lock.json to install dependencies deterministically, and it does not attempt to modify the lock file or run lifecycle scripts that may require elevated permissions.

Additionally, 'npm ci' is faster and more reliable in CI/CD environments like CodeBuild.

Exam trap

The trap here is that candidates often assume the EACCES error is a network or VPC issue (Option A) or that sudo is a quick fix (Option B), but the exam tests knowledge of npm's behavior in CI/CD and the deterministic install method 'npm ci' as the proper solution.

How to eliminate wrong answers

Option A is wrong because the EACCES error is a filesystem permission issue, not a network connectivity issue; a custom VPC with a NAT gateway addresses internet access for private subnets, not file write permissions. Option B is wrong because running npm install with sudo would escalate privileges unnecessarily and is considered a security anti-pattern in CI/CD; it also may not resolve the issue if the underlying user context still lacks proper ownership. Option C is wrong because changing ownership of node_modules does not fix the root cause—the directory may not exist yet, and the error occurs during the initial creation of node_modules, not after it exists.

73
MCQeasy

A developer is setting up AWS CodeBuild to compile a Go application. The build fails with the error: 'go: command not found'. What is the MOST likely cause?

A.The environment variables in buildspec.yml are incorrectly set
B.The build project does not have enough memory to compile Go code
C.The build environment image does not have the Go runtime installed
D.The CodeBuild service role does not have permission to access the S3 bucket for artifacts
AnswerC

The CodeBuild managed build image is version-specific and does not include every language runtime; for example, the Amazon Linux 2 x86_64 standard image version 3.0 has Java, Python, Node.js, and Ruby, but no Go binary on its PATH. When the buildspec runs 'go build', the shell returns 'go: command not found' because the executable is simply not installed in the selected image. The correct remedy is to select an image that includes Go (such as a newer standard image with the Go runtime), add a runtime-versions entry for golang, or provide a custom Dockerfile that installs Go.

Why this answer

The error 'go: command not found' indicates that the Go executable is not available in the build environment's PATH. CodeBuild uses a managed or custom build environment image (e.g., Ubuntu, Amazon Linux 2) to run build commands. If the image does not include the Go runtime, the shell cannot locate the 'go' binary, causing the build to fail.

The most direct fix is to select a build environment image that has Go pre-installed or to install Go in the install phase of the buildspec.

Exam trap

The trap here is that candidates often blame environment variables (Option A) or permissions (Option D) because they are common build failures, but the root cause is the missing runtime in the build environment image — a fundamental prerequisite that CodeBuild does not automatically provide.

How to eliminate wrong answers

Option A is wrong because environment variables in buildspec.yml control runtime behavior (e.g., GOPATH, GO111MODULE) but do not cause a 'command not found' error; the shell would still find the 'go' binary if it exists in PATH. Option B is wrong because insufficient memory leads to out-of-memory (OOM) kills or build timeouts, not a 'command not found' error; the Go compiler itself would be invoked before memory limits become an issue. Option D is wrong because S3 bucket permissions affect artifact uploads or cache retrieval, not the execution of build commands; the 'go' binary would still be found and run regardless of S3 access.

74
MCQeasy

A company uses AWS CodeBuild to run unit tests as part of a CI pipeline. The buildspec.yaml file is located in the root of the source repository. The build takes 30 minutes to complete. The team wants to speed up the build by caching dependencies. Which approach should they take?

A.Download dependencies from the internet each time the build runs.
B.Mount an Amazon EFS file system to the build container and store dependencies there.
C.Configure the buildspec.yaml to enable local caching and specify the paths to cache.
D.Store dependencies in an AWS CodeCommit repository and clone it during the build.
AnswerC

Local caching in CodeBuild persists declared dependency directories between builds on the same host, so package managers such as npm or Maven skip re-downloading. Specifying cache paths in buildspec.yaml directly cuts the 30-minute runtime without altering the pipeline structure.

Why this answer

CodeBuild supports caching dependencies to speed up builds. The simplest native approach is to enable caching in the buildspec.yaml using the cache configuration, specifying local caching paths (e.g., /root/.m2 for Maven or /root/.cache/pip for pip) so dependencies are preserved between builds on the same build environment. This avoids re-downloading dependencies from the internet each time and can significantly reduce build time.

Note that CodeBuild also supports Amazon S3 caching, and EFS can be mounted for shared storage, but local caching is the most direct and commonly recommended option for dependency caching within the buildspec.

Exam trap

Candidates may assume any persistent storage (EFS, S3, CodeCommit) will speed up builds, but the question asks for the approach configured in buildspec.yaml. Local caching is the native, buildspec-level caching mechanism for dependencies, though S3 caching is also valid in other contexts.

How to eliminate wrong answers

Option A is wrong because downloading dependencies from the internet each time is the current slow behavior the team wants to avoid, and it does not implement any caching mechanism. Option B is wrong because mounting an Amazon EFS file system introduces network latency and I/O overhead, which can actually slow down the build, and EFS is not designed for high-frequency dependency caching in ephemeral build containers; it also requires additional VPC configuration and security group management. Option D is wrong because storing dependencies in a CodeCommit repository and cloning them during the build adds unnecessary network transfer and storage costs, and does not provide the incremental caching benefit that local caching offers.

75
MCQeasy

A DevOps engineer wants to automate the creation and cleanup of temporary development environments on AWS. Each environment consists of an Amazon EC2 instance and an Amazon RDS database. The environments should be isolated and cost-effective. Which AWS service is best suited for this?

A.AWS Elastic Beanstalk
B.AWS CloudFormation
C.AWS OpsWorks
D.Amazon ECS
AnswerB

AWS CloudFormation is the definitive Infrastructure-as-Code service that uses declarative JSON/YAML templates to provision and manage all resources in a stack, including EC2 instances, RDS databases, VPCs, and security groups as a single unit. Stack creation handles dependency ordering and rollback on failure, while stack deletion removes the complete set of resources, enabling reliable automation of ephemeral environments. The ability to set a deletion policy on resources like RDS allows you to control whether the database is retained or deleted, making cleanup predictable and safe.

Why this answer

AWS CloudFormation is best suited because it allows you to define the entire temporary environment—EC2 instance and RDS database—as infrastructure as code (IaC) in a single template. You can create and delete the entire stack with one API call, ensuring isolation via separate stacks and cost-effectiveness by automating cleanup when the stack is deleted.

Exam trap

The trap here is that candidates confuse AWS Elastic Beanstalk's environment management (which does create EC2 and RDS) with the ability to easily and cost-effectively tear down temporary environments, but Elastic Beanstalk environments are designed for persistent applications and lack the simple, automated stack deletion that CloudFormation provides for ephemeral workloads.

How to eliminate wrong answers

Option A is wrong because AWS Elastic Beanstalk is a PaaS service that abstracts underlying infrastructure, but it does not provide native, automated stack-level cleanup for temporary environments; it manages long-running applications and lacks the granular, one-shot creation/deletion lifecycle needed for ephemeral dev environments. Option C is wrong because AWS OpsWorks is a configuration management service based on Chef/Puppet, designed for managing long-lived server configurations and deployments, not for automating the creation and teardown of isolated, temporary infrastructure stacks. Option D is wrong because Amazon ECS is a container orchestration service for running Docker containers, not for provisioning EC2 instances and RDS databases as a coordinated, isolated environment; it focuses on container lifecycle, not infrastructure provisioning and cleanup.

Page 1 of 5 · 316 questions totalNext →

Ready to test yourself?

Try a timed practice session using only SDLC Automation questions.