# Parsing of ssm JSON values does not work + docs out of date?

**URL:** <https://forum.serverless.com/t/parsing-of-ssm-json-values-does-not-work-docs-out-of-date/15265>\
**Category:** Serverless Framework\
**Tags:** variables\
**Created:** [June 8, 2021, 3:49pm UTC](https://forum.serverless.com/t/parsing-of-ssm-json-values-does-not-work-docs-out-of-date/15265 "2021-06-08T15:49:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![codan84](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/codan84/32/5837_2.png) [@codan84](https://forum.serverless.com/u/codan84)\
**Post date:** [June 8, 2021, 3:49pm UTC](https://forum.serverless.com/t/parsing-of-ssm-json-values-does-not-work-docs-out-of-date/15265/1 "2021-06-08T15:49:43Z")

</div>

I am trying to pull a value from SSM that is a stringified JSON and assign it to a resource policy of API gateway.  
According to docs ([https://www.serverless.com/framework/docs/providers/aws/guide/variables#resolution-of-non-plain-string-types](https://www.serverless.com/framework/docs/providers/aws/guide/variables#resolution-of-non-plain-string-types)) SecureString params are automatically parsed if they contain JSON. so I have tried this:

```auto
provider:
  resourcePolicy: ${ssm:/my/resource/policy}

```

This did not even get decrypted (according to docs above this should work tho). then I found somewhere on a forum that I need to pass `~true` to decrypt (so here - docs out of date):

```auto
provider:
  resourcePolicy: ${ssm:/my/resource/policy~true}

```

This decrypts, but the policy statement is stringified json:

```auto
"Policy": {
          "Version": "2012-10-17",
          "Statement": [
            " [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"execute-api:Invoke\",\n \"Resource\": \"arn:aws:execute-api:eu-west-1:111111111:*\",\n \"Principal\": \"*\",\n \"Condition\": {\n \"StringEquals\": {\n \"aws:SourceVpce\": [\n \"vpc-1111111\"\n]"
          ]
        }

```

So here, this clearly does not work, right?  
I am confident that my ssm param is correct. To test it I created a JS file to fetch/parse it and then imported the parsed value in serverless config:

```auto
const AWS = require('aws-sdk')
const SSM = require('aws-sdk/clients/ssm')

// https://www.serverless.com/framework/docs/providers/aws/guide/variables/#reference-variables-in-javascript-files
module.exports = async ({ options, resolveConfigurationProperty }) => {
  // So that we can run it locally too!
  if (options['aws-profile']) {
    AWS.config.credentials = new AWS.SharedIniFileCredentials({
      profile: options['aws-profile'],
    })
  }

  const region = await resolveConfigurationProperty(['provider', 'region'])
  const ssm = new SSM({ region })

  const policy = await ssm
    .getParameter({
      Name: '/my/resource/policy',
      WithDecryption: true,
    })
    .promise()

  return JSON.parse(policy.Parameter.Value)
}

```

And then in Serverless.yml:

```auto
provider:
  resourcePolicy: ${file(./serverless-get-policy.js)}

```

Again, this works lovely, proving that value in SSM is a correct stringified JSON.  
Am I missing something? Docs are clearly out of date…

---

<div class="post-metadata">

**Author:** ![thomykut](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/thomykut/32/7509_2.png) [@thomykut](https://forum.serverless.com/u/thomykut)\
**Post date:** [June 6, 2023, 5:50pm UTC](https://forum.serverless.com/t/parsing-of-ssm-json-values-does-not-work-docs-out-of-date/15265/2 "2023-06-06T17:50:20Z")

</div>

Same problem here. This happened when upgrading from v2 to v3
