AWS Lambda
Retool offers an in-built integration with AWS Lambda which allows an application to make secure requests to endpoints available to the AWS account used to set up the integration.
In your Retool home page, go to the Resources section and create a new resource.
Type ‘Lambda’ into the search bar and select Lambda under the APIs section
In the configuration page, add a name and description. For the credentials. We need to log into the AWS portal and set up an IAM user to allow Retool access to the lambda.
In the AWS portal, create a new IAM user called ‘retool-lambda-user’.
Add a policy to the account to give permission to list and invoke lambdas.
Note
This policy with ‘*’ resource gives the IAM user access to ALL lambda functions in the account. This can be changed to the lambda ARN to restrict it to the specific lambda you want.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"lambda:ListFunctions",
"lambda:InvokeFunction"
],
"Resource": "*"
}
]
}
Returning to the ‘retool-lambda-user’ page, we need to create an access key and add the access key ID and secret key ID to the Retool Lambda configuration page, as well as setting the region to where the lambda will be located. Click ‘Test Connection’ to verify the integration.
After creating the resource, you can see that it is available on your Retool ‘Production’ environment. Separate resources can be created for different environments, e.g. Staging, but this is beyond the scope of this tutorial.
Returning to our demo application, we can create a new Resource Query and search for the ‘Lambda Demo’ resource that we just created.
After creating the resource query, we can now select from the available lambda functions. One has already been set up but the creation of Lambdas is out of the scope of this tutorial.
Note
The lambda MUST be created on AWS in the same region as the Retool resource or it will not appear in the function options.
The connection can be verified by running the query and observing a 200 status code and seeing the default body ‘Hello from Lambda!’
From here you can proceed with cloud development in AWS and the Retool Database queries we used to create our application can be replaced with calls to AWS Lambda which can perform similar CRUD operations on data in, for example, DynamoDB, RDS, etc.
In the next section, we will look at integrating Retool with BrainCloud, a 3rd Party BAAS platform for gaming.