AWS Certified DevOps Engineer – Professional (DOP-C02) — Question 255
A company uses the AWS Cloud Development Kit (AWS CDK) to define its application. The company uses a pipeline that consists of AWS CodePipeline and AWS CodeBuild to deploy the CDK application.
The company wants to introduce unit tests to the pipeline to test various infrastructure components. The company wants to ensure that a deployment proceeds if no unit tests result in a failure.
Which combination of steps will enforce the testing requirement in the pipeline? (Choose two.)
Answer options
- A. Update the CodeBuild build phase commands to run the tests then to deploy the application. Set the OnFailure phase property to ABORT.
- B. Update the CodeBuild build phase commands to run the tests then to deploy the application. Add the --rollback true flag to the cdk deploy command.
- C. Update the CodeBuild build phase commands to run the tests then to deploy the application. Add the --require-approval any-change flag to the cdk deploy command.
- D. Create a test that uses the AWS CDK assertions module. Use the template.hasResourceProperties assertion to test that resources have the expected properties.
- E. Create a test that uses the cdk diff command. Configure the test to fail if any resources have changed.
Correct answer: A, D
Explanation
Option A is correct because it ensures that the tests are run before deployment, and setting the OnFailure phase property to ABORT allows the pipeline to proceed if tests pass. Option D is also correct as it involves creating a test that checks resource properties, which is a key aspect of validating infrastructure. The other options either do not fulfill the requirement of proceeding with deployment upon test success or do not pertain to unit testing.