serverless/serverless

Optionally Parse SSM String Parameters as JSON

開放

#11,289 建立於 2022年7月28日

 (8 則留言) (2 個反應) (0 位負責人)JavaScript (5,734 個分叉)batch import
cat/variablehelp wanted

倉庫指標

星標
 (46,915 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Use case description

I am currently storing various configuration values as JSON strings in SSM. These are mostly lists of strings although some include more complex structures. To simplify use across tools, we've standardized on storing JSON strings.

In Serverless, AWS Secrets Manager and SSM StringLists and SecureStrings will parse as JSON but there is no detection nor manual option to allow for parsing as JSON so it results in something like the following:

    subnetIds:
      Fn::Split:
        - '","'
        - Fn::Select:
          - '1'
          - Fn::Split:
              - '["'
              - Fn::Select:
                - '0'
                - Fn::Split:
                  - '"]'
                  - ${ssm:/<ssm_path>}

Proposed solution (optional)

Add a json option (similar to raw for the other SSM types) to force JSON parsing of SSM String values.

  • OR -

Add a generic function that parses strings as JSON.

The discussion in #4608 seems to suggest that the latter is preferred so as not to expand the SSM-specific codebase for a relatively generic function but the fact that there isn't a jsonparse() or similar makes me think there's a reason it hasn't been previously created.

貢獻者指南