Skip to content

Commit

Permalink
docs(runner): update docs for tenv and runner refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
corrieriluca authored and AlanLonguet committed Sep 2, 2024
1 parent 4d141a5 commit 6bca876
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 0 additions & 2 deletions docs/examples/terraform-layer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ spec:
repository:
name: my-repository
namespace: burrito-project
terraform:
version: 1.3.1
10 changes: 4 additions & 6 deletions docs/guides/iac-drift-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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}}}'
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/pr-mr-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <my-webhook-secret>
Expand Down Expand Up @@ -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.

Expand Down
7 changes: 3 additions & 4 deletions docs/operator-manual/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 12 additions & 6 deletions docs/user-guide/terraform-version.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# 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.

If the field is specified for a given `TerraformLayer` it will take precedence over the `TerraformRepository` configuration.

## 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
Expand All @@ -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"
Expand All @@ -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)

0 comments on commit 6bca876

Please sign in to comment.