Description
Using the following example
import { App } from 'cdktf';
import { Construct } from 'constructs';
import {
TFModuleStack,
TFModuleVariable,
TFModuleOutput,
ProviderRequirement,
} from '@cdktf/tf-module-stack';
import { Resource } from '@cdktf/provider-null/lib/resource';
class MyAwesomeModule extends TFModuleStack {
constructor(scope: Construct, id: string) {
super(scope, id);
new ProviderRequirement(this, 'null', '~> 2.0');
const resource = new Resource(this, 'resource');
new TFModuleVariable(this, 'my_var', {
type: 'string',
description: 'A variable',
default: 'default',
});
new TFModuleOutput(this, 'my_output', {
value: resource.id,
});
}
}
const app = new App();
new MyAwesomeModule(app, 'my-awesome-module');
app.synth();
cdktf synth generates
cdktf-modules
├── cdktf.out
│ ├── manifest.json
│ └── stacks
│ └── my-awesome-module
│ └── cdk.tf.json
└── main.ts
cdk.tf.json content
{
"//": {
"metadata": {
"backend": "local",
"stackName": "my-awesome-module",
"version": "0.20.0"
},
"outputs": {
"my-awesome-module": {
"my_output": "my_output"
}
}
},
"output": {
"my_output": [
{
"value": "${null_resource.resource.id}"
}
]
},
"resource": {
"null_resource": {
"resource": {
"//": {
"metadata": {
"path": "my-awesome-module/resource",
"uniqueId": "resource"
}
}
}
}
},
"terraform": {
"required_providers": {
"null": {
"version": "~> 2.0"
}
}
},
"variable": {
"my_var": [
{
"default": "default",
"description": "A variable",
"type": "string"
}
]
}
}
cdktf synth --hcl generates
cdktf-modules
├── cdktf.out
│ ├── manifest.json
│ └── stacks
│ └── my-awesome-module
│ ├── cdk.tf
│ └── metadata.json
└── main.ts
cdk.tf content
terraform {
required_providers {
null = {
version = "~> 2.0"
}
}
backend "local" {
path = "/Users/Home/cdktf-modules/terraform.my-awesome-module.tfstate"
}
}
provider "null" {
}
resource "null_resource" "resource" {
}
variable "my_var" {
default = "default"
description = "A variable"
type = string
}
output "my_output" {
value = "${null_resource.resource.id}"
}
metadata.json content
{
"//": {
"metadata": {
"backend": "local",
"stackName": "my-awesome-module",
"version": "0.20.0"
},
"outputs": {
"my-awesome-module": {
"my_output": "my_output"
}
}
},
"resource": {
"null_resource": {
"resource": {
"//": {
"metadata": {
"path": "my-awesome-module/resource",
"uniqueId": "resource"
}
}
}
}
},
"terraform": {
"backend": {
"local": {
"path": "/Users/Home/cdktf-modules/terraform.my-awesome-module.tfstate"
}
},
"required_providers": {
"null": {
"version": "~> 2.0"
}
}
}
}
Versions
language: typescript
cdktf-cli: 0.20.0
cdktf: 0.20.0
node: v20.10.0
constructs: 10.3.0
terraform: v1.3.7
arch: arm64
os: darwin 23.2.0
Providers
"@cdktf/provider-null": "10.0.0",
"@cdktf/tf-module-stack": "5.0.0"
Gist
No response
Possible Solutions
No response
Workarounds
No response
Anything Else?
Is metadata.json file needed? It looks identical to the previous json version.
References
No response
Help Wanted
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
Using the following example
cdktf synthgeneratescdk.tf.jsoncontent{ "//": { "metadata": { "backend": "local", "stackName": "my-awesome-module", "version": "0.20.0" }, "outputs": { "my-awesome-module": { "my_output": "my_output" } } }, "output": { "my_output": [ { "value": "${null_resource.resource.id}" } ] }, "resource": { "null_resource": { "resource": { "//": { "metadata": { "path": "my-awesome-module/resource", "uniqueId": "resource" } } } } }, "terraform": { "required_providers": { "null": { "version": "~> 2.0" } } }, "variable": { "my_var": [ { "default": "default", "description": "A variable", "type": "string" } ] } }cdktf synth --hclgeneratescdk.tfcontentmetadata.jsoncontent{ "//": { "metadata": { "backend": "local", "stackName": "my-awesome-module", "version": "0.20.0" }, "outputs": { "my-awesome-module": { "my_output": "my_output" } } }, "resource": { "null_resource": { "resource": { "//": { "metadata": { "path": "my-awesome-module/resource", "uniqueId": "resource" } } } } }, "terraform": { "backend": { "local": { "path": "/Users/Home/cdktf-modules/terraform.my-awesome-module.tfstate" } }, "required_providers": { "null": { "version": "~> 2.0" } } } }Versions
Providers
Gist
No response
Possible Solutions
No response
Workarounds
No response
Anything Else?
Is
metadata.jsonfile needed? It looks identical to the previous json version.References
No response
Help Wanted
Community Note