Skip to content

Commit

Permalink
feat: Automatically append .fifo to fifo topic names (#55)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfenman authored Jul 5, 2024
1 parent 501f39c commit cfd23c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ data "aws_caller_identity" "current" {}
# Topic
################################################################################

locals {
name = try(trimsuffix(var.name, ".fifo"), "")
}

resource "aws_sns_topic" "this" {
count = var.create ? 1 : 0

name = var.use_name_prefix ? null : var.name
name_prefix = var.use_name_prefix ? var.name : null
name = var.use_name_prefix ? null : (var.fifo_topic ? "${local.name}.fifo" : local.name)
name_prefix = var.use_name_prefix ? "${local.name}-" : null

application_failure_feedback_role_arn = try(var.application_feedback.failure_role_arn, null)
application_success_feedback_role_arn = try(var.application_feedback.success_role_arn, null)
Expand Down

0 comments on commit cfd23c1

Please sign in to comment.