core: fix test fixtures for HCL2 syntax idiom

A number of our test fixtures were previously using the non-idiomatic form
of including a single child attribute all on one line with the block
header and bounding braces.

This non-idiomatic form is an error in HCL2, and hclfmt has always "fixed"
it to the expected form of each attribute being on a line of its own, and
so here we just update all the affected test fixtures to canonical form
(using hclfmt), allowing them to be parsed as intended.

Since the these entire files were processed with hclfmt, there are some
other unrelated style changes included in situations where the file
layouts were non-idiomatic in other ways.
This commit is contained in:
Martin Atkins 2018-05-04 20:26:07 -07:00
parent c82e3ec92f
commit b33a970b62
44 changed files with 205 additions and 96 deletions

View File

@ -1,5 +1,8 @@
resource "aws_instance" "bar" {
count = 2
foo = "bar"
lifecycle { create_before_destroy = true }
count = 2
foo = "bar"
lifecycle {
create_before_destroy = true
}
}

View File

@ -1,3 +1,5 @@
resource "aws_instance" "bar" {
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}

View File

@ -1,15 +1,17 @@
variable "count" { default = 15 }
variable "count" {
default = 15
}
resource "aws_instance" "bar" {
count = "${var.count}"
foo = "index-${count.index}"
count = "${var.count}"
foo = "index-${count.index}"
}
resource "aws_instance" "baz" {
count = "${var.count}"
foo = "baz-${element(aws_instance.bar.*.foo, count.index)}"
count = "${var.count}"
foo = "baz-${element(aws_instance.bar.*.foo, count.index)}"
}
output "should-be-11" {
value = "${element(aws_instance.baz.*.foo, 11)}"
value = "${element(aws_instance.baz.*.foo, 11)}"
}

View File

@ -1,10 +1,12 @@
variable "count" { default = 15 }
variable "count" {
default = 15
}
resource "aws_instance" "bar" {
count = "${var.count}"
foo = "index-${count.index}"
count = "${var.count}"
foo = "index-${count.index}"
}
output "should-be-11" {
value = "${element(aws_instance.bar.*.foo, 11)}"
value = "${element(aws_instance.bar.*.foo, 11)}"
}

View File

@ -1 +1,3 @@
output "foo" { value = "bar" }
output "foo" {
value = "bar"
}

View File

@ -1 +1,3 @@
output "foo" { value = "bar" }
output "foo" {
value = "bar"
}

View File

@ -1,11 +1,14 @@
provider "another" {
foo = "bar"
foo = "bar"
}
provider "another" {
alias = "two"
foo = "bar"
alias = "two"
foo = "bar"
}
resource "another_instance" "foo" {}
resource "another_instance" "bar" { provider = "another.two" }
resource "another_instance" "bar" {
provider = "another.two"
}

View File

@ -1 +1,3 @@
module "child" { source = "./child" }
module "child" {
source = "./child"
}

View File

@ -1,7 +1,9 @@
resource "aws_instance" "foo" { foo = "bar" }
resource "aws_instance" "foo" {
foo = "bar"
}
module "child" {
source = "./child"
source = "./child"
var = "${aws_instance.foo.foo}"
var = "${aws_instance.foo.foo}"
}

View File

@ -1 +1,3 @@
terraform { required_version = ">= 0.5.0" }
terraform {
required_version = ">= 0.5.0"
}

View File

@ -1,5 +1,7 @@
resource "aws_instance" "A" {
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}
resource "aws_instance" "B" {

View File

@ -1,9 +1,13 @@
resource "aws_instance" "A" {
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}
resource "aws_instance" "B" {
value = ["${aws_instance.A.*.id}"]
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}

View File

@ -1,7 +1,11 @@
variable "input" {}
resource "null_resource" "foo" {
triggers { input = "${var.input}" }
triggers {
input = "${var.input}"
}
}
output "output" { value = "${null_resource.foo.id}" }
output "output" {
value = "${null_resource.foo.id}"
}

View File

@ -1,11 +1,13 @@
variable "input" { default = "value" }
variable "input" {
default = "value"
}
module "A" {
source = "./A"
input = "${var.input}"
source = "./A"
input = "${var.input}"
}
module "B" {
source = "./A"
input = "${module.A.output}"
source = "./A"
input = "${module.A.output}"
}

View File

@ -1,4 +1,7 @@
variable "key" {}
provider "null" { key = "${var.key}" }
provider "null" {
key = "${var.key}"
}
resource "null_resource" "foo" {}

View File

@ -1,4 +1,7 @@
variable "key" {}
provider "null" { key = "${var.key}" }
provider "null" {
key = "${var.key}"
}
resource "null_resource" "foo" {}

View File

@ -1,2 +1,7 @@
module "child1" { source = "./child1" }
module "child2" { source = "./child2" }
module "child1" {
source = "./child1"
}
module "child2" {
source = "./child2"
}

View File

@ -1 +1,3 @@
output "list" { value = "foo,bar,baz" }
output "list" {
value = "foo,bar,baz"
}

View File

@ -1,7 +1,9 @@
variable "c" { default = 1 }
variable "c" {
default = 1
}
resource "template_file" "parent" {
count = "${var.c}"
count = "${var.c}"
template = "Hi"
}

View File

@ -1,11 +1,17 @@
resource "aws_instance" "foo" {
count = "2"
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}
resource "aws_instance" "bar" {
count = "2"
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}
output "out" {

View File

@ -1,3 +1,5 @@
resource "aws_instance" "foo" {
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}

View File

@ -1,11 +1,14 @@
resource "aws_instance" "foo" {
count = 2
count = 2
num = "2"
compute = "${element(data.aws_vpc.bar.*.id, count.index)}"
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}
data "aws_vpc" "bar" {
count = 2
foo = "${count.index}"
foo = "${count.index}"
}

View File

@ -3,13 +3,14 @@ resource "aws_computed_source" "intermediates" {}
module "test_mod" {
source = "./mod"
services {
"exists" = "true"
"elb" = "${aws_computed_source.intermediates.computed_read_only}"
}
services {
"otherexists" = " true"
"elb" = "${aws_computed_source.intermediates.computed_read_only}"
}
services = [
{
"exists" = "true"
"elb" = "${aws_computed_source.intermediates.computed_read_only}"
},
{
"otherexists" = " true"
"elb" = "${aws_computed_source.intermediates.computed_read_only}"
},
]
}

View File

@ -1,6 +1,8 @@
variable "foo" { default = "3" }
variable "foo" {
default = "3"
}
module "child" {
source = "./child"
value = "${var.foo}"
source = "./child"
value = "${var.foo}"
}

View File

@ -1,6 +1,8 @@
variable "foo" { default = "3" }
variable "foo" {
default = "3"
}
module "child" {
source = "./child"
value = "${var.foo}"
source = "./child"
value = "${var.foo}"
}

View File

@ -1,4 +1,7 @@
resource "aws_instance" "foo" {
count = "${length("abc")}"
lifecycle { create_before_destroy = true }
lifecycle {
create_before_destroy = true
}
}

View File

@ -1 +1,3 @@
module "B" { source = "../B" }
module "B" {
source = "../B"
}

View File

@ -1 +1,3 @@
module "C" { source = "../C" }
module "C" {
source = "../C"
}

View File

@ -1,6 +1,8 @@
variable "foo" { default = "bar" }
variable "foo" {
default = "bar"
}
module "child" {
source = "./child"
foo = "${var.foo}"
source = "./child"
foo = "${var.foo}"
}

View File

@ -1,7 +1,7 @@
resource "aws_instance" "foo" {
num = "2"
num = "2"
}
output "num" {
value = "${aws_instance.foo.num}"
value = "${aws_instance.foo.num}"
}

View File

@ -1,7 +1,7 @@
module "child" {
source = "./child"
source = "./child"
}
resource "aws_instance" "bar" {
foo = "${module.child.num}"
foo = "${module.child.num}"
}

View File

@ -1,10 +1,13 @@
variable "map_in" {
type = "map"
default = {
us-west-1 = "ami-12345"
us-west-2 = "ami-67890"
}
type = "map"
default = {
us-west-1 = "ami-12345"
us-west-2 = "ami-67890"
}
}
// We have to reference it so it isn't pruned
output "output" { value = "${var.map_in}" }
output "output" {
value = "${var.map_in}"
}

View File

@ -1,5 +1,7 @@
resource "aws_instance" "foo" {
foo = "bar"
foo = "bar"
}
output "value" { value = "${aws_instance.foo.id}" }
output "value" {
value = "${aws_instance.foo.id}"
}

View File

@ -1,4 +1,7 @@
variable "key" {}
provider "null" { key = "${var.key}" }
provider "null" {
key = "${var.key}"
}
resource "null_resource" "foo" {}

View File

@ -1,4 +1,7 @@
variable "key" {}
provider "null" { key = "${var.key}" }
provider "null" {
key = "${var.key}"
}
resource "null_resource" "foo" {}

View File

@ -1 +1,3 @@
output "foo" {}
output "foo" {
value = ""
}

View File

@ -1,2 +1,5 @@
resource "test" "A" {}
resource "test" "B" { value = "${test.A.value}" }
resource "test" "B" {
value = "${test.A.value}"
}

View File

@ -1,5 +1,7 @@
resource "aws_instance" "b" {
value = "foo"
value = "foo"
}
output "output" { value = "${aws_instance.b.value}" }
output "output" {
value = "${aws_instance.b.value}"
}

View File

@ -1,3 +1,9 @@
resource "test" "A" {}
resource "test" "B" { value = "${test.A.value}" }
resource "test" "C" { value = "${test.B.value}" }
resource "test" "B" {
value = "${test.A.value}"
}
resource "test" "C" {
value = "${test.B.value}"
}

View File

@ -1,6 +1,9 @@
resource "aws_instance" "foo" {}
resource "aws_instance" "bar" { value = "${aws_instance.foo.value}" }
resource "aws_instance" "bar" {
value = "${aws_instance.foo.value}"
}
module "child" {
source = "./child"
source = "./child"
}

View File

@ -1,3 +1,5 @@
variable "value" {}
output "result" { value = "${var.value}" }
output "result" {
value = "${var.value}"
}

View File

@ -1,3 +1,5 @@
variable "value" {}
output "result" { value = "${var.value}" }
output "result" {
value = "${var.value}"
}

View File

@ -1 +1,3 @@
resource "aws_instance" "foo" { count = 3 }
resource "aws_instance" "foo" {
count = 3
}

View File

@ -1,3 +1,5 @@
resource "aws_instance" "source" { }
resource "aws_instance" "source" {}
output "sourceout" { value = "${aws_instance.source.id}" }
output "sourceout" {
value = "${aws_instance.source.id}"
}