-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve Expressions when it references variables in called modules (#77)
- Loading branch information
1 parent
1d5b47a
commit ecfacb4
Showing
4 changed files
with
245 additions
and
8 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
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,25 @@ | ||
package utils | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
tfjson "github.com/hashicorp/terraform-json" | ||
) | ||
|
||
func LoadPlan(planFilePath string) *tfjson.Plan { | ||
planBytes, err := os.ReadFile(planFilePath) | ||
if err != nil { | ||
log.Fatalf("Unable to read JSON plan file: %s", err) | ||
} | ||
|
||
var plan tfjson.Plan | ||
err = json.Unmarshal(planBytes, &plan) | ||
if err != nil { | ||
log.Fatalf("Unable to unmarshal JSON plan file: %s", err) | ||
} | ||
|
||
return &plan | ||
} |
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,58 @@ | ||
{ | ||
"format_version": "0.1", | ||
"terraform_version": "0.12.24", | ||
"configuration": { | ||
"provider_config": { | ||
"aws": { | ||
"name": "aws", | ||
"expressions": { | ||
"region": { | ||
"references": [ | ||
"module.module2.module1_region" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"root_module": { | ||
"module_calls": { | ||
"module2": { | ||
"source": "../module2", | ||
"module": { | ||
"outputs": { | ||
"module1_region": { | ||
"expression": { | ||
"references": [ | ||
"module.module1.region" | ||
] | ||
} | ||
} | ||
}, | ||
"module_calls": { | ||
"module1": { | ||
"source": "../module1", | ||
"module": { | ||
"outputs": { | ||
"region": { | ||
"expression": { | ||
"references": [ | ||
"var.region" | ||
] | ||
} | ||
} | ||
}, | ||
"variables": { | ||
"region": { | ||
"default": "region_from_module_calls" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"variables": {} | ||
} |