hashicorp / hashicorp/hcl

Issue parsing HCL object within a block

Open
#672 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

Hey, I am trying to parse terraform HCL into Golang struct and im facing issues when trying to parse an object inside a Module block. this it the example I am trying to make work:
Terraform file:
```
module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
bucket = "my-s3-bucket"
versioning = {
enabled = true
}
}
```

Golang struct:

```
type Attributes struct {
Source string `hcl:"source,attr"`
Bucket string `hcl:"bucket,attr"`
Versioning Versioning `hcl:"versioning,attr"`
}

type Versioning struct {
Enabled bool `hcl:"enabled,attr"`
}
```

I am being able to parse both of `source` and `bucket` attributes, however, no matter what I try I was not able to parse the `versioning` attribute.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.