mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #620 from Banno/fix-multi-var-module-state
Fix for multivars when modulestate not created yet
This commit is contained in:
commit
cd50d71538
@ -1705,7 +1705,6 @@ func (c *walkContext) computeResourceMultiVariable(
|
||||
}
|
||||
|
||||
// Get the relevant module
|
||||
// TODO: Not use only root module
|
||||
module := c.Context.state.ModuleByPath(c.Path)
|
||||
|
||||
count, err := cr.Count()
|
||||
@ -1716,8 +1715,8 @@ func (c *walkContext) computeResourceMultiVariable(
|
||||
err)
|
||||
}
|
||||
|
||||
// If we have no count, return empty
|
||||
if count == 0 {
|
||||
// If we have no module in the state yet or count, return empty
|
||||
if module == nil || count == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
@ -844,6 +844,9 @@ STATE:
|
||||
const testTerraformPlanModuleMultiVarStr = `
|
||||
DIFF:
|
||||
|
||||
CREATE: aws_instance.parent.0
|
||||
CREATE: aws_instance.parent.1
|
||||
|
||||
module.child:
|
||||
CREATE: aws_instance.bar.0
|
||||
baz: "" => "baz"
|
||||
|
@ -1,3 +1,5 @@
|
||||
variable "things" {}
|
||||
|
||||
resource "aws_instance" "bar" {
|
||||
baz = "baz"
|
||||
count = 2
|
||||
|
@ -1,4 +1,9 @@
|
||||
module "child" {
|
||||
source = "./child"
|
||||
resource "aws_instance" "parent" {
|
||||
count = 2
|
||||
}
|
||||
|
||||
module "child" {
|
||||
source = "./child"
|
||||
things = "${join(",", aws_instance.bar.*.private_ip)}"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user