hashicorp / hashicorp/packer-plugin-amazon
Add optional configuration option `ignore_missing` or `default` in data plugin parameterstore
- Dominant language
- Go
- Stars
- 91
- Forks
- 141
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 3
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 "me too" comments, 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.
#### Description
**Fact 1:** Currently there is no option to get packer to work, when a referenced aws ssm parameter is not existant.
**Fact 2:** aws parameter store does not allow for empty strings.
This leads to problems where a string is existant on one environment, but empty on another one.
The big problem is, that there is no real workaround in packer. The only chance to escape is, to convert to a variable and wrap it with some shell magic before execution. But this is what I wanted to get dropped with using the cool ssm paramter store plugin.
#### Use Case(s)
The essence of the problem is, that *AWS SSM Parameter Store* does NOT allow for empty strings. See e.g. [this aws forum entry](https://forums.aws.amazon.com/thread.jspa?threadID=282296) (aws login required, see all the way down screenshot).
In our environment we have a variable called *environment_suffix*. This variable is *"-dev"* on dev, *"-qa"* on qa and *""* on prod. So, it is an empty string on prod.
We use this parameter in our builds to suffix objects to make the environment more clear.
In theory we could work with [`try()`](https://www.packer.io/docs/templates/hcl_templates/functions/conversion/try), but Packer exits completely and does not continue to work.
Another option would be to allow for a default value in case the parameter is not available in the destination ssm parameter store.
#### Potential configuration
One option would be to ignore the fail, then handle the parameter with `try()` in packer config.
```hcl2
data "amazon-parameterstore" "environment_suffix" {
name = "/environment/suffix"
with_decryption = false
ignore_fail = true
}
```
or
```hcl2
data "amazon-parameterstore" "environment_suffix" {
name = "/environment/suffix"
with_decryption = false
default = ""
}
```
#### Potential References
* https://www.packer.io/docs/datasources/amazon/parameterstore
* https://www.packer.io/docs/templates/hcl_templates/functions/conversion/try
* https://forums.aws.amazon.com/thread.jspa?threadID=282296

Contributor guide
Assessment
This issue has not been assessed yet.