Home
Published on

Making ChatGPT Write CDK: Slow and Furious

Author
    Roman Naumenko
    Name
    Roman Naumenko

ChatGPT tackled the challenge of writing a simple AWS Cloud Development Kit (CDK) app from scratch in Typescript, creating a basic app with VPC, private subnets, and a NAT Gateway. Through a series of prompts, we guided the AI through the app creation process, addressing any errors or issues encountered.

In our 20-minute interaction, we faced multiple errors, such as outdated CDK versions, deprecated properties, and incorrect imports. ChatGPT provided instructions for updating the CDK version, replacing deprecated properties, and using correct imports. Some issues took several interactions to resolve. At some point ChatGPT started making bogus excuses like "this could be due to local cach issues with npm" - well, that did sound like a developer's complaint.

It was an interesting experiment, however we wouldn't recommend using bots to write actual code. Although ChatGPT generated valid code, the process was slow and needed frequent corrections. Developers can work more efficiently with IDEs and other tools to catch and correct errors. We spent about 30 minutes to get ~100 LOC (~50 CDK Typescript and the rest Node and CDK configs). This is not very productive in terms of code writing.

It also were making multiple error, couldn't find a good suggestion for subnet type. CDK changed enum for subnets few times, sure. This kind of information is so well encoded and widely availale, that there is no reason for ChatGPT not to improve in the future.

ChatGPT corrected some errors esily.

cdk_from_scratch_err_fix1.jpg

It really hung up on other errors, making the same mistake over and over.

What ChatGPT is very useful for is exploratory interactions, such as guiding beginners through creating a bare-bones CDK app step by step. However, learning to use ChatGPT effectively requires mastering prompts, interactions, and other techniques that itself resemble the software development process. There is no way to avoid it.

Engineers should maximize their efficiency by combining IDE tips and hints, knowledge of CDK compostions and abstrations, and ChatGPT's ability to generate examples and explain nuances. This approach is more effective than relying solely on code generation. Engineers also should use code bootstraping, init commands where possible.

⁠Final result - the app.

Overall structure

Next Post

← Back to the blog

Services

Overview
AWS CDK CourseNew

Catenary Cloud

© 2021 Catenary Cloud LLC. Made with ❤️ in Philadelphia