-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from breml/fixes
Fixes
- Loading branch information
Showing
28 changed files
with
906 additions
and
143 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,2 @@ | ||
# Declare files that will always have LF line endings on checkout | ||
*.golden text eol=lf |
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
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 |
---|---|---|
@@ -1,18 +1,41 @@ | ||
# tfreveal | ||
|
||
terraform does mask sensitive values in the output (e.g. from `terraform plan`) | ||
in order to protect them from being reveals to 3rd parties. | ||
Terraform does mask sensitive values in the output (e.g. from `terraform plan`) | ||
in order to protect them from being revealed to 3rd parties. | ||
|
||
Sometimes it is neccessary to see the exact changes, terraform will perform to the | ||
infrastructure including all the changes to sensitive values. So far, terraform | ||
Sometimes it is neccessary to see the exact changes, Terraform will perform to the | ||
infrastructure including all the changes to sensitive values. So far, Terraform | ||
does not provide a feature to forcefully unmask the sensitive values in the | ||
[concise diff plan outputs](https://www.hashicorp.com/blog/terraform-0-14-adds-a-new-concise-diff-format-to-terraform-plans). | ||
The general advice given by the terraform maintainers is to use the JSON output | ||
The general advice given by the Terraform maintainers is to use the JSON output | ||
in such cases. While the JSON output does provide all the necessary information, | ||
it is not perticularely easy to read for humans and to spot small differences. | ||
It gets even more complicated, if the sensitive values contain larger JSON | ||
encoded values. | ||
|
||
There exists instructions using for example `jq`, but the process stays manual, | ||
cumbersome and error prone. | ||
|
||
`tfreveal` is here to fix this and provide an easy way to show the concise diff | ||
plan outputs with all sensitive values revealed. | ||
|
||
## Usage | ||
|
||
The plan file generated from Terraform can be directly piped to `tfreveal`: | ||
|
||
```bash | ||
$ terraform plan -out plan.out | ||
$ terraform show -json plan.out | tfreveal | ||
``` | ||
|
||
Alternatively, the plan file can also be passed as argument: | ||
|
||
```bash | ||
$ terraform plan -out plan.out | ||
$ terraform show -json plan.out > plan.json | ||
$ tfreveal plan.json | ||
``` | ||
|
||
## Trademarks | ||
|
||
All other trademarks referenced herein are the property of their respective owners. |
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
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
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
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
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
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,42 @@ | ||
package main | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMain0(t *testing.T) { | ||
files, err := filepath.Glob(filepath.Join("testdata", "*")) | ||
require.NoError(t, err) | ||
|
||
for _, filename := range files { | ||
filename := filename | ||
t.Run(filename, func(t *testing.T) { | ||
defer func(orig *os.File) { | ||
os.Stdout = orig | ||
}(os.Stdout) | ||
|
||
r, w, err := os.Pipe() | ||
require.NoError(t, err) | ||
|
||
os.Stdout = w | ||
|
||
err = main0([]string{"tfreveal", "--no-color", filepath.Join(filename, "plan.json")}) | ||
require.NoError(t, err) | ||
err = w.Close() | ||
require.NoError(t, err) | ||
|
||
out, err := io.ReadAll(r) | ||
require.NoError(t, err) | ||
|
||
want, err := os.ReadFile(filepath.Join(filename, "output.golden")) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, string(want), string(out)) | ||
}) | ||
} | ||
} |
Oops, something went wrong.