Skip to content
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

feat : Add variable to set sns topic name #66

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ Available targets:
| <a name="input_redrive_policy"></a> [redrive\_policy](#input\_redrive\_policy) | The SNS redrive policy as JSON. This overrides `var.redrive_policy_max_receiver_count` and the `deadLetterTargetArn` (supplied by `var.fifo_queue = true`) passed in by the module. | `string` | `null` | no |
| <a name="input_redrive_policy_max_receiver_count"></a> [redrive\_policy\_max\_receiver\_count](#input\_redrive\_policy\_max\_receiver\_count) | The number of times a message is delivered to the source queue before being moved to the dead-letter queue. When the ReceiveCount for a message exceeds the maxReceiveCount for a queue, Amazon SQS moves the message to the dead-letter-queue. | `number` | `5` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <a name="input_sns_topic_name"></a> [sns\_topic\_name](#input\_sns\_topic\_name) | The name of sns topic | `string` | `"sns-topic-${uuid()}"` | no |
| <a name="input_sns_topic_policy_json"></a> [sns\_topic\_policy\_json](#input\_sns\_topic\_policy\_json) | The fully-formed AWS policy as JSON | `string` | `""` | no |
| <a name="input_sqs_dlq_enabled"></a> [sqs\_dlq\_enabled](#input\_sqs\_dlq\_enabled) | Enable delivery of failed notifications to SQS and monitor messages in queue. | `bool` | `false` | no |
| <a name="input_sqs_dlq_max_message_size"></a> [sqs\_dlq\_max\_message\_size](#input\_sqs\_dlq\_max\_message\_size) | The limit of how many bytes a message can contain before Amazon SQS rejects it. An integer from 1024 bytes (1 KiB) up to 262144 bytes (256 KiB). The default for this attribute is 262144 (256 KiB). | `number` | `262144` | no |
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ locals {

kms_key_id = local.enabled && var.encryption_enabled && var.kms_master_key_id != "" ? var.kms_master_key_id : ""

sns_topic_name = var.fifo_topic ? "${module.this.id}.fifo" : module.this.id
default_sns_topic_name = var.sns_topic_name != "" ? var.sns_topic_name : "sns-topic-${uuid()}"

sns_topic_name = var.fifo_topic ? "${local.default_sns_topic_name}.fifo" : local.default_sns_topic_name
sqs_queue_name = var.fifo_queue_enabled ? "${module.this.id}.fifo" : module.this.id

sqs_dlq_enabled = local.enabled && var.sqs_dlq_enabled
Expand All @@ -15,7 +17,7 @@ resource "aws_sns_topic" "this" {
count = local.enabled ? 1 : 0

name = local.sns_topic_name
display_name = replace(module.this.id, ".", "-") # dots are illegal in display names and for .fifo topics required as part of the name (AWS SNS by design)
display_name = replace(local.sns_topic_name, ".", "-") # dots are illegal in display names and for .fifo topics required as part of the name (AWS SNS by design)
kms_master_key_id = local.kms_key_id
delivery_policy = var.delivery_policy
fifo_topic = var.fifo_topic
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ variable "allowed_iam_arns_for_sns_publish" {
default = []
}

variable "sns_topic_name" {
type = string
description = "The name of sns topic"
default = ""
}

variable "sns_topic_policy_json" {
type = string
description = "The fully-formed AWS policy as JSON"
Expand Down
Loading