Skip to content

Commit c8d354a

Browse files
authored
Minor tone/organization update to Patch concept page. (#2222)
* Minor tone/organization update to Patch concept page. * Additional tweaks to patch concept page. * One final tweak.
1 parent 9835ffa commit c8d354a

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

docs/2.0/docs/patcher/concepts/patches.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,63 @@ steps:
2525

2626
[Check out an example of a patch in the CIS Service Catalog.](https://github.com/gruntwork-io/terraform-aws-service-catalog/blob/c3d5ede211fc3230a7d493ceea43622b337ee88a/.patcher/patches/v0.96.4/switch-to-cis-rds-module/patch.yaml)
2727

28+
## Module consumers and module authors
29+
30+
Patcher is built around the idea of two specific personas:
31+
32+
- **Module authors.** Module authors write OpenTofu/Terraform modules, or make updates to those modules.
33+
- **Module consumers.** Module consumers make use of an OpenTofu/Terraform module that was created by a module author, typically in Terragrunt units (`terragrunt.hcl` files) or directly in OpenTofu/Terraform code that calls a module.
34+
35+
## For Module Authors
36+
37+
Module authors periodically need to introduce breaking changes in their modules, causing a downstream, potentially painful, experience for module consumers.
38+
With patches, module authors include a patch YAML file that automatically updates consuming code to incorporate the breaking changes associated with the updated module code. For example, when module consumers "execute" a patch and their code will automatically be updated to add a variable, rename a variable, update a provider reference, or incorporate some other transformation specified by the module author.
39+
This allows module consumers to automatically update consuming code to adopt breaking changes.
40+
41+
In a Patcher ecosystem, the module author spends a small amount of extra time to author a patch, but now all module consumers can automatically update their code to consume the latest breaking change.
42+
43+
In theory, you may write whatever command execution steps you want to perform patch steps.
44+
For example, there are many cases where validating tool versions are required, or using `sed` to find and replace certain values.
45+
However, we _strongly_ recommend using [`terrapatch`](https://github.com/gruntwork-io/terrapatch), a Gruntwork tool that surgically updates Terraform/OpenTofu HCL files.
46+
2847
## For Module Consumers
2948

30-
As an OpenTofu/Terraform module consumer, modules are imported to launch infrastructure by writing Terragrunt units (`terragrunt.hcl` files) or OpenTofu/Terraform code that calls a module.
49+
When module consumers reference an OpenTofu/Terraform module, it is a best practice to reference a specific version of the OpenTofu/Terraform module.
50+
Over time, module authors release new versions of the module, and the code that consumes those modules slowly gets out of date.
51+
In some cases, the latest update of the underlying modules requires a breaking change to the consuming code, meaning the version can't just be bumped; the code needs to be edited.
52+
This is when using a patch with Patcher comes in handy.
3153

32-
It is best practice to reference a specific version of an OpenTofu/Terraform module.
33-
Over time, module authors release new versions of the module, and the code that consumes those modules slowly gets out of date.
34-
In some cases, the latest update of the underlying modules requires a breaking change to the consuming code, meaning the version can't just be bumped.
35-
The consuming code needs to be edited to make use of the new version.
36-
In this instance, using a patch with Patcher comes in handy.
54+
### Two update strategies
3755

38-
Patches can be consumed with either a "push" strategy, when Patcher proactively opens a pull request with the latest update, or a "pull" strategy, when a repo is manually scanned to look at the current state of your infrastructure using the Patcher CLI tool.
56+
Patches can be consumed with either a "push" strategy, where Patcher proactively opens a pull request with the latest update, or a "pull" strategy, where a repo is manually scanned to look at the current state of your infrastructure using the Patcher CLI tool.
3957

40-
Regardless of methodology, the concept remains the same.
41-
Patcher will suggest changes to your codebase in order to keep your infrastructure up to date, however you see fit.
58+
Regardless of methodology, the concept remains the same.
59+
Patcher will suggest changes to your codebase in order to keep your infrastructure up to date, however you see fit.
4260

43-
Here is an example of what your PR will look like, after being generated by Patcher:
61+
### Update Push Strategy
62+
63+
In the "push" strategy, Patcher opens pull requests against your codebase on a schedule you set. You can further customize how those pull requests are grouped by environment, module version, or other parameters. Here is an example of such a pull request:
4464

4565
![Patcher PR Example](/img/patcher/pr-example.png)
4666

47-
### Update Push Strategy
67+
You can implement the push strategy by using the [Patcher GitHub action workflow](https://github.com/gruntwork-io/patcher-action).
4868

49-
Let's take a look at the experience of the "push" strategy available through our [GitHub action](https://github.com/gruntwork-io/patcher-action).
50-
Using the GitHub action, PRs will be opened against your codebase on a cadence specified by you, against environments, versions, etc. specified by you.
51-
The intention with this GitHub action is to leave the repo owner in full control of your upgrade cadence. Check out our guide on [promotion workflows](/2.0/docs/patcher/guides/promotion-workflows), so that updates can proceed from `dev` to `stage` to `prod` (or any other environment sequence) to mitigate risks around upgrades.
69+
The intention with this GitHub action is to leave the repo owner in full control of your upgrade cadence. Check out our guide on [promotion workflows](/2.0/docs/patcher/guides/promotion-workflows), so that updates can proceed from `dev` to `stage` to `prod` (or any other environment sequence) to mitigate risks around upgrades.
5270

5371
### Update Pull Strategy
5472

55-
Let's take a look at the experience of "pulling" available updates by using the Patcher CLI tool.
56-
The first step is to run `patcher update` within the repo in which updates are desired.
57-
When `patcher update` is run, the default mode is to click through the updates **interactively**.
73+
In the "pull" strategy, you the user choose to launch the Patcher CLI to scan the current state of your repo.
74+
75+
The first step is to run `patcher update` within the repo in which updates are desired.
76+
When `patcher update` is run, the default mode is to click through the updates **interactively**.
5877
In this mode, available updates are found, and the details of those updates are presented to you:
5978

6079
![Patcher Update Interactive Mode](/img/patcher/interactive-update.png)
6180

62-
You can choose to run in `--non-interactive` mode, which will modify the codebase and present results about what the program did at the end.
81+
You can choose to run in `--non-interactive` mode, which will modify the codebase and present results about what the program did at the end.
6382

64-
By default a PR will _not_ be opened with the changes.
65-
However, the changes should be visible within the version control system. At that point, you may make a PR or apply the changes using your IaC system.
83+
By default a pull request will _not_ be opened with the changes.
84+
However, the changes should be visible within the version control system. At that point, you may make a pull request or apply the changes using your IaC system.
6685

6786
### Examples Running `patcher update`
6887

@@ -81,17 +100,5 @@ If more fine-grain controls are desired, the following example (which includes a
81100
$ patcher update --update-strategy next-safe --non-interactive --publish --pr-branch grunty/update-via-patcher --pr-title "[Patcher] Update All Dependencies to Next Safe"
82101
```
83102

84-
More details on the available options included in `patcher update` can be found in the [reference section](/2.0/reference/patcher/index.md#update).
85-
86-
## For Module Authors
87-
88-
Module authors periodically need to introduce breaking changes in their modules, causing a downstream, potentially painful, experience for module consumers.
89-
With patches, module authors include a patch YAML file that automatically updates consuming code to incorporate the breaking changes associated with the updated module code.
90-
Doing so allows module consumers to use patches to enable their modules consumers to automatically update consuming code to adopt breaking changes.
91-
92-
In a Patcher ecosystem, the resolution to such a change is written once, in a patch, and distributed to all consumers.
93-
Although your release will succeed with or without a patch, downstream consumers of your breaking change will praise you thoroughly for your advance work.
103+
More details on the available options included in `patcher update` can be found in the [reference section](/2.0/reference/patcher/index.md#update).
94104

95-
In theory, you may write whatever command execution steps you want to perform patch steps.
96-
For example, there are many cases where validating tool versions are required, or using `sed` to find and replace certain values.
97-
However, we _strongly_ recommend using [`terrapatch`](https://github.com/gruntwork-io/terrapatch), a Gruntwork tool that surgically updates Terraform/OpenTofu HCL files.

0 commit comments

Comments
 (0)