From 6bca8767e515285a2f1943a03055032fe6e0d1f2 Mon Sep 17 00:00:00 2001 From: Luca Corrieri Date: Thu, 22 Aug 2024 14:56:30 +0200 Subject: [PATCH] docs(runner): update docs for tenv and runner refacto --- docs/examples/terraform-layer.yaml | 2 -- docs/guides/iac-drift-detection.md | 10 ++++------ docs/guides/pr-mr-workflow.md | 4 ++-- docs/operator-manual/architecture.md | 7 +++---- docs/user-guide/terraform-version.md | 18 ++++++++++++------ 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/docs/examples/terraform-layer.yaml b/docs/examples/terraform-layer.yaml index b3572d1a..612d737b 100644 --- a/docs/examples/terraform-layer.yaml +++ b/docs/examples/terraform-layer.yaml @@ -11,5 +11,3 @@ spec: repository: name: my-repository namespace: burrito-project - terraform: - version: 1.3.1 diff --git a/docs/guides/iac-drift-detection.md b/docs/guides/iac-drift-detection.md index a931ac9a..76d9cbea 100644 --- a/docs/guides/iac-drift-detection.md +++ b/docs/guides/iac-drift-detection.md @@ -72,14 +72,14 @@ Here is the content of the `TerraformRepository` resource that you have created apiVersion: config.terraform.padok.cloud/v1alpha1 kind: TerraformRepository metadata: - name: my-repo + name: my-repository namespace: burrito-project spec: repository: - url: git@github.com:padok-team/burrito-examples.git + url: https://github.com/padok-team/burrito-examples ``` -Create a `TerraformLayer` resource in the `burrito-system` namespace, referencing the `TerraformRepository` you just created. For now, the autoApply is set to false, so the layer will only plan the Terraform code and not apply it. +Create a `TerraformLayer` resource in the `burrito-system` namespace, referencing the `TerraformRepository` you just created. For now, the `autoApply` is set to false, so the layer will only plan the Terraform code and not apply it. ```bash kubectl apply -f https://raw.githubusercontent.com/padok-team/burrito/main/docs/examples/terraform-layer.yaml @@ -99,8 +99,6 @@ spec: repository: name: my-repository namespace: burrito-project - terraform: - version: 1.3.1 ``` Check that your Terraform code is being planned by Burrito: @@ -135,7 +133,7 @@ kubectl port-forward svc/burrito-server -n burrito-system 8080:80 ![Burrito drift example](../assets/demo/drift-example.png) -Activate the autoApply feature by updating the `TerraformLayer` resource: +Activate the `autoApply` feature by updating the `TerraformLayer` resource: ```bash kubectl patch tfl my-layer -n burrito-project --type merge --patch '{"spec":{"remediationStrategy":{"autoApply":true}}}' diff --git a/docs/guides/pr-mr-workflow.md b/docs/guides/pr-mr-workflow.md index 0572e95d..bdb1db66 100644 --- a/docs/guides/pr-mr-workflow.md +++ b/docs/guides/pr-mr-workflow.md @@ -44,7 +44,7 @@ Configure a webhook in your GitHub repository to point to the exposed `burrito-s kind: Secret metadata: name: burrito-webhook-secret - namespace: burrito + namespace: burrito-system type: Opaque stringData: burrito-webhook-secret: @@ -86,7 +86,7 @@ my-layer-pr-1-rxvrt ApplyNeeded my-repository update-tf-code terraform The Burrito server should have commented on the PR/MR with the plan output. You can check the comments on the PR/MR to see the plan output. -![Pul request comment demo](../assets/demo/pr-demo.png) +![Pull request comment demo](../assets/demo/pr-demo.png) Set the `autoApply` field to `true` in the TerraformLayer resource to automatically apply the Terraform code upon merging the PR/MR. diff --git a/docs/operator-manual/architecture.md b/docs/operator-manual/architecture.md index 63a6fc71..1922b2f7 100644 --- a/docs/operator-manual/architecture.md +++ b/docs/operator-manual/architecture.md @@ -86,9 +86,8 @@ The `TerraformRun` controller also creates and deletes the [Kubernetes leases](h ### The runners -The runner image implementation heavily relies on Golang libraries provided by Hashicorp such as [`tfexec`](https://github.com/hashicorp/terraform-exec) and [`hc-install`](https://github.com/hashicorp/hc-install) which allows us to dynamically download and use any version of the Terraform binary. -Thus, we support any existing version of Terraform. +The runner implementation relies on [`tenv`](https://github.com/tofuutils/tenv), a tool from the community which allows us to dynamically download and use any version of Terraform, Terragrunt or OpenTofu (coming soon). Thus, we support any existing version of Terraform. -The runners also support any existing version of [Terragrunt](https://terragrunt.gruntwork.io/). +If no version constraint is set in the TerraformLayer resource or in the TerraformRepository resource, `tenv` will detect which version of Terraform/Terragrunt/OpenTofu to use by looking at the version constraints in your code. -The runner is responsible to update the annotations of the layer it is associated with to store information about what commit was plan/apply and when. +The runner is responsible to update the annotations of the layer it is associated to to store information about what commit was planned/applied and when. diff --git a/docs/user-guide/terraform-version.md b/docs/user-guide/terraform-version.md index c9babc43..1d3f7f2d 100644 --- a/docs/user-guide/terraform-version.md +++ b/docs/user-guide/terraform-version.md @@ -1,10 +1,12 @@ -# Choose a terraform/terragrunt version +# Configure a Terraform/Terragrunt/OpenTofu version -For now, Burrito doesn't auto-detect the terraform or terragrunt version used in your repository. You have to specify it in the `TerraformRepository` or `TerraformLayer` resource. +By leveraging [`tenv`](https://github.com/tofuutils/tenv), Burrito auto-detects the Terraform, Terragrunt or OpenTofu version used in your repository, with version constraints set in your code (see [`tenv`'s README](https://github.com/tofuutils/tenv/blob/main/README.md)). -## Choose terraform version +Additionally, you can to specify version constraints in the `TerraformRepository` or `TerraformLayer` resource as described below. -Both `TerraformRepository` and `TerraformLayer` expose a `spec.terrafrom.version` map field. +## Choose Terraform version + +Both `TerraformRepository` and `TerraformLayer` expose a `spec.terraform.version` map field that support version constraints as described in the [Terraform documentation](https://www.terraform.io/docs/language/expressions/version-constraints.html). If the field is specified for a given `TerraformRepository` it will be applied by default to all `TerraformLayer` linked to it. @@ -12,7 +14,7 @@ If the field is specified for a given `TerraformLayer` it will take precedence o ## Enable Terragrunt -You can specify usage of terragrunt as follow: +You can specify usage of Terragrunt with the `spec.terraform.terragrunt` map as follow: ```yaml apiVersion: config.terraform.padok.cloud/v1alpha1 @@ -21,7 +23,7 @@ metadata: name: random-pets-terragrunt spec: terraform: - version: "1.3.1" + version: "~> 1.3.0" terragrunt: enabled: true version: "0.44.5" @@ -36,3 +38,7 @@ spec: !!! info This configuration can be specified at the `TerraformRepository` level to be enabled by default in each of its layers. + +## Use OpenTofu instead of Terraform + +(coming soon)