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

Documentation on working with other layers #6

Open
cjlludwig opened this issue Mar 8, 2022 · 3 comments
Open

Documentation on working with other layers #6

cjlludwig opened this issue Mar 8, 2022 · 3 comments

Comments

@cjlludwig
Copy link

While attempting to test this repo I encountered a couple of hiccups. First, I wasn't seeing the node version updated when checking inside my Lambda runtime. After some testing I realized that my runtime in my Lambda template was still set to "nodejs14.x" which was overriding any changes the Lambda made. This setting would be useful to highlight in the readMe.

Second, I'm having issues getting other layers to work when using in conjunction with this repo. For my use case it seems that using a node shebang declaration in my other layer fails. This layer works when using AWS node runtimes so it seems that the layer has changed other parts of the environment outside of node version. This likely just requires some tweaking on my end but it would be helpful to include some documentation on how running an everynode layer differs from the standard AWS node runtime.

#!/usr/bin/env node

/usr/bin/env: node: No such file or directory

Appreciate the work here. Very interesting feature!

@tjanczuk
Copy link
Contributor

tjanczuk commented Mar 9, 2022

@cjlludwig When using the everynode Lambda layers, the standard Node.js runtimes from AWS are not used at all. You will notice that the instructions in the readme use the provided runtime as opposed to nodejs14.x:

aws lambda create-function --function-name hello17 \
  --layers $LAYER \
  --region us-west-1 \
  --zip-file fileb://function.zip \
  --handler function.handler \
  --runtime provided \
  --role {iam-role-arn}

The implication is that the Node.js executable normally provided by the AWS runtime is absent. Instead, the executable of the selected version of Node.js is placed in /opt/node/bin/node by the layer.

One thing you can try to make the composition with other layers work is to provide a PATH environment variable when creating your Lambda function that will include the /opt/node/bin directory -- I have not tested it though.

@jlarmstrongiv
Copy link

I have many scripts starting with #!/usr/bin/env node, so having node in the path by default would be nice

@tjanczuk
Copy link
Contributor

@jlarmstrongiv How are you launching those scripts from your code? The custom runtime bundled in the layer sets the process.env.PATH to include the location of the node executable (https://github.com/fusebit/everynode/blob/main/src/bootstrap#L1-L3). As long as you launch the script in a way that passes process.env as the environment, your shebang should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants