<BoilerplateInputs>
The <BoilerplateInputs>
block creates dynamic web forms based on Gruntwork Boilerplate variable definitions. It’s used to collect user input that can then be used in Commands, Checks, or to generate files from templates.
Basic Usage
Section titled “Basic Usage”With Template Path
Section titled “With Template Path”<BoilerplateInputs id="terraform-config" templatePath="templates/terraform-vpc"/>
This loads the boilerplate.yml
file from templates/terraform-vpc/boilerplate.yml
(relative to your runbook file).
With Inline YAML
Section titled “With Inline YAML”<BoilerplateInputs id="user-inputs">```yamlvariables: - name: ProjectName type: string description: Name for your project validations: "required" - name: Environment type: enum description: Deployment environment options: - dev - staging - production default: dev```</BoilerplateInputs>
This will render a form with the following fields:
- ProjectName (text input)
- Environment (dropdown select)
Required Props
Section titled “Required Props”id
(string) - Unique identifier for this form (used by Commands/Checks to reference the variables)
Optional Props
Section titled “Optional Props”templatePath
(string) - Path to a directory containing aboilerplate.yml
file (relative to runbook)prefilledVariables
(object) - Pre-filled values for form fieldsvariant
(string) - Display variant:'standard'
(default) or'embedded'
(for inline use in Commands/Checks)children
(ReactNode) - Inline YAML content (alternative totemplatePath
)onGenerate
(function) - Callback function called when form is submitted (advanced)
Supported Variable Types
Section titled “Supported Variable Types”String
Section titled “String”Text input field:
variables: - name: ProjectName type: string description: Name for your project default: my-project validations: "required"
Number input field:
variables: - name: InstanceCount type: int description: Number of instances default: 3
Checkbox:
variables: - name: EnableMonitoring type: bool description: Enable CloudWatch monitoring default: true
Dropdown select:
variables: - name: Environment type: enum description: Deployment environment options: - dev - staging - production default: dev
Dynamic list of values:
variables: - name: AllowedIPs type: list description: List of allowed IP addresses default: - 0.0.0.0/0
Key-value pairs:
variables: - name: Tags type: map description: AWS resource tags default: Environment: dev Owner: team
Structured Map (with Schema)
Section titled “Structured Map (with Schema)”Map with predefined fields:
variables: - name: Accounts type: map description: AWS accounts configuration schema: email: string environment: string id: string schemaInstanceLabel: Account Name default: dev: email: dev@example.com environment: development id: "123456789012" prod: email: prod@example.com environment: production id: "098765432109"
Validations
Section titled “Validations”Boilerplate supports various validation types:
variables: - name: Email type: string validations: - type: required message: Email is required - type: email message: Must be a valid email address
- name: Region type: string validations: - type: required - type: length args: [2, 20] message: Region must be between 2 and 20 characters
- name: ProjectName type: string validations: - type: alphanumeric message: Project name must be alphanumeric
Supported validation types:
required
- Field must not be emptyemail
- Must be a valid email addressurl
- Must be a valid URLalpha
- Letters onlydigit
- Numbers onlyalphanumeric
- Letters and numbers onlysemver
- Valid semantic version (e.g., 1.2.3)length
- String length range (args: [min, max])countrycode2
- Two-letter country code
Using with Commands and Checks
Section titled “Using with Commands and Checks”Reference by ID
Section titled “Reference by ID”<BoilerplateInputs id="vpc-config">```yamlvariables: - name: VpcName type: string - name: CidrBlock type: string default: 10.0.0.0/16```</BoilerplateInputs>
<Command id="create-vpc" command="aws ec2 create-vpc --cidr-block {{ .CidrBlock }} --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value={{ .VpcName }}}]'" boilerplateInputsId="vpc-config" title="Create VPC"/>
Inline (Embedded)
Section titled “Inline (Embedded)”<Command id="echo-greeting" command='echo "Hello, {{ .Name }}!"'> <BoilerplateInputs id="inline-name"> ```yaml variables: - name: Name type: string description: Your name ``` </BoilerplateInputs></Command>
Generating Files
Section titled “Generating Files”When you provide a templatePath
, users can click “Generate” to create files from templates using Boilerplate:
<BoilerplateInputs id="vpc-template" templatePath="templates/vpc"/>
Directory structure:
templates/vpc/├── boilerplate.yml├── main.tf├── variables.tf└── outputs.tf
The template files can use Boilerplate syntax:
resource "aws_vpc" "main" { cidr_block = "{{ .CidrBlock }}"
tags = { Name = "{{ .VpcName }}" Environment = "{{ .Environment }}" }}
Generated files are saved to a generated/
directory by default (or the path specified with the --output-path
CLI flag) and displayed in a file tree in the UI.
Form Features
Section titled “Form Features”Auto-Render
Section titled “Auto-Render”When used inline with Commands/Checks, the form automatically re-renders the command/check as the user types (with debouncing).
Generate Button
Section titled “Generate Button”For standalone BoilerplateInputs with a templatePath
, a “Generate” button appears. Clicking it:
- Validates all form inputs
- Calls the backend API to render the template
- Displays a file tree of generated files
- Shows a success indicator
Form Validation
Section titled “Form Validation”The form validates inputs in real-time based on the validation rules defined in the boilerplate.yml.
Complete Example
Section titled “Complete Example”# Deploy a VPC
First, configure your VPC settings:
<BoilerplateInputs id="vpc-setup" templatePath="templates/vpc" />
The form above will generate Terraform files. Now let's validate and apply:
<Check id="validate-terraform" command="cd generated && terraform validate" title="Validate Terraform Configuration" successMessage="Terraform configuration is valid!"/>
<Command id="apply-terraform" command="cd generated && terraform init && terraform apply -auto-approve" title="Deploy VPC" successMessage="VPC deployed successfully!" failMessage="VPC deployment failed. Check logs."/>
<Check id="verify-vpc" command="aws ec2 describe-vpcs --filters Name=tag:Name,Values={{ .VpcName }}" boilerplateInputsId="vpc-setup" title="Verify VPC Was Created" successMessage="VPC exists!"/>