Package: cdktf-tf-module-stack
cdktf-tf-module-stackA drop-in replacement for cdktf.TerraformStack that lets you define Terraform modules as constructs.cdktf-tf-module-stackis in technical preview, which means it's a community supported project. It still requires extensive testing and polishing to mature into a HashiCorp officially supported project. Pleasefile issuesgenerously and detail your experience while using the library. We welcome your feedback.By using the software in this repository, you acknowledge that:cdktf-tf-module-stackis still in development, may change, and has not been released as a commercial product by HashiCorp and is not currently supported in any way by HashiCorp.cdktf-tf-module-stackis provided on an "as-is" basis, and may include bugs, errors, or other issues.cdktf-tf-module-stackis NOT INTENDED FOR PRODUCTION USE, use of the Software may result in unexpected results, loss of data, or other unexpected results, and HashiCorp disclaims any and all liability resulting from use ofcdktf-tf-module-stack.HashiCorp reserves all rights to make all decisions about the features, functionality and commercial release (or non-release) ofcdktf-tf-module-stack, at any time and without any obligation or liability whatsoever.Compatibilitycdktf>= 0.20.0constructs>= 10.0.25Available PackagesNPMThe npm package is available athttps://www.npmjs.com/package/@cdktf/tf-module-stack.npm install @cdktf/tf-module-stackNOTE: Originally, this package was namedcdktf-tf-module-stack, and the legacy versions (<= 0.2.0) can be found on npmhere.PyPIThe PyPI package is available athttps://pypi.org/project/cdktf-tf-module-stack.pipenv install cdktf-tf-module-stackNugetThe Nuget package is available athttps://www.nuget.org/packages/HashiCorp.Cdktf.TfModuleStack.dotnet add package HashiCorp.Cdktf.TfModuleStackMavenThe Maven package is available athttps://mvnrepository.com/artifact/com.hashicorp/cdktf-tf-module-stack.<dependency>
    <groupId>com.hashicorp</groupId>
    <artifactId>cdktf-tf-module-stack</artifactId>
    <version>[REPLACE WITH DESIRED VERSION]</version>
</dependency>GoThe go package is generated into thegithub.com/cdktf/cdktf-tf-module-stack-gopackage.go get github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestackUsageTypescriptimport{App}from"cdktf";import{TFModuleStack,TFModuleVariable,TFModuleOutput,ProviderRequirement,}from"@cdktf/tf-module-stack";import{Resource}from'@cdktf/provider-null/lib/resource';classMyAwesomeModuleextendsTFModuleStack{constructor(scope:Construct,id:string){super(scope,id);newProviderRequirement(this,"null","~> 2.0");constresource=newResource(this,"resource");newTFModuleVariable(this,"my_var",{type:"string",description:"A variable",default:"default",});newTFModuleOutput(this,"my_output",{value:resource.id,});}}constapp=newApp();newMyAwesomeModule(app,"my-awesome-module");app.synth();PythonfromconstructsimportConstructfromcdktfimportApp,TerraformStackfromimports.null.resourceimportResourcefromcdktf_tf_module_stackimportTFModuleStack,TFModuleVariable,TFModuleOutput,ProviderRequirementclassMyAwesomeModule(TFModuleStack):def__init__(self,scope:Construct,ns:str):super().__init__(scope,ns)ProviderRequirement(self,"null",provider_version_constraint="~> 2.0")TFModuleVariable(self,"my_var",type="string",description="A variable",default="default")resource=Resource(self,"resource")TFModuleOutput(self,"my_output",value=resource.id)app=App()MyAwesomeModule(app,"my-awesome-module")app.synth()This will synthesize a Terraform JSON file that looks like this:{"output":{"my_output":[{"value":"${null_resource.resource.id}"}]},"resource":{"null_resource":{"resource":{}}},"terraform":{"required_providers":{"null":{"source":"null","version":"~> 2.0"}},"variable":{"my_var":{"default":"default","description":"A variable","type":"string"}}}}Please note that the provider section is missing, so that the Terraform Workspace using the generated module can be used with any provider matching the version.