Skip to Content
Hands-On AWS CDK
book

Hands-On AWS CDK

by Sam Ward Biddle, Kyle T. Jones
April 2025
Intermediate to advanced
258 pages
6h 32m
English
O'Reilly Media, Inc.
Content preview from Hands-On AWS CDK

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Serverless Development on AWS

Serverless Development on AWS

Sheen Brisals, Luke Hedger
Serverless Architectures on AWS, Second Edition

Serverless Architectures on AWS, Second Edition

Yan Cui, Ajay Nair, Peter Sbarski
Generative AI on AWS

Generative AI on AWS

Chris Fregly, Antje Barth, Shelbee Eigenbrode

Publisher Resources

ISBN: 9781098158767Errata Page