Skip to content

Add terraform output changes along resource changes #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ SHELL:=/bin/sh
help: ## this help
@awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n make \033[36m<target> \033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

local-run: ## Run tftools locally
go run main.go summarize <demo.json

doctoc: ## Create table of contents with doctoc
doctoc .

Expand All @@ -25,6 +28,7 @@ gosec: ## Run gosec
update-dependencies: ## Update dependencies
go get -u ./...


##https://github.com/moovweb/gvm
##go get golang.org/x/tools/cmd/goimports
##go install golang.org/x/tools/cmd/goimports
3 changes: 2 additions & 1 deletion cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"log"
"os"
"runtime"

Expand Down Expand Up @@ -54,7 +55,7 @@ var summarizeCmd = &cobra.Command{

output, err := reader.Reader(os.Stdin)
if err != nil {
panic(err)
log.Fatal(err)
}

parser.Parser(output, showTags, showUnchanged, compact, useMarkdown, useJson, metrics, prettyJSON)
Expand Down
21 changes: 20 additions & 1 deletion demo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"format_version": "1.1",
"terraform_version": "1.2.9",
"terraform_version": "1.8.1",
"planned_values": {
"outputs": {
"test": {
"sensitive": false,
"type": "string",
"value": "test2"
}
},
"root_module": {
"resources": [
{
Expand Down Expand Up @@ -567,6 +574,18 @@
}
}
],
"output_changes": {
"test": {
"actions": [
"update"
],
"before": "test1",
"after": "test2",
"after_unknown": false,
"before_sensitive": false,
"after_sensitive": false
}
},
"prior_state": {
"format_version": "1.0",
"terraform_version": "1.2.9",
Expand Down
2 changes: 2 additions & 0 deletions internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func Parser(output []byte, showTags, showUnchanged, compact, useMarkdown bool, u
return
}

// TODO: add also output changes using data.OutputChanges

for _, resourceChange := range data.ResourceChanges {
processResourceChange(resourceChange, showTags)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ func Reader(stdin *os.File) ([]byte, error) {
}
return data, nil
}
return nil, fmt.Errorf("no data to be processed")
return nil, fmt.Errorf("no data to be processed. Please proide a valid tf plan json file")
}