Better roundtriping of HCL

This commit is contained in:
Mike Farah
2025-12-08 21:09:21 +11:00
parent e4bf8a1e0a
commit f4fd8c585a
6 changed files with 159 additions and 11 deletions
+24
View File
@@ -175,3 +175,27 @@ message = "Hello, ${name}!"
shouty_message = upper(message)
```
## Roundtrip: Separate blocks with same name.
Given a sample.hcl file of:
```hcl
resource "aws_instance" "web" {
ami = "ami-12345"
}
resource "aws_instance" "db" {
ami = "ami-67890"
}
```
then
```bash
yq sample.hcl
```
will output
```hcl
resource "aws_instance" "web" {
ami = "ami-12345"
}
resource "aws_instance" "db" {
ami = "ami-67890"
}
```