diff --git a/main.tf b/main.tf index bdb8f1c..e764361 100644 --- a/main.tf +++ b/main.tf @@ -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 } \ No newline at end of file diff --git a/modules/terraform-aws-ca-sns/locals.tf b/modules/terraform-aws-ca-sns/locals.tf index c477082..29e2a34 100644 --- a/modules/terraform-aws-ca-sns/locals.tf +++ b/modules/terraform-aws-ca-sns/locals.tf @@ -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" diff --git a/modules/terraform-aws-ca-sns/main.tf b/modules/terraform-aws-ca-sns/main.tf index 340eeef..b6ccf83 100644 --- a/modules/terraform-aws-ca-sns/main.tf +++ b/modules/terraform-aws-ca-sns/main.tf @@ -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, diff --git a/modules/terraform-aws-ca-sns/variables.tf b/modules/terraform-aws-ca-sns/variables.tf index 3368a24..6994859 100644 --- a/modules/terraform-aws-ca-sns/variables.tf +++ b/modules/terraform-aws-ca-sns/variables.tf @@ -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 = "" diff --git a/variables.tf b/variables.tf index b31f68d..6c5eb6e 100644 --- a/variables.tf +++ b/variables.tf @@ -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 = ""