Chapter 7. Extending CDK Constructs
In this chapter, you will build custom L3 CDK constructs for an S3 bucket and a Lambda function by extending existing L3 constructs. In the next chapter, you will build on this knowledge by creating your own custom construct from scratch. Custom L3 constructs are useful when teams of developers need to adhere to a common standard for cost, performance, security, compliance, or compatibility purposes. In our case, we will be creating a custom construct for an S3 bucket that has access logging enabled and public access blocked for security and compliance purposes. It will also have a lifecycle policy enabled to reduce the cost of storing data that is accessed less frequently.
We will also create a custom Lambda function construct that enables logging for security purposes and that uses the Graviton2 compute instance to optimize cost and reduce the carbon footprint of our data processing compute. You might use custom constructs for similar purposes, or to meet some other goal for your team or your individual project. The goal of a custom construct is to standardize a repeatable configuration so that you don’t have to code it from scratch every time or copy/paste it from a template. Now you and your team can update the code in a central place. In this case, our custom constructs will live within our project, but teams often choose to maintain their own private repositories of custom constructs in a central npm repository.
Project Architecture: ...
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