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.ymllists 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:
ok pkg addadds the template topackages.yml, and creates a configuration file with default values.ok pkg installruns Boilerplate. Boilerplate downloads the template version fromgolden-path-boilerplate, renders it with your values, and writes the files to your directory.ok pkg updatechanges the template version inpackages.ymlto the newest release. Runok pkg installafterwards 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.