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

aws_secretsmanager crashes on number value #12813

Open
anderssonjohan opened this issue Jan 29, 2024 · 1 comment
Open

aws_secretsmanager crashes on number value #12813

anderssonjohan opened this issue Jan 29, 2024 · 1 comment
Labels

Comments

@anderssonjohan
Copy link

anderssonjohan commented Jan 29, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction 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

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

@anderssonjohan
Copy link
Author

Workaround:

Use key/value pairs and use key.

  1. Update secret value to:
{ "number": 1234 }
  1. Add key to template:
data "amazon-secretsmanager" "mysecret" {
  name = "numeric_plaintext"
  key = "number"
}

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

No branches or pull requests

1 participant