Search code examples
amazon-web-servicesaws-lambdazipaws-secrets-manager

AWS Lambda Extension throws exit status 127 (/usr/bin/env: node : No such file or directory)


I am creating a Lambda extension to get secret values from secret manager using as a template: https://github.com/hariohmprasath/aws-lambda-extensions

I have zipped the files into the following structure.

extension.zip
  --> extensions
      --> secret-extension
  --> secret-extension
      --> node_modules
      --> extensions-api.js
      --> index.js
      --> package.json
      --> package-lock.json
      --> secrets.js

Error:

{
  "errorMessage": "RequestId: e5c06575-cf7d-46c0-b168-624e8e9cf572 Error: exit status 127",
  "errorType": "Extension.Crash"
}

The Error is that /usr/bin/env: node : No such file or directory At the top of the index.js file is the command #!/usr/bin/env node (in order to interpret the file in node)

The runtime environment is Nodejs 12 and have tried with 14 as well.(extension documentation says node 12 runtime is required)

What could be causing this issue?

  • The lambda runtime is a node runtime so node should be installed.
  • I have ls the folder and /env folder exists.
  • I know node exists within the runtime as node -v returns v14.20.0 or v12.22.11
  • I am on a windows machine creating the extension (dont think the deployment could be causing this because it was written on windows machine.

Any help would be appreciated.


Solution

  • So found out it has to do with a custom environment they are using for the example provided by AWS. Instead I went the route of using a runtime independent solution which has worked as expected.

    Documentation