-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QT-601] Nest scenario step variables in eval context (#107)
Previously we'd expose any know scenario step variables at the top-level of a steps entry in the eval context. This leads to problems if a Terraform module has both an input and output with the same name. Consider the following scenario: ```hcl module "cluster" { source = "./modules/cluster" } module "worker" { source = "./modules/worker" } variable "addr" { type = string default = "http://192.168.0.1" } scenario "boundary" { step "cluster" { module = module.cluster variables { addr = var.addr } } step "worker" { module = module.worker variables { upstream_addr = step.cluster.addr } } step "worker_downstream" { module = module.worker variables { upstream_addr = step.worker.upstream_addr } } } ``` We expect expect `step.cluster.addr` to be the known value of of `var.addr`. But what happens with step worker here is the problem. `step.worker.upstream_addr` should be module call to `step.cluster.addr` but because we've exposed `step.cluster.addr` in the eval context we don't do a module call, and instead inherit the value from `var.addr`. The same happens with `step.worker_downstream.upstream_addr`. Instead of being a module call to `step.worker.upstream_addr` we inherit the know value of `var.addr`. With this change that behavior is now default. If you wish to use the prior behavior (getting a steps known variables) you can access them with the `variables` key, e.g. `step.cluster.variables.addr`. - [x] The commit message includes an explanation of the changes - [x] Manual validation of the changes have been performed (if possible) - [x] New or modified code has requisite test coverage (if possible) - [x] I have performed a self-review of the changes - [x] I have made necessary changes and/or pull requests for documentation - [x] I have written useful comments in the code Signed-off-by: Ryan Cragun <[email protected]>
- Loading branch information
1 parent
cc21213
commit 547ee1a
Showing
7 changed files
with
155 additions
and
43 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
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 |
---|---|---|
|
@@ -2,6 +2,10 @@ variable "ami" { | |
type = string | ||
} | ||
|
||
output "ami" { | ||
value = var.ami | ||
} | ||
|
||
output "ips" { | ||
value = ["127.0.0.1"] | ||
} |
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