Skip to content

Commit cfd23c1

Browse files
authored
feat: Automatically append .fifo to fifo topic names (#55)
With this change, we automatically append the .fifo suffix to fifo topic names since it is required by AWS SNS. We also sanitize the name input to ensure that if users have already included the .fifo suffix in their topic names it will not be appended again.
1 parent 501f39c commit cfd23c1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ data "aws_caller_identity" "current" {}
44
# Topic
55
################################################################################
66

7+
locals {
8+
name = try(trimsuffix(var.name, ".fifo"), "")
9+
}
10+
711
resource "aws_sns_topic" "this" {
812
count = var.create ? 1 : 0
913

10-
name = var.use_name_prefix ? null : var.name
11-
name_prefix = var.use_name_prefix ? var.name : null
14+
name = var.use_name_prefix ? null : (var.fifo_topic ? "${local.name}.fifo" : local.name)
15+
name_prefix = var.use_name_prefix ? "${local.name}-" : null
1216

1317
application_failure_feedback_role_arn = try(var.application_feedback.failure_role_arn, null)
1418
application_success_feedback_role_arn = try(var.application_feedback.success_role_arn, null)

0 commit comments

Comments
 (0)