Skip to content

Commit

Permalink
config: understand provisioner blocks in JSON [GH-807]
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jan 16, 2015
1 parent 5864913 commit 91a3405
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BUG FIXES:
* core: Escape characters `\"`, `\n`, and `\\` now work in interpolations.
* core: Fix crash that could occur when there are exactly zero providers
installed on a system. [GH-786]
* core: JSON TF configurations can configure provisioners. [GH-807]
* provider/aws: ELB subnet change doesn't force new resource. [GH-804]

PLUGIN CHANGES:
Expand Down
10 changes: 9 additions & 1 deletion config/loader_hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,15 @@ func loadProvisionersHcl(os *hclobj.Object, connInfo map[string]interface{}) ([]
//
for _, o1 := range os.Elem(false) {
for _, o2 := range o1.Elem(true) {
pos = append(pos, o2)

switch o1.Type {
case hclobj.ValueTypeList:
for _, o3 := range o2.Elem(true) {
pos = append(pos, o3)
}
case hclobj.ValueTypeObject:
pos = append(pos, o2)
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ const basicResourcesStr = `
aws_instance[db] (x1)
VPC
security_groups
provisioners
file
destination
source
dependsOn
aws_instance.web
vars
Expand All @@ -418,6 +422,10 @@ aws_instance[web] (x1)
ami
network_interface
security_groups
provisioners
file
destination
source
vars
resource: aws_security_group.firewall.foo
user: var.foo
Expand Down
10 changes: 10 additions & 0 deletions config/test-fixtures/basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ resource aws_instance "web" {
device_index = 0
description = "Main network interface"
}

provisioner "file" {
source = "foo"
destination = "bar"
}
}

resource "aws_instance" "db" {
security_groups = "${aws_security_group.firewall.*.id}"
VPC = "foo"

depends_on = ["aws_instance.web"]

provisioner "file" {
source = "foo"
destination = "bar"
}
}

output "web_ip" {
Expand Down
16 changes: 15 additions & 1 deletion config/test-fixtures/basic.tf.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
"db": {
"security_groups": ["${aws_security_group.firewall.*.id}"],
"VPC": "foo",
"depends_on": ["aws_instance.web"]
"depends_on": ["aws_instance.web"],

"provisioner": [{
"file": {
"source": "foo",
"destination": "bar"
}
}]
},

"web": {
Expand All @@ -34,6 +41,13 @@
"network_interface": {
"device_index": 0,
"description": "Main network interface"
},

"provisioner": {
"file": {
"source": "foo",
"destination": "bar"
}
}
}
},
Expand Down

0 comments on commit 91a3405

Please sign in to comment.