Skip to content

Commit 6d61934

Browse files
committed
feat: add support for latest downstream cognito-message-sender
- add allow list to by email verifications - use sendgrid an email provider
1 parent 594797d commit 6d61934

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

main.tf

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,15 @@ resource "aws_lambda_function" "email_msg_sender" {
354354

355355
environment {
356356
variables = {
357-
APP_DEBUG_MODE = var.email_sender_debug_mode
358-
APP_LOG_LEVEL = var.service_log_level
359-
APP_KMS_KEY_ID = module.kms_key.key_arn
360-
APP_EMAIL_SENDER_POLICY_PATH = local.email_sender_policy_path
361-
APP_SENDGRID_API_KEY = var.sendgrid_api_key
362-
APP_SENDGRID_EMAIL_VERIFICATION_ENABLED = var.sendgrid_email_verification_enabled
357+
APP_DEBUG_MODE = var.email_sender_debug_mode
358+
APP_LOG_LEVEL = var.service_log_level
359+
APP_KMS_KEY_ID = module.kms_key.key_arn
360+
APP_EMAIL_PROVIDER = var.email_sender_providers[0]
361+
APP_EMAIL_SENDER_POLICY_PATH = local.email_sender_policy_path
362+
APP_SENDGRID_EMAIL_SEND_API_KEY = var.sendgrid_email_send_api_key
363+
APP_SENDGRID_EMAIL_VERIFICATION_API_KEY = coalesce(var.sendgrid_email_verification_api_key, var.sendgrid_api_key)
364+
APP_SENDGRID_EMAIL_VERIFICATION_ALLOWLIST = join(",", var.sendgrid_email_verification_allowlist)
365+
APP_SENDGRID_EMAIL_VERIFICATION_ENABLED = var.sendgrid_email_verification_enabled
363366
}
364367
}
365368

variables.tf

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,46 @@ variable "email_sender_policy_content" {
4646
default = ""
4747
}
4848

49+
variable "email_sender_providers" {
50+
type = list(string)
51+
description = "List of enabled email providers."
52+
default = ["ses"]
53+
54+
validation {
55+
condition = length(var.email_sender_providers)
56+
error_message = "Must define exactly one email provider. Support for more than one coming the future."
57+
}
58+
}
59+
4960
variable "sendgrid_api_key" {
5061
type = string
51-
description = "The SendGrid API key used to interact with its API."
62+
description = "Deprecated: Use sendgrid_email_send_api_key"
5263
default = ""
5364
}
5465

66+
variable "sendgrid_email_send_api_key" {
67+
type = string
68+
description = "The SendGrid API key used to interact with its Mail Send API."
69+
default = ""
70+
}
71+
72+
variable "sendgrid_email_verification_api_key" {
73+
type = string
74+
description = "The SendGrid API key used to interact with its Email Verification API."
75+
default = ""
76+
77+
validation {
78+
condition = !var.sendgrid_email_verification_enabled || (var.sendgrid_email_verification_enabled && length(var.sendgrid_email_verification_api_key) > 0)
79+
error_message = "SendGrid Email Verification is enabled but API Key is not set."
80+
}
81+
}
82+
83+
variable "sendgrid_email_verification_allowlist" {
84+
type = list(string)
85+
description = "List of email domains that bypass email validation."
86+
default = false
87+
}
88+
5589
variable "sendgrid_email_verification_enabled" {
5690
type = bool
5791
description = "Toggle to use email verification."

0 commit comments

Comments
 (0)