Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Middleware] Parameters Secrets lambda extension #1270

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions packages/parameters-secrets-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div align="center">
<h1>SSM Parameters or Secrets Manager secrets Lambda Extension middleware</h1>
<img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/docs/img/middy-logo.svg"/>
<p><strong>parameters-secrets-extension (AWS System Manager Parameter) middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
<p>
<a href="https://www.npmjs.com/package/@middy/parameters-secrets-extension?activeTab=versions">
<img src="https://badge.fury.io/js/%40middy%2Fparameters-secrets-extension.svg" alt="npm version" style="max-width:100%;">
</a>
<a href="https://packagephobia.com/result?p=@middy/parameters-secrets-extension">
<img src="https://packagephobia.com/badge?p=@middy/parameters-secrets-extension" alt="npm install size" style="max-width:100%;">
</a>
<a href="https://github.com/middyjs/middy/actions/workflows/tests.yml">
<img src="https://github.com/middyjs/middy/actions/workflows/tests.yml/badge.svg?branch=main&event=push" alt="GitHub Actions CI status badge" style="max-width:100%;">
</a>
<br/>
<a href="https://standardjs.com/">
<img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard Code Style" style="max-width:100%;">
</a>
<a href="https://snyk.io/test/github/middyjs/middy">
<img src="https://snyk.io/test/github/middyjs/middy/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/middyjs/middy" style="max-width:100%;">
</a>
<a href="https://github.com/middyjs/middy/actions/workflows/sast.yml">
<img src="https://github.com/middyjs/middy/actions/workflows/sast.yml/badge.svg
?branch=main&event=push" alt="CodeQL" style="max-width:100%;">
</a>
<a href="https://bestpractices.coreinfrastructure.org/projects/5280">
<img src="https://bestpractices.coreinfrastructure.org/projects/5280/badge" alt="Core Infrastructure Initiative (CII) Best Practices" style="max-width:100%;">
</a>
<br/>
<a href="https://gitter.im/middyjs/Lobby">
<img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
</a>
<a href="https://stackoverflow.com/questions/tagged/middy?sort=Newest&uqlId=35052">
<img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;">
</a>
</p>
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/parameters-secrets-extension">https://middy.js.org/docs/middlewares/parameters-secrets-extension</a></p>
</div>

## License

Licensed under [MIT License](LICENSE). Copyright (c) 2017-2025 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).

<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
<img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
</a>
38 changes: 38 additions & 0 deletions packages/parameters-secrets-extension/__benchmarks__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Bench } from 'tinybench'
import middy from '../../core/index.js'
import middleware from '../index.js'

const bench = new Bench({ time: 1_000 })

const context = {
getRemainingTimeInMillis: () => 30000
}
const setupHandler = (options = {}) => {
// TODO fetch mock
const baseHandler = () => {}
return middy(baseHandler).use(
middleware({
...options
})
)
}

const coldHandler = setupHandler({ cacheExpiry: 0 })
const warmHandler = setupHandler()

const event = {}
await bench
.add('without cache', async () => {
try {
await coldHandler(event, context)
} catch (e) {}
})
.add('with cache', async () => {
try {
await warmHandler(event, context)
} catch (e) {}
})

.run()

console.table(bench.table())
25 changes: 25 additions & 0 deletions packages/parameters-secrets-extension/__tests__/fuzz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test } from 'node:test'
import fc from 'fast-check'
import middy from '../../core/index.js'
import middleware from '../index.js'

const handler = middy((event) => event).use(
middleware({ type: 'systemsmanager' })
)
const context = {
getRemainingTimeInMillis: () => 1000
}

test('fuzz `event` w/ `object`', async () => {
fc.assert(
fc.asyncProperty(fc.object(), async (event) => {
await handler(event, context)
}),
{
numRuns: 100_000,
verbose: 2,

examples: []
}
)
})
Loading
Loading