terrafmt icon indicating copy to clipboard operation
terrafmt copied to clipboard

Two quoted format verb parameters on the same line do not both get replaced

Open gdavison opened this issue 4 years ago • 0 comments

When a configuration with format verbs has two quoted values on the same line, only the first is replaced.

For example, in https://github.com/hashicorp/terraform-provider-aws/blob/38319aa13aea65d3e946450c1f881d8fef12e734/aws/resource_aws_ecs_capacity_provider_test.go#L438-L448

resource "aws_ecs_capacity_provider" "test" {
  name = %[1]q

  tags = {
    %[2]q = %[3]q,
  }

  auto_scaling_group_provider {
    auto_scaling_group_arn = aws_autoscaling_group.test.arn
  }
}

Expected Result

the line%[2]q = %[3]q, should be replaced with "@@_@@ TFMT:%[2]q:TFMT @@_@@" = "@@_@@ TFMT:%[3]q:TFMT @@_@@", or something similar

Actual Result

the line%[2]q = %[3]q, is replaced with "@@_@@ TFMT:%[2]q:TFMT @@_@@" = %[3]q,, and terrafmt fmt fails.

gdavison avatar Apr 19 '21 19:04 gdavison