> **Page index:** https://km.oslo.systems/llms.txt lists every page on this site, with a link to its Markdown version.

# 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](<https://github.com/gruntwork-io/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](<https://km.oslo.systems/terraform/how-terraform-templates-work/index.md>).

## Working with templates

The [`ok` CLI](<https://km.oslo.systems/ok-cli/index.md>) 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`](<https://km.oslo.systems/ok-cli/packages/index.md>) 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](<https://km.oslo.systems/templates/index.md>) 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`](<https://github.com/oslokommune/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](<https://km.oslo.systems/terraform-automation/renovate/index.md>) can do both steps for you, and opens a pull request when a new template version is available.

> [!WARNING]
>
> **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.
