Simple Queue Service (SQS)
Queues messages between services so a producer doesn't have to wait for a consumer to process them. SQS decouples services and handles workloads asynchronously, such as processing an uploaded file in the background instead of inside an HTTP request. Failed messages become visible again automatically, so a consumer can retry them or route them to a dead-letter queue.
Byks guides
-
SQS-triggered Lambda Function
A Lambda function that is triggered by incoming messages from an SQS queue.
Terraform configuration
Each entry in the sqs_queues map deploys one SQS queue, with an automatically created dead-letter queue. The map key becomes the queue name.
main.tf
module "application" {
source = "git@github.com:BYM-IKT/terraform-byks-module.git?ref=v12"
# ...
sqs_queues = {
new-visitors = {
# options go here
}
}
}
Options
| Option | Type | Default | Description |
|---|---|---|---|
visibility_timeout_seconds |
number |
30 |
Seconds a received message stays invisible to other consumers before it becomes visible again. From 0 to 43200. |
message_retention_seconds |
number |
1209600 |
Seconds a message stays in the queue before Amazon SQS deletes it. From 60 to 1209600. |
max_receive_count |
number |
1 |
Number of times a message can be received before it moves to the automatically created dead-letter queue. |
is_fifo_queue |
bool |
false |
Create the queue as a FIFO queue. The generated queue name gets a .fifo suffix. |
content_based_deduplication |
bool |
false |
Skip messages with duplicate content sent within five minutes. Only applies when is_fifo_queue is true. |
override_name |
string |
null |
Custom queue name, instead of the generated default. |
schedules |
map(object) |
{} |
Deliver messages to the queue on an EventBridge schedule. See Schedule object. |
Schedule object
Used in schedules. The map key is an arbitrary identifier for the schedule.
| Option | Type | Default | Description |
|---|---|---|---|
expression |
string |
required | EventBridge schedule expression, for example rate(5 minutes) or cron(0 8 * * ? *). |
payload |
string |
required | Message body delivered to the queue on each scheduled invocation. |
description |
string |
null |
Description shown in the EventBridge Scheduler console. |
timezone |
string |
"UTC" |
Timezone the schedule expression is evaluated in. |
flexible_time_window |
string |
"OFF" |
Either OFF or FLEXIBLE. With OFF, the schedule runs at the exact time defined by expression. |
enabled |
bool |
true |
Turn the schedule on or off. |
Resources
-
AWS documentation
Official AWS documentation for SQS