A developer initialized a new AWS CDK project in CodeCommit and must (1) write unit tests for the generated IaC templates and (2) run a validation across all CDK constructs to ensure key security configurations are enforced. Which combination of actions provides these checks with the least development overhead? (Choose two.)
Choose an answer
Tap an option to check your answer.
Correct answer: Use the CDK assertions library to create unit tests integrated with the application, and run these tests in the CI/CD pipeline on every commit., Implement custom CDK Aspects to enforce rules across constructs and cause synthesis to fail on violations..
Why this is the answer
The CDK assertions library is designed for testing CDK applications. It allows developers to write unit tests that verify the synthesized CloudFormation templates, ensuring the infrastructure behaves as expected. Running these tests in a CI/CD pipeline on every commit provides immediate feedback and catches regressions early. CDK Aspects are a powerful feature for enforcing architectural and security best practices across all constructs in a CDK application. By implementing custom Aspects, developers can define rules that validate configurations (e.g., encryption, logging) and cause synthesis to fail if violations are detected, ensuring security configurations are enforced consistently. The other options are less efficient or effective. Writing unit tests against cdk.out with a general framework is possible but less convenient and idiomatic than using the CDK assertions library. Using CDK runtime context for validation is not its primary purpose and less robust than Aspects. Authoring a script to search for strings is prone to errors, difficult to maintain, and lacks the deep understanding of the CDK construct tree that Aspects provide.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed