Invocation Methods and Integrations

Dashbird continuously monitors and analyses your serverless applications to ensure reliability, cost and performance optimisation and alignment with the Well Architected Framework.

Product Features Start Free Trial

Invocation Methods

Developers can invoke an AWS Lambda function through an HTTP API1. AWS also provides SDKs2 that wrap Lambda API endpoints and make it easier to interact with functions.

Synchronous

When a Lambda function is invoked synchronously, it will keep the connection open until the execution is finished. Once it’s done, it returns the response provided by the function’s code (or an error, if that’s the case).

This is the default invocation type for all Lambda functions. Although not necessary, to explicitly invoke a function synchronously, the API consumer provides the InvocationType parameter as RequestResponse.

Asynchronous

When you invoke a function asynchronously, Lambda sends the event to a queue. A separate process reads events from the queue and runs your function. When the event is successfully added to the queue, Lambda returns a success message to the client3.

To invoke a function asynchronously, the API client must explicitly specify the InvocationType parameter as Event.

Dry Run

This invocation type will validate the parameter values and verify whether the API client has appropriate permission to invoke the function. It will not actually execute the function code, only carry out a verification and validation process.

Simply specify DryRun as the InvocationType parameter to invoke a function in this mode.

Integrations

Below is a list of services that integrate with Lambda. They invoke a given function either synchronous or asynchronously, depending on the service.

S3 (Simple Storage Service)

S3 is a scalable and highly durable storage service by AWS. It an hold from image and video to text and columnar data files.

The main operations in S3 are PUT (save or update an object), GET (retrieve an object), DELETE (remove an object). It can automatically send asynchronous event messages to AWS Lambda whenever an object is stored or deleted, for example4.

Lambda receives an S3 event, which contains basic information about the object. It can then perform whatever task is needed in response to the operation executed against this object.

DynamoDB

DynamoDB is a distributed, highly scalable NoSQL database by AWS. By enabling DynamoDB Streams, write operations (insert, update, delete) against a DynamoDB table will be stored in a stream of events. These events can be read by a Lambda function asynchronously to perform any kind of job in response to the database changes5.

To learn more about DynamoDB Streams, please read our page about Operations and Data Access patterns.

SQS (Simple Queue Service)

SQS is a queue buffer service by AWS. Lambda can poll the queue of events and invoke a given function synchronously6. Messages are read in batches from the queue to improve performance and reduce costs. When the function successfully processes the queue messages, Lambda deletes them from the queue.

API Gateway

Lambda can be used as the backend processing platform to answer REST API requests received by an API Gateway7. Each request method (GET, PUT, POST) can be matched to a different Lambda function or a single function can serve all requests from an endpoint (or a group of endpoints).

API Gateway will invoke Lambda synchronously. Beware that, even though Lambda timeout limit is 15 minutes, API Gateway is limited to 29 seconds8.

Load Balancer

Similarly to the API Gateway integration, Lambda can also serve HTTP requests received by an Application Load Balancer (ALB)9. Also as API Gateway, the ALB will invoke the Lambda function synchronously.

ALB does not have a hard timeout limit. Processing time is limited to the Lambda timeout of 15 minutes.

SES (Simple Email Service)

SES is an email sending and receiving service by AWS. When configured to receive messages, it can invoke a Lambda function passing the email received as a parameter10. SES can invoke in both synchronous and asynchronous modes, depending on how the integration is intended to work. Please refer to the AWS documentation for more details11.

CloudFront / Lambda@Edge

CloudFront is a content delivery network (CDN) service by AWS. It serves static content in a performant way distributing and replicating content across hundreds of points-of-interest that are geographically closer to application users.

Lambda@Edge is an integration between CloudFront and Lambda that allows to customize content delivered through the CDN12. This can be used to inspect cookies and customize content returned by CloudFront, or to manipulate headers in the CloudFront HTTP responses, for example.

Kinesis Firehose (Stream Processing)

Amazon Kinesis Data Firehose can automatically transform data received through streams. By integrating with AWS Lambda, it’s possible to implement custom transformation processes13.

Other Integrations


Footnotes


  1. Lambda API Reference ↩︎
  2. AWS SDKs and Programming Toolkits ↩︎
  3. Asynchronous Invocation ↩︎
  4. Using AWS Lambda with Amazon S3 ↩︎
  5. Using AWS Lambda with Amazon DynamoDB ↩︎
  6. Using AWS Lambda with Amazon SQS ↩︎
  7. Using AWS Lambda with Amazon API Gateway ↩︎
  8. API Gateway Integration timeout ↩︎
  9. Using AWS Lambda with an Application Load Balancer ↩︎
  10. Using AWS Lambda with Amazon SES ↩︎
  11. SES Receiving Email Lambda Action ↩︎
  12. Using AWS Lambda with CloudFront Lambda@Edge ↩︎
  13. Using AWS Lambda with Amazon Kinesis Data Firehose ↩︎

No results found