Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Modules from Various Sources #584

Merged
merged 30 commits into from
Mar 11, 2021
Merged

Build Modules from Various Sources #584

merged 30 commits into from
Mar 11, 2021

Conversation

skorfmann
Copy link
Contributor

This adds a new package, @cdktf/hcl2json which is being used to to convert HCL to JSON. This is required to get the inputs and outputs for a given module.

This aims to fully resolve #522

@skorfmann skorfmann marked this pull request as ready for review March 9, 2021 22:07
@skorfmann
Copy link
Contributor Author

In general, this is ready for review. I'm gonna adda a few test cases around modules, fix the existing tests and perhaps extract a few classes into dedicated files. Conceptually it's going to stay like this for now.

On a high level, this merged the module and provider schema generation. Both is now generated from a Terraform config, where the module schema is processed via @cdktf/hcl2json.

The naming part for modules is a bit tricky. Since this supports various module sources now, a simple string source doesn't cut it anymore. Hence, this introduces an additional option to define modules - both options will be valid:

{
  terraformModules: [
    "terraform-aws-modules/vpc/aws@2.39.0",
    {
      name: "AwsVpc",
      source: "terraform-aws-modules",
      version: "2.39.0"
    }
  ]
}

Furthermore, there's a breaking change regarding the generated module name. Given the following config:

{
  terraformModules: [
    "terraform-aws-modules/vpc/aws@2.39.0",
  ]
}

Before a class Vpc would have been generated. Now it will generate a class name TerraformAwsModulesVpcAws. This makes the name handling simpler. An upgrade path for a user with existing module config would be to change to a module configuration object like

{
  terraformModules: [
    {
      name: "Vpc",
      source: "terraform-aws-modules",
      version: "2.39.0"
    }
  ]
}

@skorfmann skorfmann requested review from jsteinich and removed request for jsteinich March 9, 2021 22:21
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module Support
3 participants