DOP-C02 Question 108
Single answerYour company is using AWS CodePipeline to automate the deployment of a serverless application. The pipeline has the following stages: Source, Build, Deploy, and Test. During the Deploy stage, the application is deployed to AWS Lambda using AWS CloudFormation. Recently, deployments have been failing intermittently during the Deploy stage due to a race condition between resource updates. How can you address this issue to ensure consistent deployments?
- A
Enable the 'Rollback on failure' option in the CloudFormation stack settings.
- B
Add a dependency explicitly in the CloudFormation template to define the order of resource creation.
- C
Increase the build timeout in the Build stage of the pipeline.
- D
Enable retries in AWS CodePipeline for the Deploy stage.
Show answer and explanation
Correct answer: B
Explanation
Race conditions during resource updates in AWS CloudFormation occur when the creation of one resource depends on another, but the dependency is not clearly defined in the template. By explicitly specifying the dependency in the CloudFormation template, you ensure that resources are created or updated in the correct order, eliminating the race condition. Other options, such as enabling rollback or retries, do not solve the root cause of the issue.
- A. Incorrect.
Enabling 'Rollback on failure' ensures that the stack is cleaned up when a failure occurs, but it does not address the root cause of the race condition.
- B. Correct.
Adding a dependency explicitly in the CloudFormation template ensures that resources are created in a specific order, which resolves race conditions during deployments.
- C. Incorrect.
Increasing the build timeout in the Build stage does not affect the Deploy stage or resolve race conditions in resource updates.
- D. Incorrect.
Enabling retries in AWS CodePipeline can retry failed deployments, but it does not address the underlying race condition causing the failures.