Back to articles
Terraform CDK Has a Free Tool That Lets You Write Infrastructure in TypeScript — No More HCL
NewsDevOps

Terraform CDK Has a Free Tool That Lets You Write Infrastructure in TypeScript — No More HCL

via Dev.to DevOpsAlex Spinov

The IaC Problem Terraform's HCL is fine for simple infra. But when you need loops, conditionals, and shared modules? HCL fights you. You end up with for_each hacks and dynamic blocks. Terraform CDK (CDKTF) lets you write Terraform in TypeScript, Python, Go, or Java. Real programming languages with real abstractions. What CDKTF Gives You TypeScript Infrastructure import { App , TerraformStack } from ' cdktf ' ; import { AwsProvider } from ' @cdktf/provider-aws/lib/provider ' ; import { Instance } from ' @cdktf/provider-aws/lib/instance ' ; import { S3Bucket } from ' @cdktf/provider-aws/lib/s3-bucket ' ; class MyStack extends TerraformStack { constructor ( scope : App , id : string ) { super ( scope , id ); new AwsProvider ( this , ' aws ' , { region : ' us-east-1 ' }); new S3Bucket ( this , ' bucket ' , { bucket : ' my-app-assets ' , tags : { Environment : ' production ' }, }); new Instance ( this , ' server ' , { ami : ' ami-0c55b159cbfafe1f0 ' , instanceType : ' t3.micro ' , tags : {

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
6 views

Related Articles