Skip to content

Shared SSM parameters don't seem to be working #1529

@iiroj

Description

@iiroj

Describe the bug

SSM parameters shared between AWS accounts don't seem to be working in with the Middy.js ssm middleware. See more info about the feature here: https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-shared-parameters.html

Since the shared parameter needs to be fetched with the Name being the full ARN of the parameter like arn:aws:ssm:us-east-1:000000000000:parameter/foo, the fetched value seems to be lost somewhere inside the Middy.js cache, given that the Name returned in the SSM response is only the path /foo (in the other AWS account). Thus, I believe the issue is somewhere here:

middy/packages/ssm/index.js

Lines 105 to 109 in e657041

for (const internalKey of batchInternalKeys) {
values[internalKey] = batchReq.then((params) => {
return params[options.fetchData[internalKey]];
});
}

where options.fetchData[internalKey]] refers to the full ARN arn:aws:ssm:us-east-1:000000000000:parameter/foo, but in params the value exists only with the parm path /foo.

...(resp.Parameters ?? []).map((param) => {
return { [param.Name]: parseValue(param) };
}),

To Reproduce

Use the ssm middleware to get a shared parameter from another aws account:

ssm({
  fetchData: {
    foo: 'arn:aws:ssm:us-east-1:000000000000:parameter/foo'
  },
  setToContext: true
})

And try to access context.foo, which will be undefined.

Expected behaviour
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Node.js: 22.x (Lambda runtime
  • Middy: tested with 5.5.1 and 6.4.5
  • AWS SDK tested with 3.799.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions