Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added email_subject, email_message and sms_message support for verification_message_template #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,11 @@ No modules.
| <a name="input_username_configuration"></a> [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 |
| <a name="input_verification_message_template"></a> [verification\_message\_template](#input\_verification\_message\_template) | The verification message templates configuration | `map(any)` | `{}` | no |
| <a name="input_verification_message_template_default_email_option"></a> [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 |
| <a name="input_verification_message_template_email_message"></a> [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 |
| <a name="input_verification_message_template_email_message_by_link"></a> [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 |
| <a name="input_verification_message_template_email_subject"></a> [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 |
| <a name="input_verification_message_template_email_subject_by_link"></a> [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 |
| <a name="input_verification_message_template_sms_message"></a> [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

Expand Down
14 changes: 12 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down