Everyone loves infrastructure as code because it gives you consistency across environments as no manual steps will be forgotten and it makes it easier to handle infrastructure. Writing software defined infrastructure inside AWS started with CloudFormation which is a low level interaction (YAML/JSON templates).
IAM Role which has permissions to create and write logs into CloudWatch and has custom DynamoDB API permissions for a particular table and all its indexes.
Api Gateway - Rest API which will proxy all GET/PUT/POST/DELETE requests to a Lambda function.
In our construct we define an IAM Role for the lambda, an API Gateway (both described above) and a Lambda.
Once we have our construct, writing unit tests is fairly easy. You can use CDK assertions for fine grained assertions👇.
I think AWS CDK is a great framework because it brings the infrastructure inside your IDE alongside with your runtime code, makes your environments consistent and easier to manage and you can create reusable bits of infrastructure. Having infrastructure unit tests setup in your CI pipeline is a best practice that you should follow and will make you more confident to go to prod on Fridays😱.