hashicorp / hashicorp/packer

Documentation for variable `type`s talks about "keyword `any`", but `any` is not a valid type.

Open
#12,805 2 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
15.8k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

#### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment

#### Overview of the Issue

I need to accept a variable that can contain any object, not an object with specific fields. By reading the following documentation in https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables#type-constraints …

> The keyword `any` may be used to indicate that any type is acceptable.

I expected that I could use either `type = any` or `type = object(any)`. Neither is accepted by the parser.

If `any` is not a valid keyword, then it should not be in the documentation as a valid keyword.

#### Reproduction Steps

```
variable "foo" {
type = any
default = {}
}
```
or
```
variable "foo" {
type = object(any)
default = {}
}
```

### Packer version

`1.9.4`

### Simplified Packer Template

template 1:
```
variable "foo" {
type = any
default = {}
}
```

template 2:
```
variable "foo" {
type = object(any)
default = {}
}
```

### Operating system and Environment details

```
$ uname -a
Linux turbinevm-builder 4.18.0-448.el8.x86_64 #1 SMP Wed Jan 18 15:02:46 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
```

### Log Fragments and crash.log files

for template 1:
```
$ packer init t.pkr.hcl
Error: Invalid type specification

on t.pkr.hcl line 2, in variable "foo":
2: type = any

The keyword "any" cannot be used in this type specification: an exact type is
required.
```

for template 2:
```
$ packer init t2.pkr.hcl
Error: Invalid type specification

on t2.pkr.hcl line 2, in variable "foo":
2: type = object(any)

Object type constructor requires a map whose keys are attribute names and whose
values are the corresponding attribute types.
```

Contributor guide

Open the contributing guide

Research direction

Start with the variable type constraints page linked in the issue and compare its description of `any` with the reported Packer parser errors from version 1.9.4. Done means the documentation accurately explains whether `any` is valid and shows syntax that Packer accepts.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.