With our event connector, you can trigger function invocations from messages on AWS SQS queues. This is useful for processing events from AWS services such as S3, CloudWatch and DynamoDB.
You can configure permissions using a dedicated IAM user, or if your cluster is configured for AWS IAM, ambient credentials mapped into the Pod at runtime.
Set up the connector
You can install the SQS connector using its helm chart.
The values.yaml file can be customised to suit the needs of your SQS queue and the consumer.
Tuning the connector for your needs
queueURL - the URL for your SQS queue - you can specify a comma-separated list of queues to consume from or a single URL of a queue. When you specify multiple queues, the connector will consume from each of them and invoke functions in parallel. The access key and secret key must be the same for all queues given in queueURL.
visibilityTimeout - Maximum time to keep message hidden from other processors whilst executing function.
waitTime - Time to wait between polling SQS queue for messages.
maxMessages - Maximum messages to fetch at once - between 1-10. This limit is part of the AWS SQS service.
asyncInvocation - when set to true, every message will be dequeued and transferred to the built-in queueing system in OpenFaaS. The queue system in OpenFaaS is ideal for long-running functions, or functions that need to be retried if a non-200 status code is returned. This means the SQS connector can move onto the next message without holding up the processing of pending messages.
contentType - By default, the content type header sent to functions by the connector is text/plain. If you need to change this, you can set it to something like such as application/json or application/octet-stream.
Each time a function is invoked by the connector it will receive the message from the queue as the HTTP body.
It'll also receive two HTTP headers:
X-SQS-Message-ID- the ID of the message in the SQS queue for when a function needs to do something with the message
X-SQS-Queue-URL - the URL of the SQS queue - required when a function receives messages from multiple queues
Once the message has been delivered to the function, it will be deleted from the queue.