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

Splat operators lead to invalid type #81

Closed
archoversight opened this issue Oct 4, 2022 · 4 comments · Fixed by #84 or #85
Closed

Splat operators lead to invalid type #81

archoversight opened this issue Oct 4, 2022 · 4 comments · Fixed by #84 or #85

Comments

@archoversight
Copy link

Using an input file such as:

output "sometest" { value = {
  name = module.instance.*.tags.Name
  id   = module.instance.*.id
} }

When attempting to read it, will lead to this error:

Error: invalid type: string ".*", expected unit

The splat operator is used heavily in our terraform configuration for outputs.

@archoversight
Copy link
Author

As a follow-up this is also an issue with the [*] splat variant:

output "sometest" { value = {
  name = module.instance[*].tags.Name
  id   = module.instance[*].id
} }
Unable to process: invalid type: string "[*]", expected unit

@martinohmann
Copy link
Owner

Hi, this looks like a bug in the deserializer implementation for the traversal operator. It should be fairly easy to fix, i'll try to provide a fix later today.

This should not happen if you use hcl::parse instead of hcl::from_str though.

martinohmann added a commit that referenced this issue Oct 7, 2022

Verified

This commit was signed with the committer’s verified signature.
JoshuaKGoldberg Josh Goldberg ✨
Fixes #81
@martinohmann
Copy link
Owner

@archoversight I just published https://crates.io/crates/hcl-rs/0.8.4 which includes the fix.

@archoversight
Copy link
Author

@martinohmann thank you!

I was using hcl::from_reader() so that I can pass it a file that was opened. Is there a better pattern to use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants