CatchTheTornado / askql

AskQL is a query language that can express any data request
https://askql.org/
MIT License
387 stars 27 forks source link

Add Lambda/serverless function as the resources #576

Open pkarw opened 3 years ago

pkarw commented 3 years ago

Is your feature request related to a problem? If yes, please describe the problem. It would be great to have an abstract resource like lambda for adding custom resources based on AWS. OK, it's kind of wrapper for fetch but it shows how super easily one can extend and call the AskQL with custom-made data sources

Describe the solution you'd like to see. It could be like lambda helper one can could add as a customResource. I mean something like:

const baseEnvironment = {
  const customResources = [
    'myLambdaCall': awsLambda("myFunctionName", awsOptions) // the first attribute of the returned resource is accepting the lambda payload and it's returning json
  ];
  resources: {...builtInResources, ...customResources },
  // customValues,
};

so then they could use it in the AskQL Script (assuming we already have #575 implemented) like this:

let a =  { exampleObject }
a:myLambdaCall:jsonPath("a:items[0]")
czerwinskilukasz1 commented 3 years ago

I like it, it would greatly enhance Ask's capabilities, while maintaining the security of the Ask server.

You suggested to hard code a specific lambda function (myLambdaCall defined as calling an AWS lambda function myFunctionName). Correct me if I am wrong, but to me it means that: 1) the function would need to be accessible by the running server, meaning that the CODE of server would automatically assume access to AWS through a very specific account where myFunctionName is defined 2) adding other lambda functions, whose one of the main advantages is being ad-hoc functions, would require changes in the source code of the server.

What I suggest instead is to: 1) provide a mechanism to authenticate server owner's AWS account so that Ask programs can call lambda functions from it and 2) provide a mechanism to pass AWS credentials, so that AskScript programs can call user's AWS Lambda functions that were set up with AWS authorization.

pkarw commented 3 years ago

Cool, it leads us to new FR - implementing secrets. Not sure how exactly it should work - I mean it should be somehow pass-only kind of variables (that you can't get thru query, but could pass to the subsequent resource and function -calls)