We should add a prompts.json file to application templates that lets the template developer add additional fields to the prompt for the end user to fill in so we don't have to litter the templates with TODO (put your value here).
We can use JSON Schema to define these, loop through and even use JSON Schema to do rich validation.
The two caveats w/ json schema are:
I'm not sure we should go more than one level deep in prompting - by that I mean, lets not prompt them for env vars and deeply nested things, just stuff they need to fill in their terraform
JSON is unordered, so everytime the prompt loads it'll be in a random order.
An example would be for aws-lambda application template... the main.tf file will probably resemble:
module "lambda" {
source = ".../massdriver-application-aws-lambda"
# a bunch of fields for the lambda
runtime = "nodejs900.4"
}
The runtime for lambda will likely not change for a given users application, so it shouldnt be present in their YAML. The user does need the runtime they plan to use though in their terraform.
Using this prompts feature:
mass app new
[x] aws-lambda
Name: foo
Description: does a great foo
Runtime:
[x] Node JS 90000
[ ] Ruby 3x3
[ ] Python 2.3.2.3.2.3.2.3.lol
And this would fill in the templated terraform:
module "lambda" {
source = ".../massdriver-application-aws-lambda"
# a bunch of fields for the lambda
runtime = "<md .Runtime md>"
}
We should add a
prompts.json
file to application templates that lets the template developer add additional fields to the prompt for the end user to fill in so we don't have to litter the templates with TODO (put your value here).We can use JSON Schema to define these, loop through and even use JSON Schema to do rich validation.
The two caveats w/ json schema are:
An example would be for
aws-lambda
application template... the main.tf file will probably resemble:The runtime for lambda will likely not change for a given users application, so it shouldnt be present in their YAML. The user does need the runtime they plan to use though in their terraform.
Using this prompts feature:
And this would fill in the templated terraform: