Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform fmt produces incorrect indents for resource properties after heredoc with templating #35645

Open
VladRassokhin opened this issue Aug 27, 2024 · 1 comment
Labels
bug new new issue not yet triaged

Comments

@VladRassokhin
Copy link
Contributor

VladRassokhin commented Aug 27, 2024

Terraform Version

Terraform v1.9.5
on darwin_arm64

Terraform Configuration Files

resource "aws_instance" "test" {
  user_data = <<EOF
#!/bin/bash
${templatefile("${path.module}/userdata.sh", {
  var = local.var
})}
EOF

  root_block_device {
    volume_size           = var.disk_size
    delete_on_termination = true
  }
}

Debug Output

https://gist.github.com/VladRassokhin/baa20d094a8de5b8a09610e1bb930cf2

Expected Behavior

Indentation of root_block_device kept as is.

Actual Behavior

Indentation changes to:

resource "aws_instance" "test" {
  user_data = <<EOF
#!/bin/bash
${templatefile("${path.module}/userdata.sh", {
  var = local.var
})}
EOF

root_block_device {
  volume_size           = var.disk_size
  delete_on_termination = true
}
}

Steps to Reproduce

terraform fmt -write=true test.tf

Additional Context

Removing templating from the heredoc or removing {} from templatefile helps.

References

No response

@VladRassokhin VladRassokhin added bug new new issue not yet triaged labels Aug 27, 2024
@crw
Copy link
Collaborator

crw commented Aug 27, 2024

Thanks for this report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants