DEV Community

Cover image for Lessons in AWS Python CDK: 3 - Sometimes You Just Need to Learn to Read Typescript
Jakob Ondrey for AWS Community Builders

Posted on

Lessons in AWS Python CDK: 3 - Sometimes You Just Need to Learn to Read Typescript

TLDR
The best way to get AWS CDK Python documentation is to learn to read and translate the Typescript documentation. Really.

Read and navigate through the Typescript docs so that you know what relevant arguments are and what type their values need to be, and then rely on your IDE's autocompletion to get the Python syntax right.

If you use an IDE without autocompletion, click over to the Python version of the docs to get the correct snake casing of the arguments.

You are pretty smart. You will catch on really fast.


About Me
My name is Jakob and I am a DevOps Engineer. I used to be a lot of other things as well (Dish Washer, Retail Employee, Camp Counselor, Army Medic, Infectious Disease Researcher), but now I am a DevOps Engineer. I received no formal CS education but I'm not self taught, because I had thousands of instructors who taught me through their tutorials and blog posts. The culture of information sharing within the software engineering community is vital to everyone, especially those like me who didn't have other options. So, as I learn new things I will be documenting them through the eyes of someone learning for the first time, because those are the people most in need of a guide. Happy Learning! And don't be a stranger.


Note: I am NOT going to be sourcing and fact checking everything here. This is not an O'Reilly book. The language and descriptions are intended to allow beginners to understand. If you want to be pedantic about details or critique my framing of what something is or how it works feel free to write your own post about it. These posts are intended to be enough to get you started so that you can begin breaking things in new ways on your own!


The Problem

Python documentation for the AWS CDK stinks. It's not good at all.

Here is an example of the Python documentation for an EKS Custer. It tells you all of the arguments, and whether they are optional, that you can use to customize your EKS Cluster. What more could you want?

Screenshot of the AWS CDK Documentation in Python for an EKS Cluster. It shows the a number of parameters of the cluster class.

Well what if you want to specify an alb_controller for your cluster? Union[AlbControllerOptions, Dict[str, Any], None] of course.. Wait what? tell me more! No! Python documentation doesn't supply links to anything!

Now let's compare that to the Typescript documentation.

Screenshot of the AWS CDK Documentation in Typescript for an EKS Cluster. It shows the a number of properties of the cluster class.

It contains all the relevant information but includes links to all the subclasses that you may need to reference. ALB Controller options? They look like this!

Screenshot of the AWS CDK Documentation in Typescript for an ALB Controller interface. It shows the a number of properties of the controller interface.

And what of ALB Versions? Whats available? Just click on that link!

Screenshot of the AWS CDK Documentation in Typescript for an ALB Controller Version. It shows possible versions available to use for the controller class.

They Typescript documentation is just so much more rich.

So here is my advice. Just use the Typescript documentation as your main source. Will it take a little bit of time to get the hang of reading Typescript documentation then writing your CDK code in Python? yeah, but I know you are up to the challenge. A fully featured IDE will help with auto-completion and worst case if a particular class is giving you trouble you can follow the link to the Python docs, resolve your issue, and go back to the Typescript docs.

Screenshot of the AWS CDK Documentation in Python for an ALB Controller Version. It shows possible versions available to use for the controller class.

It is a bummer that the Python documentation for the AWS CDK lacks the interactivity of the Typescript documentation, but by learning to read in Typescript you are not only making your CDK building in Python easier for yourself, but also learning some Typescript along the way!

Top comments (1)

Collapse
 
atula28os profile image
atulkr28

Thank for advice on Typescript approach, I was way hesitant to follow Typescript