Integrating Amazon AWS Lambda with DronaHQ

AWS Lambda is an event-driven, serverless computing platform that runs code in response to events. You can run code without having to manage the server. You can use it to run code of any type of application or backend service.

You would be organizing your code into Lambda functions. You can invoke Lambda functions using the API or run them in response to events from other AWS Services. Integrating AWS Lambda with DronaHQ enables you to transform the results of the function invocation into convenient formats.

Configuring AWS Lambda connector

  • The Amazon Lambda connector is available under Connectors > APIs.

  • Add an Amazon Lambda Account to Authenticate. Here you can add an account by using Connect Amazon AWS Lambda Account.

  • For this you need to first configure the account and then proceed. Once all details are added, click Save.

    Your connector account configuration is now done.

  • If you have already configured your account, you simply need to choose it from the list. In case you want to make any changes to the account configuration you can hover your mouse across the account and you can note the edit and delete options. Click to Edit.

Using AWS Lambda connector

Now let us consider a few scenarios to understand some of the functionalities available with this integration. You can make use of the connector actions by adding the connector from an Action Flow or a Workflow. You can also use the Bind Data to fetch data from the connector.

Now when you want to use the AWS Lambda connector within your Apps, you can go to the UI Builder > Connectors > Connected tab. Here all connectors that have accounts configured or in other words, are connected will be listed out. If you click Manage Account, you can see the list of all available actions for the connector. You would need to add the API / action whenever that you need to use for further actions. Once you have fetched the data using the respective action, you can make use of the Bind Data to fetch data into a control.

Using Connector

Get the list of functions

Let us consider a very simple example to fetch a list of functions from the AWS Lambda account and use it in a dropdown control. Add a Dropdown control and go to Bind data. Click Select Connector where you would get a list of Connectors. Select AWS Lambda and click Continue. You get the list of available actions for the connector.

Select ListFunctions and click Continue. Select the Account to authenticate.

Add the connector name. Now if you want to transform response or add transform keys you can make the necessary changes and updates here and click Finish.

Once the configuration is done you need to select the keys to be used to display data like FunctionName, Version, Description, and so on. Click Save.

Now if you run the form you can get the list of functions from your AWS Lambda.

You can further use the selected item from the Dropdown control and use it to display the details for the selected function from the list.

Get function details

Now add a textarea control and then Bind Data. Add a connector and select the action as GetfunctionDetails . Select the Configured account.

You need to provide the name of the function selected from the Dropdown that we created in the previous example. Select the dropdown control name from the Keywords.

Test the connection and click Finish.

Now, whenever you run the form you can select the function from the dropdown and that is displayed in the text area.

Invoking functions

The AWS Lambda connector enables you to effectively invoke your customized functions. Let us take an example here to invoke the selected function on the click of the action button. You also have the option to the Invocation type as Request Response, Dry Run, or Event.

  • RequestResponse invokes the function synchronously and receives an API response.
  • Event type invokes function asynchronously.
  • DryRun is used to validate parameter values and verify that the user has permission to invoke the function.

In this situation on the button_click event of the action button, you would add the Server-side action > AWS Lambda connector and choose the action InvokeFunction.

  • Select the connected account and click Continue.

  • Use the dropdown control as the Function list from the Use keywords, add the Invocation type (which is / can be optional) and provide the Invocation type using the Dropdown control’s name from the Use keywords. Click Continue.

  • Add the action name and provide the variable that returns the response code for the action completed. If you want you can use this variable to display the URL in a text area control for the sake of understanding.

  • Now, you can see the function invocation and the response status code whenever you run the form.

    preview invoke

Adding function with parameters

Now that we have seen how to use the different functions of AWS Lambda, let’s see how to include parameters in different function calls received by the users from the app.

It is currently available in our self-hosted version of DronaHQ Studio

Adding functions with parameters helps users to pass dynamic values and properties with the function call of the connector.

  • Let’s add an API function of the POST method in the AWS Lambda connector with an endpoint same as invoke function.
    Click on Add API after configuring your AWS Lambda connector.

  • Provide the API path set it to POST method and click on Advance and set the content type to RAW.

  • This will enable you to add variables as input parameters for your AWS Lambda function call which you can use to configure dynamic values and other properties.

  • Next, provide some demo data to your variables and give a name for the function like addition.

  • Do Test API and after successful query execution, click on Save.

Now that you have added your API function, let’s use it in the app.

To use the added API function, go to the action of the button control and add a server-side action of AWS Lambda connector on button_click.
Select the endpoint/function we just added.

Next bind the keywords respective to the controls, to the added variables section.

Click Continue. Now add variable to the output response we are getting from the function call.

Click Finish.
Add another action to set the output from the function call saved in the variable of result, into the Result control.

App preview: