base2Services / shelvery-aws-backups

Automating EBS RDS EC2 backups on lambda
MIT License
36 stars 22 forks source link

yaml error while running the code in AWS Lambda #123

Closed Hardik2003 closed 3 years ago

Hardik2003 commented 4 years ago

I'm using the Lambda function in AWS to deploy the shelvery function for cross-region/cross-account backups.

While running the Lambda function to test the same, I get the following error:

START RequestId: 2989c816-0cff-4386-80a8-0fd338fdcefc Version: $LATEST
Unable to import module 'shelvery_lambda/lambda_handler': No module named 'yaml'

Not quite sure what could be missing here.

When I try to install serverless module in the node docker container as mentioned in the documentation, I do see this. It may/may not be related to the issue I'm facing.

root@a0488a85ac4b:/src/shelvery# npm install -g serverless
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/usr/local/bin/serverless -> /usr/local/lib/node_modules/serverless/bin/serverless.js
/usr/local/bin/sls -> /usr/local/lib/node_modules/serverless/bin/serverless.js

> snappy@6.3.5 install /usr/local/lib/node_modules/serverless/node_modules/snappy
> prebuild-install || node-gyp rebuild

prebuild-install WARN install EACCES: permission denied, access '/root/.npm'
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.14.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/serverless/node_modules/snappy/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serverless/node_modules/snappy/.node-gyp'
gyp ERR! System Linux 4.19.76-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/serverless/node_modules/snappy
gyp ERR! node -v v14.14.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 

> protobufjs@6.10.1 postinstall /usr/local/lib/node_modules/serverless/node_modules/protobufjs
> node scripts/postinstall

> serverless@2.8.0 postinstall /usr/local/lib/node_modules/serverless
> node ./scripts/postinstall.js

   ┌───────────────────────────────────────────────────┐
   │                                                   │
   │   Serverless Framework successfully installed!    │
   │                                                   │
   │   To start your first project run 'serverless'.   │
   │                                                   │
   └───────────────────────────────────────────────────┘

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/serverless/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: snappy@6.3.5 (node_modules/serverless/node_modules/snappy):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: snappy@6.3.5 install: `prebuild-install || node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ serverless@2.8.0
Hardik2003 commented 4 years ago

Hi team. Is there any update on this?

Guslington commented 4 years ago

Hi @Hardik2003

I haven't tested the serverless deployment for a while, it's been replaced with AWS SAM. Please try deploying with the sam-cli.

BenjaDiaz commented 4 years ago

@Hardik2003 Seems the current serverless.yml does not install and package dependencies. Try adding the serverless-python-requirementes plugin. You can find documentation here: https://www.serverless.com/plugins/serverless-python-requirements

Hardik2003 commented 4 years ago

Thanks @BenjaDiaz - I ended up using the AWS SAM solution as suggested by @Guslington and it is working perfectly fine.

But I appreciate the solution you have mentioned above. It might help someone facing a similar issue with the serverless platform.