SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
249 stars 73 forks source link

AWS Lambda support #121

Open deathquin opened 4 years ago

deathquin commented 4 years ago

The directory was applied to the environment variable SAPNWRFC_HOME by following the installation instructions, but eventually it does not work. And here's the message. In lambda, I put the file in the folder /var/task. "The SAP NW RFC SDK could not be loaded" I wonder if it can't be turned in aws lambda. I'd appreciate it if you could let me know. Thank you

Suncatcher commented 4 years ago

Have you found any solution?

bsrdjan commented 4 years ago

Where the ABAP backend system should be installed, to be reached from AWS Lambda?

manishvyas1911 commented 4 years ago

Hi @bsrdjan please help with the above. Is it possible to setup SDK so that it would be accessible to AWS Lambdas.

bsrdjan commented 4 years ago

Basically you need to:

1) Build the node-rfc from source on a same platform the AWS Lambdas are running on

2) Deploy the node-rfc package, together with SAP NWRFC SDK on AWS Lambdas

The AWS Lambdas run on AMI Linux and you can build the node-rfc from source on AMI Linux based docker container for example. Also check with Linux 2, the AMI Linux successor: https://aws.amazon.com/amazon-linux-2/

After the node-rfc works in Amazon docker, the AWS Lambdas deployment package, containing NWRFC SDK, should be built, following: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-linux-binary-package/

After deployment on AWS Lambda, the node-rfc should connect to some ABAP system from there and for that RFC connection parameters are required. That is why I asked where the ABAP system is running.

ABAP business systems are not exposed in internet and the connection from Cloud to ABAP, requires SAP Cloud Connector (SCC) component installed on premise. The NWRFC SDK is currently not enabled for using SCC channel and the feature request is the same like for the Cloud Foundry: @mkolksdorf#79.

manishvyas1911 commented 4 years ago

hi @bsrdjan Yes the system is connected to SAP Cloud Connector(SCC) and i am able to use it with nodejs application in EC2 instance. as i can configure easily all the requirements like as mentioned in node-rfc document. but i need to do it in lambdas only as it is cost efficient. As guided by you, i used https://hub.docker.com/_/amazonlinux and setup node-rfc environment in it. now problem is how to deploy the node-rfc package, together with SAP NWRFC SDK on AWS Lambdas. please help err

manishvyas1911 commented 4 years ago

The directory was applied to the environment variable SAPNWRFC_HOME by following the installation instructions, but eventually it does not work. And here's the message. In lambda, I put the file in the folder /var/task. "The SAP NW RFC SDK could not be loaded" I wonder if it can't be turned in aws lambda. I'd appreciate it if you could let me know. Thank you

Did u find any solution?

bsrdjan commented 4 years ago

Solving the loading issue would lead to the next problem, I mentioned at the end of my previous comment. The NWRFC SDK is currently not enabled for using SAP Cloud Connector Channel and even if loaded, it can't use the SCC to reach ABAP backend system.

The same feature request can be created, like for the Cloud Foundry: node-rfc/#79.

manishvyas1911 commented 4 years ago

So is it not at all possible. I was able to call sap functions with nodejs app with SDK configured inside EC2 instance. Just need to check if possible with lambdas

manishvyas1911 commented 4 years ago

Hi @bsrdjan , I finally figured out a way to get this done. First of all let me get you through issues.

Issue : Error: /var/task/node_modules/node-rfc/lib/binding/sapnwrfc.node: invalid ELF header

Solved: Created Node modules.

Issue: Error: libsapnwrfc.so: cannot open shared object file: No such file or directory

Solved: Copy nwrfcsdk libraries in lib folder and zip with code.

Issue: Not able to load libraries from lib folder.

Solved: Lambda has LD_LIBRARY_PATH set to /var/task/lib where I was putting the libraries in /var/task/libs

Issue: Error: libuuid.so.1: cannot open shared object file: No such file or directory

Solved:

  1. AWS Lambda uses the amzn2-ami-hvm-2.0.20190313-x86_64-gp2
  2. Linux study gives: lib, lib64 folder may contain system libraries.
  3. get all the files required from amazon linux docker.
  4. paste it inside lib folder.

Steps to get it done.

  1. Create a layer in aws lambda with node-rfc modules.
  2. Create a folder named "lib" and add all nwrfcsdk lib files inside it.
  3. Pull Amazon Linux docker and go to Lib64 folder . basically you need to copy three files in your "lib" folder i.e. libuuid.so.1, libmount.so.1, libblkid.so.1 image
  4. Create a lambda function with lambda credentials i.e index.js and zip it together with "lib" folder.
  5. Upload lambda with aws as
    • aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip
    • directly through console.
  6. In aws lambda set environment variable as LD_LIBRARY_PATH : /var/task/lib

Thats all. All above issues will be resolved and SDK problem is also solved. To see demo : https://www.youtube.com/watch?v=rhY4jVtl0k8&t=39s

bsrdjan commented 3 years ago

The feature request to enable SAP NWRFC SDK usage on AWS Lambda, in Connectivity context, can be created for:

Security Services category of the SAP Cloud Platform – Platform Foundation

bsrdjan commented 3 years ago

You may vote for the new request, linked here: https://github.com/SAP/node-rfc/issues/145#issuecomment-781209573

frumania commented 2 years ago

Thanks to @manishvyas1911 research, this is actually even easier to do.

We have created a simple walkthrough to setup your AWS Lambda Project for Node RFC.

mtolksdorf commented 2 years ago

@frumania: The connection parameters are not visible. How do you connect to the ABAP system? What are the prerequisites so that the system can be reached? In case it needs to be exposed to the internet, using SNC is mandatory and this is not visible in the simple walk-through, neither for node nor for the described alternative using JCo within a Java runtime. Neither node nor Java in a lambda environment can make use of a Cloud Connector setup

frumania commented 2 years ago

Thanks for the reply!

Connectivity: I am simply using the sapnwrfc.ini adjusted to my SAP system running on AWS (private IP), straight forward. Similarly you can connect to an OnPremise system via VPN or DIrect Connect (all private connections) through private IP-Address or DNS. As a prerequisite you deploy the Lambda function inside your own VPC = private connection, hence also the Security Group and Subnet snippet for the AWS SAM template. SAP Cloud Connector is for SAP BTP connectivity only and not applicable/nor useful in this case.

SNC: This can be done as per documentation, just add the applicable libsapcrypto.so to the lib folder and adjust sapnwrfc.ini.

Happy to support, if you have a specifc setup!