{"id":4334,"date":"2022-04-15T13:58:00","date_gmt":"2022-04-15T11:58:00","guid":{"rendered":"https:\/\/blog.besharp.it\/?p=4334"},"modified":"2022-04-15T17:17:44","modified_gmt":"2022-04-15T15:17:44","slug":"step-function-with-aws-cdk-in-action-our-points-of-view-about-it-using-typescript","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/step-function-with-aws-cdk-in-action-our-points-of-view-about-it-using-typescript\/","title":{"rendered":"Step Function with AWS CDK in action: our points of view about it using Typescript"},"content":{"rendered":"\n
The infrastructure as Code (IaC) has been one of the most popular keywords in the cloud topic.<\/p>\n\n\n\n
This made cloud infrastructure implementation much more reusable, versionable, and maintainable.<\/p>\n\n\n\n
Several implementations and standards of this concept are recently born.<\/p>\n\n\n\n
Some of those are Ops<\/em>-oriented, which are usually based on declarative configuration files, like Terraform<\/strong> or AWS SAM<\/strong>.<\/p>\n\n\n\n Other tools are more Dev<\/em>-oriented, using popular programming languages like Typescript<\/strong>, Java<\/strong>, or Python<\/strong>.<\/p>\n\n\n\n The official tool to develop your IaC in your AWS account is the Cloud Development Kit (CDK), made by AWS.<\/p>\n\n\n\n We have used it a lot, for different use cases, and today we are going to share our experiences to provide you with some useful tips. Let’s dive deep!<\/p>\n\n\n\n AWS CDK is available for different programming languages, but we usually chose to use Typescript because it allows developers to use Javascript elasticity and Java type safety<\/strong>.<\/p>\n\n\n\n Those characteristics are very useful to speed up development, keeping type safety’s advantages and enabling the usage of object-oriented design patterns.<\/p>\n\n\n\n A very cool thing about AWS CDK is the modularized structure.<\/p>\n\n\n\n Each AWS service it’s represented as a node module, so it’s a dependency of your node project.<\/p>\n\n\n\n This permits you to create a lightweight project without useless imports.<\/p>\n\n\n\n Usually, we design the CDK project structure by splitting the main stack into several nested stacks, using domain-driven criteria.<\/p>\n\n\n\n AWS CDK provides you with several abstraction layers to create AWS -resources.<\/p>\n\n\n\n We have identified 3 abstraction’s macro-categories:<\/p>\n\n\n\n Typically can be identified from their name’s root: “Cfn”. Those elements give the possibility to customize your resources the same way you’d do on a CloudFormation Template.<\/p>\n\n\n\n (ie: CfnStateMachineProps<\/a>)<\/p>\n\n\n\n These constructors are our favorites, they abstract and simplify some tricky resource configurations, without losing control of the created resources.<\/p>\n\n\n\nProgramming language: Typescript<\/h2>\n\n\n\n
Project Structure<\/h2>\n\n\n\n
Abstractions layers<\/h2>\n\n\n\n
1 – CloudFormation Plain resources:<\/strong><\/h4>\n\n\n\n
2 – Attributes abstraction resources:<\/strong><\/h4>\n\n\n\n