config: understand provisioner blocks in JSON [GH-807]

This commit is contained in:
Mitchell Hashimoto 2015-01-16 10:14:48 -08:00
parent 58649132cf
commit 91a3405e88
5 changed files with 43 additions and 2 deletions

View File

@ -16,6 +16,7 @@ BUG FIXES:
* core: Escape characters `\"`, `\n`, and `\\` now work in interpolations. * core: Escape characters `\"`, `\n`, and `\\` now work in interpolations.
* core: Fix crash that could occur when there are exactly zero providers * core: Fix crash that could occur when there are exactly zero providers
installed on a system. [GH-786] 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] * provider/aws: ELB subnet change doesn't force new resource. [GH-804]
PLUGIN CHANGES: PLUGIN CHANGES:

View File

@ -517,7 +517,15 @@ func loadProvisionersHcl(os *hclobj.Object, connInfo map[string]interface{}) ([]
// //
for _, o1 := range os.Elem(false) { for _, o1 := range os.Elem(false) {
for _, o2 := range o1.Elem(true) { 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)
}
} }
} }

View File

@ -410,6 +410,10 @@ const basicResourcesStr = `
aws_instance[db] (x1) aws_instance[db] (x1)
VPC VPC
security_groups security_groups
provisioners
file
destination
source
dependsOn dependsOn
aws_instance.web aws_instance.web
vars vars
@ -418,6 +422,10 @@ aws_instance[web] (x1)
ami ami
network_interface network_interface
security_groups security_groups
provisioners
file
destination
source
vars vars
resource: aws_security_group.firewall.foo resource: aws_security_group.firewall.foo
user: var.foo user: var.foo

View File

@ -27,6 +27,11 @@ resource aws_instance "web" {
device_index = 0 device_index = 0
description = "Main network interface" description = "Main network interface"
} }
provisioner "file" {
source = "foo"
destination = "bar"
}
} }
resource "aws_instance" "db" { resource "aws_instance" "db" {
@ -34,6 +39,11 @@ resource "aws_instance" "db" {
VPC = "foo" VPC = "foo"
depends_on = ["aws_instance.web"] depends_on = ["aws_instance.web"]
provisioner "file" {
source = "foo"
destination = "bar"
}
} }
output "web_ip" { output "web_ip" {

View File

@ -22,7 +22,14 @@
"db": { "db": {
"security_groups": ["${aws_security_group.firewall.*.id}"], "security_groups": ["${aws_security_group.firewall.*.id}"],
"VPC": "foo", "VPC": "foo",
"depends_on": ["aws_instance.web"] "depends_on": ["aws_instance.web"],
"provisioner": [{
"file": {
"source": "foo",
"destination": "bar"
}
}]
}, },
"web": { "web": {
@ -34,6 +41,13 @@
"network_interface": { "network_interface": {
"device_index": 0, "device_index": 0,
"description": "Main network interface" "description": "Main network interface"
},
"provisioner": {
"file": {
"source": "foo",
"destination": "bar"
}
} }
} }
}, },