Skip to content

Module Support  #522

Closed
Closed
@skorfmann

Description

@skorfmann

The overall goal of this issue is to extend the support for modules within cdktf.

At the moment, we only support generating (via cdktf get) packages for modules which are published in the Terraform registry. While this covers a good part of the public Terraform module ecosystem, it's limiting users who want to use modules in version-control systems, local disk or other sources.

We will add support for generating Typescript classes using all module sources currently supported by Terraform Core. The experience of using these generated classes should feel idiomatic within the respective target language of the user.

Implementation

At the moment we're using a dedicated Terraform Registry client to fetch the required meta information about a module to generate the code.

When looking at the various ways of consuming Terraform modules, it's better to delegate the work of fetching the modules to Terraform Core directly. This could be done via defining a module block in a temporary working directory, running terraform init and use Terraform Config Inspect to generate the metadata.

Compared to the direct Terraform Registry API call, this will certainly a bit slower and use more resources, e.g. the terraform init call will download all required module dependencies as well. On the upside, we don't have to reimplement functionality which already exists and we'll always support what Terraform Core is going to support in the future.

On a high level view, this will include:

  • Replace the Terraform Registry Client by a Terraform workflow similar to the Provider generator step
  • Figure out if we can use Terraform Config Inspect directly or if it's better to reimplement the relevant parts in Typescript
  • Make sure Module Outputs are properly typed and are using Tokens where suitable (related to Token System #525)

Issues Resolved by this Feature

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions