// What a Terraform file deploys, read for an internal dashboard.
//
//   quillo run hcl.qwe      then open http://localhost:8080/resources

use "hcl.qwer"

route GET /resources {
    let tf = hcl_read_file("hcl_sample.tf")?
    {
        region_default: tf.variable.region.default,
        instance_type: tf.resource.aws_instance.web.instance_type,
        kinds: keys(tf.resource),
    }
}

route GET /evaluated {
    let tf = hcl_eval(read_file("hcl_sample.tf")?, { region: "eu-central-1", size: "big" }, { name: "quillo-shop" })?
    { region: tf.provider.aws.region, type: tf.resource.aws_instance.web.instance_type, name: tf.resource.aws_instance.web.tags.Name, count: tf.resource.aws_instance.web.count }
}

route GET /write = respond(200, hcl_write({ job: { web: { datacenters: ["ams1"], count: 3, image: "quillo/shop:1.4" } } })?, { "content-type": "text/plain" })
