serverless/serverless

Optionally Parse SSM String Parameters as JSON

Open

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

在 GitHub 查看
 (8 留言) (2 反應) (0 負責人)JavaScript (46,915 star) (5,734 fork)batch import
cat/variablehelp wanted

描述

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.

貢獻者指南