Skip to content

Opening Runbooks

The runbooks open command opens a runbook in the browser. It accepts two kinds of sources:

  1. A runbook (a directory containing runbook.mdx), or
  2. An OpenTofu/Terraform module (a directory containing .tf files).

Either source can be local or remote.

See the open command reference for the full list of flags and supported URL formats.

Point the CLI at a directory containing a runbook.mdx:

Terminal window
# Local
runbooks open ./runbooks/deploy-rds
# Remote (GitHub URL)
runbooks open https://github.com/org/repo/tree/main/runbooks/deploy-rds

Runbooks serves the runbook.mdx in the browser. For remote sources, it downloads just the runbook directory via sparse git clone.

Point the CLI at a directory containing .tf files:

Terminal window
# Local
runbooks open ./modules/rds
# Remote (GitHub URL)
runbooks open https://github.com/org/repo/tree/main/modules/rds
# Remote (OpenTofu shorthand)
runbooks open github.com/org/repo//modules/rds?ref=v1.0

When Runbooks detects .tf files (and no runbook.mdx), it uses a tf-runbook template to auto-generate a runbook that:

  1. Parses the module’s variables from the .tf files
  2. Renders a web form for those variables
  3. Generates output (e.g., a terragrunt.hcl file) using the template

By default, the ::terragrunt built-in template is used. Use the --tf-runbook flag to select a different built-in template or custom template.

Terminal window
runbooks open --tf-runbook=::terragrunt ./modules/rds
TemplateWhat it generatesWhen to use
::terragrunt (default)terragrunt.hcl with non-default inputsStandard Terragrunt workflows
::terragrunt-githubterragrunt.hcl + GitHub PRGitOps: clone a repo, pick a directory, generate config, open a PR
::tofumain.tf with a module blockPlain OpenTofu/Terraform (no Terragrunt)

If the built-in templates don’t fit your needs, create your own. A custom template is a local directory containing a runbook.mdx that uses <TfModule> with source="::cli_runbook_source".

my-custom-template/
runbook.mdx

Inside runbook.mdx, the ::cli_runbook_source keyword resolves to whatever module URL was passed on the command line:

my-custom-template/runbook.mdx
# Configure Module
<TfModule id="module-vars" source="::cli_runbook_source" />
<TemplateInline inputsId="module-vars" outputPath="terragrunt.hcl" generateFile={true}>
```hcl
terraform {
source = "{{ ._module.source }}"
}
inputs = {
{{- range $name, $hcl := ._module.hcl_inputs }}
{{ $name }} = {{ $hcl }}
{{- end }}
}
```
</TemplateInline>

Run it with:

Terminal window
runbooks open --tf-runbook ./my-custom-template/ https://github.com/org/repo/tree/main/modules/rds

This example uses <TemplateInline> for simplicity, but custom templates can use <Template> for multi-file scaffolding and extra variables. See <TfModule> — Template Patterns for details.

The keyword resolves to the RUNBOOK_SOURCE argument you pass on the command line:

Command::cli_runbook_source resolves to
runbooks open --tf-runbook ./tpl/ ./modules/rdsAbsolute path to ./modules/rds
runbooks open --tf-runbook ./tpl/ https://github.com/org/repo/tree/main/modules/rdshttps://github.com/org/repo/tree/main/modules/rds
runbooks open --tf-runbook ./tpl/ github.com/org/repo//modules/rds?ref=v1.0github.com/org/repo//modules/rds?ref=v1.0

If the runbook is opened without a module URL (e.g., runbooks open --tf-runbook ./tpl/), <TfModule> renders a message explaining how to provide one.

Module authors can ship a custom runbook alongside their .tf files by placing a runbook.mdx in the module directory:

modules/rds/
main.tf
variables.tf
outputs.tf
runbook.mdx <-- custom runbook

When someone runs runbooks open on this directory, the colocated runbook.mdx is served instead of generating one from a template. Inside, use source="." to reference the module in the same directory:

modules/rds/runbook.mdx
# Configure RDS
<TfModule id="rds-vars" source="." />
<TemplateInline inputsId="rds-vars" outputPath="terragrunt.hcl" generateFile={true}>
```hcl
terraform {
source = "{{ ._module.source }}"
}
inputs = {
{{- range $name, $hcl := ._module.hcl_inputs }}
{{ $name }} = {{ $hcl }}
{{- end }}
}
```
</TemplateInline>

This works with both local and remote modules:

Terminal window
# Local
runbooks open ./modules/rds
# Remote — still serves the colocated runbook.mdx
runbooks open https://github.com/org/repo/tree/main/modules/rds