Merge pull request #620 from Banno/fix-multi-var-module-state

Fix for multivars when modulestate not created yet
This commit is contained in:
Armon Dadgar 2014-12-03 11:59:10 -08:00
commit cd50d71538
4 changed files with 14 additions and 5 deletions

View File

@ -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
}

View File

@ -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"

View File

@ -1,3 +1,5 @@
variable "things" {}
resource "aws_instance" "bar" {
baz = "baz"
count = 2

View File

@ -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)}"
}