-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add support for SQS #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
f35139b
73ed2e8
0cbd6c5
ac6afb2
858646d
c123c3f
9ee4dd6
884bc6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| locals { | ||
| # This helps avoid queue names ending in "-" or "-.fifo" | ||
| given_queue_name = var.queue_name == "" ? "" : "-${var.queue_name}" | ||
| # All fifo queues must end in .fifo, per AWS rules | ||
| queue_suffix = var.is_fifo == true ? ".fifo" : "" | ||
| full_queue_name = "${var.stack}-${var.env}${local.given_queue_name}${local.queue_suffix}" | ||
| } | ||
|
|
||
| resource "aws_sqs_queue" "this" { | ||
| name = local.full_queue_name | ||
| fifo_queue = var.is_fifo | ||
| content_based_deduplication = var.content_based_deduplication | ||
|
||
| receive_wait_time_seconds = var.receive_wait_time_seconds | ||
| visibility_timeout_seconds = var.visibility_timeout_seconds | ||
| } | ||
|
|
||
| resource "aws_sqs_queue_policy" "this" { | ||
|
||
| queue_url = aws_sqs_queue.this.id | ||
|
|
||
| policy = jsonencode( | ||
| { | ||
| Version : "2008-10-17" | ||
| Id : "__default_policy_ID" | ||
|
||
| Statement : [ | ||
| { | ||
| Sid : "__owner_statement" | ||
|
||
| Effect : "Allow" | ||
| Principal : "*" | ||
| Action : "sqs:*" | ||
| Resource : "${aws_sqs_queue.this.arn}" | ||
| } | ||
| ] | ||
| } | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| output "arn" { | ||
| value = aws_sqs_queue.this.arn | ||
| } | ||
|
|
||
| output "full_queue_name" { | ||
|
||
| value = aws_sqs_queue.this.name | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| terraform { | ||
| experiments = [module_variable_optional_attrs] | ||
| } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| variable "stack" { | ||
| description = "The name of the stack" | ||
| type = string | ||
| } | ||
|
|
||
| variable "env" { | ||
| description = "The name of the environment" | ||
| type = string | ||
| } | ||
|
|
||
| variable "queue_name" { | ||
|
||
| description = "The shorthand name of the queue. The full queue name can be retrieved as an output. Note that an empty string is still a valid queue name." | ||
| type = string | ||
| } | ||
|
|
||
| variable "visibility_timeout_seconds" { | ||
| description = "The amount of time allowed to the processor to process a message before it is declared failed. Defaults to 30 seconds." | ||
| type = number | ||
| default = 30 | ||
| } | ||
|
|
||
| variable "receive_wait_time_seconds" { | ||
| description = "The time to wait when polling for new messages. Use 0 for immediate response. Longer values are preferred. AWS recommends a maximum of 20 seconds." | ||
| type = number | ||
| default = 5 | ||
|
||
| } | ||
|
|
||
| variable "is_fifo" { | ||
| description = "Specifies if this queue should be a FIFO queue, which would preserve message ordering. Defaults to true." | ||
| type = bool | ||
| default = true | ||
| } | ||
|
|
||
| variable "content_based_deduplication" { | ||
| description = "Specifies if this queue should use content-based deduplication. Must be false if using a standard (non-fifo) queue. Defaults to true" | ||
| type = bool | ||
| default = true | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| terraform { | ||
| required_version = ">= 1.0" | ||
|
|
||
| required_providers { | ||
| aws = { | ||
| source = "hashicorp/aws" | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var.is_fifo ? ".fifo" : ""There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we have the
== is truein a couple of other places, I think? I thought I just needed it. I'll fix that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you find any others, feel free to lump in a cleanup of 'em 😁