Testing Constructs
The CDK Developer Guide has a good guide on testing constructs. For this section of the workshop we are going to use the Fine-Grained Assertions and Validation type tests.
CDK assert Library
We will be using the CDK assertions (aws-cdk-lib/assertions) library throughout this section. The library contains several helper functions for writing unit and integration tests.
For this workshop we will mostly be using the hasResourceProperties function. This helper is used when you only care that a resource of a particular type exists (regardless of its logical identfier), and that some properties are set to specific values.
Example:
template.hasResourceProperties('AWS::CertificateManager::Certificate', {
DomainName: 'test.example.com',
ShouldNotExist: Match.absent(),
// Note: some properties omitted here
});
Match.absent() can be used to assert that a particular key in an object is not set (or set to undefined).
To see the rest of the documentation, please read the docs here.
'AWS > CDK' 카테고리의 다른 글
[Fixed] CDK parameter doesn't read from parameter using ASL (0) | 2022.06.18 |
---|---|
CDK use existing CloudFormation Output Value in AWS Server + StepFunction (0) | 2022.06.17 |
[AWS CDK] Clean up CDK Stack (0) | 2022.04.06 |
[AWS CDK] CDK Diff and CDK Deploy (0) | 2022.04.06 |
[AWS CDK] Exposing Hit Counter Table (0) | 2022.04.06 |