Skip to content

Instantly share code, notes, and snippets.

@bioball
Created March 15, 2024 16:35
Show Gist options
  • Save bioball/9edf23a41695cb2080131ec3610a4c17 to your computer and use it in GitHub Desktop.
Save bioball/9edf23a41695cb2080131ec3610a4c17 to your computer and use it in GitHub Desktop.
AWS CloudFormation generate pkl
import "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1.0.3#/internal/ModulesGenerator.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1.0.1#/Parser.pkl"
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.0#/URI.pkl"
jsonFiles = read*("schemas/*.json")
converted: Listing<ModulesGenerator> = new Listing {
for (filename, file in jsonFiles) {
new ModulesGenerator {
rootSchema = Parser.parse(file)
baseUri = URI.parse("file://\(read("env:PWD"))/\(filename)")!!
}
}
}
output {
files {
for (c in converted) {
for (mod in c.modules) {
["\(mod.moduleName).pkl"] {
text = """
\(mod.moduleNode.output.text)
output {
renderer = new JsonRenderer {}
}
"""
}
}
}
}
}
#!/usr/bin/env bash
curl -L -o schemas.zip https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip
unzip -o -d schemas/ schemas.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment