Skip to main content

AWS Lambda

Setup steps

  1. On AWS add Lambda functions
  2. Create AWS credentials
  3. On TakeShape add an AWS Lambda service
  4. Add any query, mutation or @resolver property to your schema which uses the AWS service you created.


Add a sample AWS Lambda function

exports.handler = async (event) => {
return `Hello ${}`;
  • event.args is the object that is set by argsMapping. Any values you want to use in the Lambda add to your argsMapping.
  • The return value of your function can be any JSON-serializable value which must match the type set in the TakeShape schema.

Configure AWS credentials

  1. Log into your AWS account and navigate to IAM Policies.
  2. Select "Create Policy"
  3. Select the "JSON" tab
  4. Paste in the access policy below replacing the "Resource" with the arn of your Lambda function.
"Version": "2012-10-17",
"Statement": [
"Sid": "AllowAuroraToExampleFunction",
"Effect": "Allow",
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:hello-world"
  1. Navigate to IAM Users.
  2. Select "Add users"
  3. On the next screen give the user a name and check the "Programatic access" checkbox.
  4. Select "Next: Permissions"
  5. Select "Attach policies directly" and select the policy created above
  6. Select through "Next: Tags", "Next: Review" and "Create user"
  7. Either copy/paste the "Access key ID" and "Secret access key" to a safe place or download the CSV

On TakeShape

Add an AWS Lambda service

Project → Schema → Connect Service → AWS Lambda

  1. In the "Name" field, choose the name you'd like to give this service. The "Slug" field will be automatically filled in based on the name field.
  2. Under "Authentication" enter the AWS "Access key ID" and "Secret access key".

Add any query, mutation or @resolver property

Project → Schema → JSON

Query example

"helloWord": {
"shape": "string",
"resolver": {
"name": "awsLambda:invoke",
"service": "lambda",
"options": {"functionName": "hello-world"}
"args": {"type": "object", "properties": {"name": {"type": "string"}}}

@resolver property example

"hello": {
"type": "string",
"@resolver": {
"name": "awsLambda:invoke",
"service": "lambda",
"options": {"functionName": "hello-world"},
"argsMapping": {
"name": [["get", {"path": ""}]]

Test the query using the API Explorer

Project → API → API Explorer

Test query
helloWord(name: "Bob")
Test query response
"data": {
"helloWord": "Hello Bob"