Skip to main content
tfts allows you to consume existing Terraform modules (HCL) using the TerraformHclModule class. This enables you to leverage the vast ecosystem of community-maintained modules while still writing your infrastructure in TypeScript.

Using a Module

To use a module, you provide its source, version, and any required variables.

Managing Variables and Providers

You can set variables after initialization using the set method:
If the module requires specific providers, you can pass them in the configuration:

Accessing Outputs

Modules often expose outputs that you need to use in other parts of your configuration. TerraformHclModule provides typed methods to access these outputs.
Available methods:
  • get(outputName): Returns a generic token.
  • getString(outputName): Returns a string token.
  • getNumber(outputName): Returns a number token.
  • getBoolean(outputName): Returns a boolean token.
  • getList(outputName): Returns a list token.

Example: VPC and EC2

Using TerraformHclModule is the fastest way to integrate complex, pre-built infrastructure components into your tfts project.