Accessing SSM variables

Hi,

I’m storing a JSON payload in AWS Secrets Manager. In serverles.yml I define a variable:

custom:
config: ${ssm:/project/app/config~true}

There is no error. Then the json config looks like this:
{
“lambda_role” : “arn:…”
}

How do I access a JSON value? This is not working:

role: ${self:custom.config.lambda_role}

Thanks!

You need to modify the role associates to the Lambda function, take a look at iamRoleStatements configuration. If you wanted to modify JSON (or .yaml) file, you can implement your own plugin.

If you are working with SSM, I suggest you take a look at the middy ssm middleware. The purpose of that middleware is it will retrieve the param value as runtime, cache it for next execution.