@middy/ssm 7.0.0-alpha.2 → 7.0.0
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.
- package/index.js +12 -8
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -43,8 +43,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
43
43
|
const fetchSingleRequest = (request, cachedValues = {}) => {
|
|
44
44
|
const values = {};
|
|
45
45
|
let batchReq = null;
|
|
46
|
-
|
|
47
|
-
let batchFetchKeys = [];
|
|
46
|
+
const batchKeys = new Map();
|
|
48
47
|
const namedKeys = [];
|
|
49
48
|
|
|
50
49
|
const internalKeys = Object.keys(options.fetchData);
|
|
@@ -57,8 +56,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
57
56
|
|
|
58
57
|
for (const [idx, internalKey] of namedKeys.entries()) {
|
|
59
58
|
const fetchKey = options.fetchData[internalKey];
|
|
60
|
-
|
|
61
|
-
batchFetchKeys.push(fetchKey);
|
|
59
|
+
batchKeys.set(internalKey, fetchKey);
|
|
62
60
|
// from the first to the batch size skip, unless it's the last entry
|
|
63
61
|
if (
|
|
64
62
|
(!idx || (idx + 1) % awsRequestLimit !== 0) &&
|
|
@@ -68,7 +66,7 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
const command = new GetParametersCommand({
|
|
71
|
-
Names:
|
|
69
|
+
Names: Array.from(batchKeys.values()),
|
|
72
70
|
WithDecryption: true,
|
|
73
71
|
});
|
|
74
72
|
batchReq = client
|
|
@@ -102,14 +100,20 @@ const ssmMiddleware = (opts = {}) => {
|
|
|
102
100
|
throw e;
|
|
103
101
|
});
|
|
104
102
|
|
|
105
|
-
for (const internalKey of
|
|
103
|
+
for (const [internalKey, fetchKey] of batchKeys.entries()) {
|
|
106
104
|
values[internalKey] = batchReq.then((params) => {
|
|
105
|
+
if (fetchKey.startsWith("arn:aws:ssm:")) {
|
|
106
|
+
const matchingParamName = Object.keys(params).find((key) =>
|
|
107
|
+
fetchKey.endsWith(`:parameter${key}`),
|
|
108
|
+
);
|
|
109
|
+
return params[matchingParamName];
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
return params[options.fetchData[internalKey]];
|
|
108
113
|
});
|
|
109
114
|
}
|
|
110
115
|
|
|
111
|
-
|
|
112
|
-
batchFetchKeys = [];
|
|
116
|
+
batchKeys.clear();
|
|
113
117
|
batchReq = null;
|
|
114
118
|
}
|
|
115
119
|
return values;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/ssm",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "SSM (EC2 Systems Manager) parameters middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"url": "https://github.com/sponsors/willfarrell"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@middy/util": "7.0.0
|
|
67
|
+
"@middy/util": "7.0.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@aws-sdk/client-ssm": "^3.0.0",
|
|
71
|
-
"@middy/core": "7.0.0
|
|
71
|
+
"@middy/core": "7.0.0",
|
|
72
72
|
"@types/aws-lambda": "^8.10.101",
|
|
73
73
|
"aws-xray-sdk": "^3.3.3"
|
|
74
74
|
},
|