Chapter 8. Creating New Custom CDK Constructs
In the previous chapter, you learned about extending existing L3 constructs by creating custom constructs with configurations specifically tailored to your business requirements. In this chapter, you will build on that knowledge by creating a new CDK construct that combines existing L2 constructs into a “sane default” configuration. In our case, we will create a custom L3 construct to represent a Lambda Integrated RESTful API that uses Cognito authorization. We will take this a step further in the next chapter when we create a custom construct from existing L1 constructs.
Project Architecture: Package and Deploy a Serverless API
In this project segment, you will create a RESTful API using Amazon API Gateway and AWS Lambda. The API will be used to query and mutate data in a DynamoDB table. The DynamoDB table will be used to store data about the energy usage of a home. This API will be authenticated using Amazon Cognito.
Let’s examine how the energy calculator Lambda function integrates with our custom API Gateway construct. Figure 8-1 shows the complete architecture and how these components work together.
Figure 8-1. Custom API Gateway construct architecture with Lambda integration and Cognito authentication
Our application is becoming more sophisticated by building on the components we have already made. We are setting up an API ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access