I have a NodeJS (node 20/esm/x86) lambda and in us-east-1 and I loaded the layer for Parameter Store as found here so: arn:aws:lambda:us-east-1:177933569100:layer:AWS-Parameters-and-Secrets-Lambda-Extension:11
I can see in my console it is loaded and also shows in my logs as listening on port 2773.
I then make a call – I have tried Axios and Fetch, adding slashes, not adding them, adding version parameters,not adding it and so on. About 50 different configurations and they all return 400
Error dump:
{
"timestamp": "2024-06-15T01:36:29.993Z",
"level": "INFO",
"message": {
"message": "Request failed with status code 400",
"name": "AxiosError",
"stack": "AxiosError: Request failed with status code 400n at settle (/node_modules/axios/lib/core/settle.js:19:12)n at IncomingMessage.<anonymous> (/node_modules/axios/lib/adapters/http.js:589:11)n at IncomingMessage.emit (node:events:531:35)n at endReadableNT (node:internal/streams/readable:1696:12)n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)n at ke.request (/node_modules/axios/lib/core/Axios.js:45:41)n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)n at ci (/lib/parameterStore.ts:34:22)n at <anonymous> (/handlers/foo/app.ts:14:13)",
"config": {
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
},
"adapter": [
"xhr",
"http"
],
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 5000,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1,
"env": {},
"headers": {
"Accept": "application/json, text/plain, */*",
"x-aws-parameters-secrets-token": "IQoJb3JpZ2luX2VjEBoaCXVzLWVhc3QtMSJIMEYCIQD5BDf/hlbtPXZ0fYZDN+u4ypX07B9GUb59JL0XksUAHQIhALAmK2BH+7vui4pCYDBEFdB9ZjesL6CJccvfYbo+uCw8KqIDCLP//////////wEQARoMMzIxMDc5N9q5rNx7iMtYx/Tg0NDYzIgxDTvZE6KlOiqNs3tMq9gJV9FmuRVlAsWytQTXKwJKsukaYeQ2vNUfMiv9Xlz0Xev3skI8zwtyeP+kY/HBdCJRUUtSPJFjl7cVDd+cbXgL54ZyigMqeCvsHgwyoXGOvw45xXF0pFDW1TTwyGgc6ibU+gRoiraBQkKXIVwzuMcbpcav+Wuuz0Sf4LpVxmBDI5un/a7ntNlakkG1t90UxYdi/T3HgiFk0FYf/9p1PFaZybLXQSKTBy6WejCXTAFIbl/Yl5c/urLJQugcgOLk6IzzYYgMzzmF/QC7+ggcXqlmtUYslRSFNTVD4I5X0MqS831JFawIlk6D9UNysFXNd/subKhDghnQogIifQA0RugtkCoVyshDqCYuB4Hn0Dqh25mxw7kYZzXb8XkRR+hRVF06GHdondlW6yui8Q6+5G2CjH+uWqyhYTknNOL2UyjdyuanrybvKj5caJm8LjEKeCFXc+mGQ2sKdMWIXK4G2BEGe3Oxn1GTFjCd4LOzBjqcAd0WtHZlAuqJF/N/A73TCqVqO/7XYTzOZHlUyRPwXJwJwHrdHs45ERM6nRT9kgQzNWoJusQ8jyv8G3FKWBDfpB29/wmvpQ103xF86jpAa+1nxmdoIy6wvnkUUYzKQjaPjDMFqumjrHMWlku8TXmMnPpnGGNkL/tmsN4epTacRKWFO0LhemlG/rVVWZmFEpP99lpUlDthlTPg8aT1wg==",
"User-Agent": "axios/1.6.8",
"Accept-Encoding": "gzip, compress, deflate, br"
},
"baseURL": "http://localhost:2773",
"method": "get",
"url": "/systemsmanager/parameters/get?name=%2FmytToken&version=1"
},
"code": "ERR_BAD_REQUEST",
"status": 400
}
}
The parameter is myToken
and tried:
- “/systemsmanager/parameters/get?name=%2FmyToken&version=1”
- “/systemsmanager/parameters/get?name=myToken&version=1”
- “/systemsmanager/parameters/get?name=myToken”
- “/systemsmanager/parameters/get/?name=myToken”
the list goes on…
Also played around with header token casing – no diff. 400 seems to want to tell me I am formatting something wrong or missing something but hmm…
any idea?
Posts I read:
- https://dev.to/aws-builders/a-different-way-of-retrieving-secrets-in-lambda-functions-4g7h
- https://medium.com/@ryan.cormack/using-the-parameter-store-lambda-extension-861450fc9bb9