Skip to content

Infrastructure as Code

A key component of the Golden Path is templates that solve common problems. A template is an abstraction level above the code: you configure it with values in YAML, and the template generates the code. Boilerplate is the engine that renders the templates.

The templates come with good defaults, for example for common use cases, security, logging and governance. You can get started without many decisions up front.

Most templates generate Terraform code. Some templates generate other files, for example GitHub Actions workflows. For the parts that are specific to Terraform, see How Terraform templates work.

Working with templates

The ok CLI makes it easier to install and configure templates so you don't have to use Boilerplate directly.

ok uses two YAML files in each directory:

  • packages.yml lists the templates that the directory uses, and the version of each template.
  • A configuration file, such as package-config.yml, holds your values for the Boilerplate variables of a template. The template reference pages list the Boilerplate variables of each template.

The life cycle of a template has three steps:

  1. ok pkg add adds the template to packages.yml, and creates a configuration file with default values.
  2. ok pkg install runs Boilerplate. Boilerplate downloads the template version from golden-path-boilerplate, renders it with your values, and writes the files to your directory.
  3. ok pkg update changes the template version in packages.yml to the newest release. Run ok pkg install afterwards to render the new version. Renovate can do both steps for you, and opens a pull request when a new template version is available.

Do not edit generated files

The next ok pkg install overwrites your changes, because Boilerplate renders the template again and overwrites all files that belong to it. Most generated files have names that start with _gp or __gp, and they start with a header that tells you that the file is generated.