@middy/ssm 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +0 -109
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -36,115 +36,6 @@
36
36
  <p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/ssm">https://middy.js.org/docs/middlewares/ssm</a></p>
37
37
  </div>
38
38
 
39
- This middleware fetches parameters from [AWS Systems Manager Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html).
40
-
41
- Parameters to fetch can be defined by path and by name (not mutually exclusive). See AWS docs [here](https://aws.amazon.com/blogs/mt/organize-parameters-by-hierarchy-tags-or-amazon-cloudwatch-events-with-amazon-ec2-systems-manager-parameter-store/).
42
-
43
- Parameters can be assigned to the function handler's `context` object by setting the `setToContext` flag to `true`. By default all parameters are added with uppercase names.
44
-
45
- The Middleware makes a single API request to fetch all the parameters defined by name, but must make an additional request per specified path. This is because the AWS SDK currently doesn't expose a method to retrieve parameters from multiple paths.
46
-
47
- For each parameter defined by name, you also provide the name under which its value should be added to `context`. For each path, you instead provide a prefix, and by default the value import each parameter returned from that path will be added to `context` with a name equal to what's left of the parameter's full name _after_ the defined path, with the prefix prepended. If the prefix is an empty string, nothing is prepended. You can override this behaviour by providing your own mapping function with the `getParamNameFromPath` config option.
48
-
49
- ## Install
50
-
51
- To install this middleware you can use NPM:
52
-
53
- ```bash
54
- npm install --save @middy/ssm
55
- ```
56
-
57
- ## Options
58
-
59
- - `AwsClient` (object) (default `SSMClient`): SSMClient class constructor (i.e. that has been instrumented with AWS X-Ray). Must be from `@aws-sdk/client-ssm`.
60
- - `awsClientOptions` (object) (default `undefined`): Options to pass to SSMClient class constructor.
61
- - `awsClientAssumeRole` (string) (default `undefined`): Internal key where role tokens are stored. See [@middy/sts](/packages/sts/README.md) on to set this.
62
- - `awsClientCapture` (function) (default `undefined`): Enable AWS X-Ray by passing `captureAWSClient` from `aws-xray-sdk` in.
63
- - `fetchData` (object) (required): Mapping of internal key name to API request parameter `Names`/`Path`. `SecureString` are automatically decrypted.
64
- - `disablePrefetch` (boolean) (default `false`): On cold start requests will trigger early if they can. Setting `awsClientAssumeRole` disables prefetch.
65
- - `cacheKey` (string) (default `ssm`): Cache key for the fetched data responses. Must be unique across all middleware.
66
- - `cacheExpiry` (number) (default `-1`): How long fetch data responses should be cached for. `-1`: cache forever, `0`: never cache, `n`: cache for n ms.
67
- - `setToContext` (boolean) (default `false`): Store role tokens to `request.context`.
68
-
69
- NOTES:
70
-
71
- - Lambda is required to have IAM permission for `ssm:GetParameters` and/or `ssm:GetParametersByPath` depending on what you're requesting.
72
- - `SSM` has [throughput limitations](https://docs.aws.amazon.com/general/latest/gr/ssm.html). Switching to Advanced Parameter type or increasing `maxRetries` and `retryDelayOptions.base` in `awsClientOptions` may be required.
73
-
74
- ## Sample usage
75
-
76
- ```javascript
77
- import middy from '@middy/core'
78
- import ssm from '@middy/ssm'
79
-
80
- const handler = middy((event, context) => {
81
- return {}
82
- })
83
-
84
- let globalDefaults = {}
85
- handler
86
- .use(
87
- ssm({
88
- fetchData: {
89
- accessToken: '/dev/service_name/access_token', // single value
90
- dbParams: '/dev/service_name/database/', // object of values, key for each path
91
- defaults: '/dev/defaults'
92
- },
93
- setToContext: true
94
- })
95
- )
96
- .before((request) => {
97
- globalDefaults = request.context.defaults.global
98
- })
99
- ```
100
-
101
- ```javascript
102
- import middy from '@middy/core'
103
- import { getInternal } from '@middy/util'
104
- import ssm from '@middy/ssm'
105
-
106
- const handler = middy((event, context) => {
107
- return {}
108
- })
109
-
110
- let globalDefaults = {}
111
- handler
112
- .use(
113
- ssm({
114
- fetchData: {
115
- defaults: '/dev/defaults'
116
- },
117
- cacheKey: 'ssm-defaults'
118
- })
119
- )
120
- .use(
121
- ssm({
122
- fetchData: {
123
- accessToken: '/dev/service_name/access_token', // single value
124
- dbParams: '/dev/service_name/database/' // object of values, key for each path
125
- },
126
- cacheExpiry: 15 * 60 * 1000,
127
- cacheKey: 'ssm-secrets'
128
- })
129
- )
130
- // ... other middleware that fetch
131
- .before(async (request) => {
132
- const data = await getInternal(
133
- ['accessToken', 'dbParams', 'defaults'],
134
- request
135
- )
136
- Object.assign(request.context, data)
137
- })
138
- ```
139
-
140
- ## Middy documentation and examples
141
-
142
- For more documentation and examples, refers to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org).
143
-
144
- ## Contributing
145
-
146
- Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
147
-
148
39
  ## License
149
40
 
150
41
  Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/ssm",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "SSM (EC2 Systems Manager) parameters middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -62,14 +62,14 @@
62
62
  },
63
63
  "homepage": "https://middy.js.org",
64
64
  "dependencies": {
65
- "@middy/util": "4.0.0"
65
+ "@middy/util": "4.0.2"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@aws-sdk/client-ssm": "^3.186.0",
69
- "@middy/core": "4.0.0",
69
+ "@middy/core": "4.0.2",
70
70
  "@types/aws-lambda": "^8.10.101",
71
71
  "aws-xray-sdk": "^3.3.3",
72
72
  "type-fest": "^3.0.0"
73
73
  },
74
- "gitHead": "582286144bcd79968a8c7c2f8867a23c80079a47"
74
+ "gitHead": "c77c9413ecb80999a71b67ff97edac1fed2ca754"
75
75
  }