Socket
Socket
Sign inDemoInstall

cdktf

Package Overview
Dependencies
3
Maintainers
1
Versions
951
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cdktf

Cloud Development Kit for Terraform


Version published
Maintainers
1
Created

Package description

What is cdktf?

The cdktf (Cloud Development Kit for Terraform) npm package allows developers to define cloud infrastructure using familiar programming languages instead of HashiCorp Configuration Language (HCL). It provides a way to leverage the power of Terraform with the flexibility and expressiveness of languages like TypeScript, Python, and Java.

What are cdktf's main functionalities?

Defining Infrastructure

This code sample demonstrates how to define an AWS S3 bucket using the cdktf package. It sets up an AWS provider and creates an S3 bucket resource.

const cdktf = require('cdktf');
const { Construct } = require('constructs');
const { App, TerraformStack } = require('cdktf');
const { AwsProvider, S3Bucket } = require('@cdktf/provider-aws');

class MyStack extends TerraformStack {
  constructor(scope, id) {
    super(scope, id);

    new AwsProvider(this, 'Aws', {
      region: 'us-west-2'
    });

    new S3Bucket(this, 'MyBucket', {
      bucket: 'my-cdktf-bucket'
    });
  }
}

const app = new App();
new MyStack(app, 'my-stack');
app.synth();

Synthesizing Terraform Configuration

This code sample shows how to synthesize the Terraform configuration from the defined infrastructure. The `app.synth()` method generates the necessary Terraform JSON configuration files.

const { App } = require('cdktf');
const { MyStack } = require('./my-stack');

const app = new App();
new MyStack(app, 'my-stack');
app.synth();

Using Constructs

This code sample demonstrates how to use constructs to encapsulate and reuse infrastructure definitions. Constructs can be used to create reusable components that can be composed into stacks.

const { Construct } = require('constructs');
const { TerraformStack } = require('cdktf');

class MyConstruct extends Construct {
  constructor(scope, id) {
    super(scope, id);
    // Define resources here
  }
}

class MyStack extends TerraformStack {
  constructor(scope, id) {
    super(scope, id);
    new MyConstruct(this, 'MyConstruct');
  }
}

Other packages similar to cdktf

Changelog

Source

0.20.7

fix

  • fix(provider-generator): refactor logic to determine if a block is optional or required #3580

chore

  • chore(deps): pin trusted workflows based on HashiCorp TSCCR #3583
  • chore: Upgrade dependencies for cli #3588
  • chore: Upgrade dependencies for cli #3574
  • chore: Upgrade dependencies for util #3573
  • chore: Upgrade dependencies for lib #3572

Readme

Source

cdktf

cdktf is a framework for defining cloud infrastructure using Terraform providers and modules. It allows for users to define infrastructure resources using higher-level programming languages.

Build

Install dependencies

yarn install

Build the package

yarn build

Learn More

Keywords

FAQs

Last updated on 15 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc