-
Notifications
You must be signed in to change notification settings - Fork 455
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
Validate cdktf.json to catch simple configuration errors #782
Comments
Here's an at least mostly correct one, translated from the spec on this page: {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "cdktf.schema.json",
"type": "object",
"properties": {
"app": {
"type": "string",
"description": "The command to run in order to synthesize the code to Terraform compatible JSON"
},
"language": {
"type": "string",
"enum": ["typescript", "python", "csharp", "java", "go"],
"description": "Target language for building provider or module bindings. Currently supported: `typescript`, `python`, `java`, `csharp`, and `go`"
},
"output": {
"type": "string",
"default": "cdktf.out",
"description": "Default: 'cdktf.out'. Where the synthesized JSON should go. Also will be the working directory for Terraform operations"
},
"codeMakerOutput": {
"type": "string",
"default": ".gen",
"description": "Default: '.gen'. Path where generated provider bindings will be rendered to."
},
"projectId": {
"type": "string",
"description": "Default: generated UUID. Unique identifier for the project used to differentiate projects"
},
"sendCrashReports": {
"type": "boolean",
"default": false,
"description": "Default: false. Whether to send crash reports to the CDKTF team"
},
"terraformProviders": {
"type": "array",
"items": {
"anyOf": [
{ "type": "string" },
{
"type": "object",
"properties": {
"name": { "type": "string" },
"source": { "type": "string" },
"version": { "type": "string" }
},
"required": ["name"]
}
]
},
"description": "Terraform Providers to build"
},
"terraformModules": {
"type": "array",
"items": {
"anyOf": [
{ "type": "string" },
{
"type": "object",
"properties": {
"name": { "type": "string" },
"source": { "type": "string" },
"version": { "type": "string" }
},
"required": ["name"]
}
]
},
"description": "Terraform Modules to build"
}
},
"required": ["app", "language", "terraformProviders", "terraformModules"]
} You can tell your editor to validate against it by adding a line to your {
"$schema": "./cdktf.schema.json",
} Would of course be great to get an "official" one maintained by Hashicorp, as I doubt I'll update the above if any changes are made. |
We have some custom properties in our
|
Community Note
Description
We had a user report on an issue with the
excludeStackIdFromLogicalIds
flag in thecdktf.json
via the CDK Dev Slack. The flag had been set to"false"
(string) instead offalse
(boolean). As TypeScript treats"false"
as a truthy value the setting was interpreted as iftrue
would have been passed.By validating the
cdktf.json
against a schema, we could catch such errors without having to do much work.Furthermore, it would be possible to use somehow publish e.g. a json schema which then can be picked up by editors and offer intellisense when editing the
cdktf.json
config. For this versioning (e.g. feature flags that change) might be a concern that could make this more complicated.References
The text was updated successfully, but these errors were encountered: