-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: WIP - Patcher test * chore: test a sample patch
- Loading branch information
1 parent
b383c2b
commit 6a34d13
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
versions: | ||
- tag: v0.10.2 | ||
patches: | ||
- slug: "sample-breaking-change" | ||
modules_affected: | ||
- patcher-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: "Sample Breaking Change" | ||
description: A sample breaking change that renames a resource | ||
author: Gruntwork | ||
|
||
# Optional list of dependencies that the patch requires. | ||
dependencies: | ||
- name: terrapatch | ||
version: "0.1.0" | ||
|
||
# List of steps that this patch should execute. | ||
# Each step has a name field (string) and a run field, which can denote either an OS command, or an external script to be run. | ||
# If there are any external scripts, then make sure you include these in the same directory where the patch.yaml file is. | ||
steps: | ||
- name: | ||
run: terrapatch move-resource --path $PATCHER_MODULE_PATH terraform $PATCHER_MODULE_ADDRESS module.null_resource.test2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Operating System Module | ||
|
||
This is a module that can be used to figure out what operating system is being used to run Terraform. This may be used | ||
to modify Terraform's behavior depending on the OS, such as modifying the way you format file paths on Linux vs | ||
Windows (see also the [join-path module](/modules/join-path)). | ||
|
||
This module uses Python under the hood so, the Python must be installed on the OS. | ||
|
||
|
||
|
||
|
||
## Example code | ||
|
||
See the [operating-system example](/examples/operating-system) for working sample code. | ||
|
||
|
||
|
||
|
||
## Usage | ||
|
||
Simply use the module in your Terraform code, replacing `<VERSION>` with the latest version from the [releases | ||
page](https://github.com/gruntwork-io/terraform-aws-utilities/releases): | ||
|
||
```hcl | ||
module "os" { | ||
source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/operating-system?ref=<VERSION>" | ||
} | ||
``` | ||
|
||
* You can now get the name of the operating system from the `name` output, which will be set to either `Linux`, | ||
`Darwin`, or `Windows` | ||
|
||
* You can also get the path separator for the current OS—backslash for Windows, forward slash everywhere else—from the | ||
`path_separator` output. | ||
|
||
```hcl | ||
operating_system_name = "${module.os.name}" | ||
path_separator = "${module.os.path_separator}" | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
terraform { | ||
required_version = ">= 1.0.0" | ||
} | ||
|
||
data "external" "os" { | ||
program = ["python3", "-c", <<-EOF | ||
import json | ||
import os | ||
import platform | ||
print(json.dumps({ | ||
"platform": platform.system(), | ||
"path_separator": os.sep, | ||
})) | ||
EOF | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
output "name" { | ||
value = data.external.os.result.platform | ||
} | ||
|
||
output "path_separator" { | ||
value = data.external.os.result.path_separator | ||
} |