0.35.3 • Published 5 months ago

@horietakehiro/aws-cdk-utul v0.35.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

AWS CDK Unit Test Utility Library

aws-cdk-utul(unit test utility library) makes it faster, more efficient with less mistakes for you to code AWS CDK unit tests.


Features


TypedTemplate

TypedTemplate class provides you proper type definitions for (almost) all AWS CloudFormation resource types. So you can easily and quickly code AWS CDK unit tests without trivial mistakes and googling.

type-hinting-1

  • You can use all methods implemented by AWS CDK's Template class with proper type definitions.
  • Return values of some methods - e.g. findResources - are changed from original ones, so that succeeding processes can handle and access them more easily.
  • You can still use AWS CDK's Matcher class and other arbitrary objects too.
import { Stack } from "aws-cdk-lib";
import { TypedTemplate } from "@horietakehiro/aws-cdk-utul/lib/assertions";
import { AWS_EC2_SUBNET, AWS_EC2_VPC } from "@horietakehiro/aws-cdk-utul/lib/types/cfn-resource-types";
const stack = new Stack()

const template = TypedTemplate.fromStack(stack)
// you can execute all method implemented in original `Template` instance
template.hasResource(AWS_EC2_VPC({Properties: {
  CidrBlock: "10.0.0.0/16"
}}))
// you can still use original `Matcher` class too.
const subnets = template.findResources(AWS_EC2_SUBNET({Properties: {
  Tags: Match.arrayWith([
    {Key: "Name", Value: Match.stringLikeRegexp("Public")}
  ])
}}))
// you can access resources with more efficient way
subnets.forEach((sn) => { 
  expect(sn.def.Properties?.CidrBlock?.endsWith("/24")).toBe(true)
})

ExtraMatch

ExtraMatch class provides you some kind of a syntax sugar for AWS CDK's Match class.

import { ExtraMatch } from "@horietakehiro/aws-cdk-utul/lib/assertions"
// get just vpc's logical id
const [{id}] = template.findResources(AWS_EC2_VPC({}))
template.allResources(AWS_EC2_SUBNET({
  // Equals to {VpcId: {Ref: id}}
  Properties: {VpcId: ExtraMatch.ref(id)}
}))
template.hasOutput("VPCARN", {
  // Equals to {Value: {"Fn::GetAtt": [id, "Arn"]}}
  Value: ExtraMatch.getAttArn(id)
})

ExtraMatch.iamPolicyLike method provides schemas for IAM Policy document - it's useful when defining tests for AWS::IAM::Policy and AWS::IAM::Role

npm.io


Install

npm install @horietakehiro/aws-cdk-utul

Release policy

This package will be released new version every 3 days, so that catching up updates of AWS CloudFormation resource types and those schemas which will be happened frequently and irregularly.


Some other notes

  • Schemas of AWS CloudFormation resource types used in this library are based on those at us-east-1
  • Compatible with AWS CDK v2.0.0 or greater.
0.35.3

5 months ago

0.35.2

5 months ago

0.35.1

5 months ago

0.35.0

5 months ago

0.34.0

5 months ago

0.33.51

5 months ago

0.33.50

5 months ago

0.33.49

5 months ago

0.33.48

6 months ago

0.33.47

6 months ago

0.33.46

6 months ago

0.33.45

6 months ago

0.33.44

6 months ago

0.33.43

6 months ago

0.33.42

6 months ago

0.33.41

6 months ago

0.33.40

6 months ago

0.33.39

6 months ago

0.33.38

7 months ago

0.33.37

7 months ago

0.33.36

7 months ago

0.33.35

7 months ago

0.33.34

7 months ago

0.33.33

7 months ago

0.33.32

7 months ago

0.33.31

7 months ago

0.33.30

7 months ago

0.33.29

7 months ago

0.33.28

7 months ago

0.33.27

8 months ago

0.33.26

8 months ago

0.33.25

8 months ago

0.33.24

8 months ago

0.33.23

8 months ago

0.33.22

8 months ago

0.33.21

8 months ago

0.33.20

8 months ago

0.33.19

8 months ago

0.33.18

8 months ago

0.33.17

8 months ago

0.33.16

9 months ago

0.33.15

9 months ago

0.33.14

9 months ago

0.33.13

9 months ago

0.33.12

9 months ago

0.33.11

9 months ago

0.33.10

9 months ago

0.33.9

9 months ago

0.33.8

9 months ago

0.33.7

9 months ago

0.33.6

10 months ago

0.33.5

10 months ago

0.33.4

10 months ago

0.33.3

10 months ago

0.33.2

10 months ago

0.33.1

10 months ago

0.33.0

11 months ago

0.32.1

11 months ago

0.32.0

11 months ago

0.31.1

11 months ago

0.31.0

11 months ago

0.30.1

12 months ago

0.30.0

12 months ago

0.20.0

12 months ago

0.12.0

1 year ago

0.11.4

1 year ago

0.11.3

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.10.0

1 year ago

0.9.1

1 year ago

0.9.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago