Using terraform 0.8.4, terraform formats comment block using # signs by placing newlines between every line. IMO, it shoudn't even be adding a newline after a comment starting with a #, let alone a newline between every line.
Original (pre-fmt)
variable "environment" {
default = {}
# default {
# "region" = "us-west-2"
# "sg" = "playground"
# "env" = "prod"
# }
}
Post-fmt
variable "environment" {
default = {}
# default {
# "region" = "us-west-2"
# "sg" = "playground"
# "env" = "prod"
# }
}
The format of adding a newline after a comment block seem arbitrary.
I am seeing the same thing with terraform 0.8.2. Seems to be happen inside variable blocks.
Original:
# Above Foo 1
# Above Foo 2
variable "foo" {
# In Foo 1
# In Foo 2
default = ""
}
Post-fmt:
# Above Foo comment 1
# Above Foo comment 2
variable "foo" {
# In Foo Line 1
# In Foo Line 2
default = ""
}
terraform v0.8.2, Ubuntu 14.04
I'm seeing a variation; it's eating the first comment.
Pre-fmt:
vpc_security_group_ids = ["sg-aaaaaaaa", # SG_USE1_DEV_REM_ACC_V01
"sg-bbbbbbbb", # SG_USE1_DEV_REL_MGMT_V01
"sg-cccccccc", # SG_USE1_DEV_INF_MGMT_V01
"${aws_security_group.docs-us-east-1.id}",
]
Post-fmt:
vpc_security_group_ids = ["sg-aaaaaaaa",
"sg-bbbbbbbb", # SG_USE1_DEV_REL_MGMT_V01
"sg-cccccccc", # SG_USE1_DEV_INF_MGMT_V01
"${aws_security_group.docs-us-east-1.id}",
]
Interesting; it doesn't eat the comment if the first sg-id is on its own line instead of against the opening left bracket.
Pre-fmt:
vpc_security_group_ids = [
"sg-aaaaaaaa", # SG_USE1_DEV_REM_ACC_V01
"sg-bbbbbbbb", # SG_USE1_DEV_REL_MGMT_V01
"sg-cccccccc", # SG_USE1_DEV_INF_MGMT_V01
"${aws_security_group.docs-us-east-1.id}",
]
Post-fmt:
vpc_security_group_ids = [
"sg-aaaaaaaa", # SG_USE1_DEV_REM_ACC_V01
"sg-bbbbbbbb", # SG_USE1_DEV_REL_MGMT_V01
"sg-cccccccc", # SG_USE1_DEV_INF_MGMT_V01
"${aws_security_group.docs-us-east-1.id}",
]
Fixed! Will be in 0.8.5. @rkulagowski I'm taking a look at that, too.
Thanks, looking forward to 0.8.5
There still appear to be issues with this. v0.11.11 turns
cidr_blocks = [
"${var.cidr_blocks}",
"x.x.x.x/32" # GitHub
]
into
cidr_blocks = [
"${var.cidr_blocks}",
"x.x.x.x/32",
] # GitHub
and
# No credentials explicitly set here because they come from either the
# environment or the global credentials file.
into
# No credentials explicitly set here because they come from either the # environment or the global credentials file.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
There still appear to be issues with this.
v0.11.11turnsinto
and
into