Skip to content

Commit

Permalink
SNS display name
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschwarzenberger committed Aug 11, 2024
1 parent 41ac08e commit 59d0ae0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
17 changes: 9 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,13 @@ module "db-reader-role" {
module "sns-ca-notifications" {
source = "./modules/terraform-aws-ca-sns"

project = var.project
function = "ca-notifications"
env = var.env
custom_sns_topic_name = var.custom_sns_topic_name
kms_key_arn = coalesce(var.kms_arn_resource, module.kms_tls_keygen.kms_arn)
email_subscriptions = var.sns_email_subscriptions
lambda_subscriptions = var.sns_lambda_subscriptions
sqs_subscriptions = var.sns_sqs_subscriptions
project = var.project
function = "ca-notifications"
env = var.env
custom_sns_topic_display_name = var.custom_sns_topic_display_name
custom_sns_topic_name = var.custom_sns_topic_name
kms_key_arn = coalesce(var.kms_arn_resource, module.kms_tls_keygen.kms_arn)
email_subscriptions = var.sns_email_subscriptions
lambda_subscriptions = var.sns_lambda_subscriptions
sqs_subscriptions = var.sns_sqs_subscriptions
}
3 changes: 2 additions & 1 deletion modules/terraform-aws-ca-sns/locals.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
locals {
sns_topic_name = coalesce(var.custom_sns_topic_name, "${var.project}-${var.function}-${var.env}")
sns_topic_display_name = coalesce(var.custom_sns_topic_name, title(replace("${var.project}-${var.function}-${var.env}", "-", " ")))
sns_topic_name = coalesce(var.custom_sns_topic_name, "${var.project}-${var.function}-${var.env}")

tags = merge(var.tags, {
Terraform = "true"
Expand Down
5 changes: 3 additions & 2 deletions modules/terraform-aws-ca-sns/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
resource "aws_sns_topic" "sns_topic" {
name = local.sns_topic_name
policy = coalesce(var.sns_policy, templatefile("${path.module}/templates/${var.sns_policy_template}.json", { region = data.aws_region.current.id, account_id = data.aws_caller_identity.current.account_id, sns_topic_name = local.sns_topic_name }))
name = local.sns_topic_name
display_name = local.sns_topic_display_name
policy = coalesce(var.sns_policy, templatefile("${path.module}/templates/${var.sns_policy_template}.json", { region = data.aws_region.current.id, account_id = data.aws_caller_identity.current.account_id, sns_topic_name = local.sns_topic_name }))

tags = merge(
var.tags,
Expand Down
6 changes: 6 additions & 0 deletions modules/terraform-aws-ca-sns/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "env" {
default = ""
}

variable "custom_sns_topic_display_name" {
description = "Customised SNS topic display name, leave empty to use standard naming convention"
default = ""
}


variable "custom_sns_topic_name" {
description = "Customised SNS topic name, leave empty to use standard naming convention"
default = ""
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ variable "csr_files" {
default = []
}

variable "custom_sns_topic_display_name" {
description = "Customised SNS topic display name, leave empty to use standard naming convention"
default = ""
}

variable "custom_sns_topic_name" {
description = "Customised SNS topic name, leave empty to use standard naming convention"
default = ""
Expand Down

0 comments on commit 59d0ae0

Please sign in to comment.