From a739b0556f60b9020f425e0191c8001e817102e2 Mon Sep 17 00:00:00 2001
From: Riccardo Locci <>
Date: Wed, 27 Nov 2024 10:25:17 +0100
Subject: [PATCH 1/2] Added 'email_subject', 'email_message' and 'sms_message'
support for 'verification_message_template'
---
main.tf | 14 ++++++++++++--
variables.tf | 18 ++++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/main.tf b/main.tf
index 29a2ae9..e364ab0 100644
--- a/main.tf
+++ b/main.tf
@@ -4,8 +4,8 @@ resource "aws_cognito_user_pool" "pool" {
alias_attributes = var.alias_attributes
auto_verified_attributes = var.auto_verified_attributes
name = var.user_pool_name
- email_verification_subject = var.email_verification_subject == "" || var.email_verification_subject == null ? var.admin_create_user_config_email_subject : var.email_verification_subject
- email_verification_message = var.email_verification_message == "" || var.email_verification_message == null ? var.admin_create_user_config_email_message : var.email_verification_message
+ email_verification_subject = local.verification_email_subject
+ email_verification_message = local.verification_email_message
mfa_configuration = var.mfa_configuration
sms_authentication_message = var.sms_authentication_message
sms_verification_message = var.sms_verification_message
@@ -336,12 +336,22 @@ locals {
# If no verification_message_template is provided, build a verification_message_template using the default values
verification_message_template_default = {
default_email_option = lookup(var.verification_message_template, "default_email_option", null) == null ? var.verification_message_template_default_email_option : lookup(var.verification_message_template, "default_email_option")
+ email_message = lookup(var.verification_message_template, "email_message", null) == null ? var.verification_message_template_email_message : lookup(var.verification_message_template, "email_message")
email_message_by_link = lookup(var.verification_message_template, "email_message_by_link", null) == null ? var.verification_message_template_email_message_by_link : lookup(var.verification_message_template, "email_message_by_link")
+ email_subject = lookup(var.verification_message_template, "email_subject", null) == null ? var.verification_message_template_email_subject : lookup(var.verification_message_template, "email_subject")
email_subject_by_link = lookup(var.verification_message_template, "email_subject_by_link", null) == null ? var.verification_message_template_email_subject_by_link : lookup(var.verification_message_template, "email_subject_by_link")
+ sms_message = lookup(var.verification_message_template, "sms_message", null) == null ? var.verification_message_template_sms_message : lookup(var.verification_message_template, "sms_message")
}
verification_message_template = [local.verification_message_template_default]
+ verification_email_subject = local.verification_message_template_default.email_subject == "" || local.verification_message_template_default.email_subject == null ? (
+ var.email_verification_subject == "" || var.email_verification_subject == null ? var.admin_create_user_config_email_subject : var.email_verification_subject
+ ) : null
+ verification_email_message = local.verification_message_template_default.email_message == "" || local.verification_message_template_default.email_message == null ? (
+ var.email_verification_message == "" || var.email_verification_message == null ? var.admin_create_user_config_email_message : var.email_verification_message
+ ) : null
+
# software_token_mfa_configuration
# If no software_token_mfa_configuration is provided, build a software_token_mfa_configuration using the default values
software_token_mfa_configuration_default = {
diff --git a/variables.tf b/variables.tf
index eeb0eff..c1695a1 100644
--- a/variables.tf
+++ b/variables.tf
@@ -399,18 +399,36 @@ variable "verification_message_template_default_email_option" {
default = null
}
+variable "verification_message_template_email_message" {
+ description = "Email message template. Must contain the {####} placeholder. Conflicts with email_verification_message argument."
+ type = string
+ default = null
+}
+
variable "verification_message_template_email_message_by_link" {
description = "The email message template for sending a confirmation link to the user, it must contain the `{##Click Here##}` placeholder"
type = string
default = null
}
+variable "verification_message_template_email_subject" {
+ description = "Subject line for the email message template. Conflicts with email_verification_subject argument."
+ type = string
+ default = null
+}
+
variable "verification_message_template_email_subject_by_link" {
description = "The subject line for the email message template for sending a confirmation link to the user"
type = string
default = null
}
+variable "verification_message_template_sms_message" {
+ description = "SMS message template. Must contain the {####} placeholder. Conflicts with sms_verification_message argument."
+ type = string
+ default = null
+}
+
#
# aws_cognito_user_pool_domain
#
From a6da6101c5af48a82e442debb7cf170e8045b403 Mon Sep 17 00:00:00 2001
From: Riccardo Locci <>
Date: Wed, 27 Nov 2024 10:42:04 +0100
Subject: [PATCH 2/2] Added 'email_subject', 'email_message' and 'sms_message'
support for 'verification_message_template'
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index 87efe0e..4755f71 100644
--- a/README.md
+++ b/README.md
@@ -270,8 +270,11 @@ No modules.
| [username\_configuration](#input\_username\_configuration) | The Username Configuration. Setting `case_sensitive` specifies whether username case sensitivity will be applied for all users in the user pool through Cognito APIs | `map(any)` | `{}` | no |
| [verification\_message\_template](#input\_verification\_message\_template) | The verification message templates configuration | `map(any)` | `{}` | no |
| [verification\_message\_template\_default\_email\_option](#input\_verification\_message\_template\_default\_email\_option) | The default email option. Must be either `CONFIRM_WITH_CODE` or `CONFIRM_WITH_LINK`. Defaults to `CONFIRM_WITH_CODE` | `string` | `null` | no |
+| [verification\_message\_template\_email\_message](#input\_verification\_message\_template\_email\_message) | Email message template. Must contain the {####} placeholder. Conflicts with email\_verification\_message argument. | `string` | `null` | no |
| [verification\_message\_template\_email\_message\_by\_link](#input\_verification\_message\_template\_email\_message\_by\_link) | The email message template for sending a confirmation link to the user, it must contain the `{##Click Here##}` placeholder | `string` | `null` | no |
+| [verification\_message\_template\_email\_subject](#input\_verification\_message\_template\_email\_subject) | Subject line for the email message template. Conflicts with email\_verification\_subject argument. | `string` | `null` | no |
| [verification\_message\_template\_email\_subject\_by\_link](#input\_verification\_message\_template\_email\_subject\_by\_link) | The subject line for the email message template for sending a confirmation link to the user | `string` | `null` | no |
+| [verification\_message\_template\_sms\_message](#input\_verification\_message\_template\_sms\_message) | SMS message template. Must contain the {####} placeholder. Conflicts with sms\_verification\_message argument. | `string` | `null` | no |
## Outputs