hashicorp / hashicorp/packer

aws_secretsmanager crashes on number value

Open
#12,813 1 comment 0 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

Storing a numeric value in a plaintext secret in AWS secrets manager crashes packer.
This was found during an upgrade of an old json template which worked fine on packer 1.4.x.

Error returned:

```
Error: Datasource.Execute failed: error to get secret value: "json: cannot unmarshal number into Go value of type map[string]interface {}"

on template.pkr.hcl line 123:
(source code not available)
```

Fix in #10421 does not seem to cover this scenario. json.Valid returns true, but can't unmarshal?

If I try add quotes to my secret value so it stores `"1234"`, I instead get this error:

```
Error: Datasource.Execute failed: error to get secret value: "json: cannot unmarshal string into Go value of type map[string]interface {}"
```

(cannot unmarshal _string_)

#### Reproduction Steps

* Create a plaintext secret named `numeric_plaintext` stored with value `1234`
* Use the secret in a template

### Packer version

Packer v1.10.0

### Simplified Packer Template

```hcl
packer {
required_plugins {
amazon = {
source = "github.com/hashicorp/amazon"
version = ">= 1.3.0"
}
}
}

data "amazon-secretsmanager" "mysecret" {
name = "numeric_plaintext"
}
```

### Operating system and Environment details

macOS

### Log Fragments and crash.log files

-

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.