From 594797d0d2decf7b861a1e98329f12b6d4fb1f0e Mon Sep 17 00:00:00 2001 From: Brian Ojeda <9335829+sgtoj@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:25:51 -0400 Subject: [PATCH] feat: add support for v1 of email-sender --- README.md | 28 ++++++++++++++-------------- main.tf | 11 ++++++----- variables.tf | 12 ++++++++++++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index db29135..c7b1d02 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Terraform Module: AWS Cognito Custom Message Sender -:warning: **This module is not ready for use. Wait until v1.x.x release.** - This Terraform module deploys a AWS Lambda function to serve as a custom SMS sender for AWS Cognito. The module uses Open Policy Agent (OPA) policies to determine whether to send an SMS message or not, and can be customized to fit @@ -43,18 +41,20 @@ other optional variables (e.g., `name`, `tags`, etc.) provided by the `cloudposse/label/null` module. Please refer to its [documentation](https://registry.terraform.io/modules/cloudposse/label/null/latest) for more details on these variables. -| Name | Description | Type | Default | Required | -|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:|:---------:|:--------:| -| `kms_key_alias_prefix` | The prefix for the KMS key alias. It must start with 'alias' and only include alphanumeric characters, dashes, underscores, colons or slashes, but doesn't end with a slash. | `string` | `"alias"` | no | -| `service_log_level` | The log level for the service. It must be one of 'debug', 'info', 'warn', 'error', 'panic' or 'fatal'. | `string` | `"info"` | no | -| `email_sender_version` | Version or git ref of the source code | `string` | `"latest"` | no | -| `email_sender_enabled` | Whether or not the eamil sender is enabled. | `bool` | `false` | no | -| `email_sender_policy_content` | The content of the Open Policy Agent policy for email sender. It must include the string 'package cognito_custom_sender_email_policy'. | `string` | n/a | yes | -| `sms_sender_enabled` | Whether or not the SMS sender is enabled. | `bool` | `false` | no | -| `sms_sender_policy_content` | The content of the Open Policy Agent policy for SMS sender. It must include the string 'package cognito_custom_sender_sms_policy'. | `string` | n/a | yes | -| `sms_sender_throttle_period_in_minutes` | The throttle period for the SMS sender, in minutes. It must be a positive integer. | `number` | `15` | no | -| `aws_account_id` | The AWS account ID that the module will be deployed in. | `string` | `""` | no | -| `aws_region_name` | The AWS region name where the module will be deployed. | `string` | `""` | no | +| Name | Description | Type | Default | Required | +|-----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|:--------:|:----------:|:--------:| +| `kms_key_alias_prefix` | The prefix for the KMS key alias. | `string` | `"alias"` | no | +| `service_log_level` | The log level for the service. It must be one of 'debug', 'info', 'warn', 'error', 'panic' or 'fatal'. | `string` | `"info"` | no | +| `email_sender_version` | Version or git ref of the source code | `string` | `"latest"` | no | +| `email_sender_enabled` | Whether or not the eamil sender is enabled. | `bool` | `false` | no | +| `email_sender_policy_content` | The content of the Open Policy Agent policy for email sender. It must include the string 'package cognito_custom_sender_email_policy'. | `string` | n/a | yes | +| `sendgrid_api_key` | The SendGrid API key used to interact with its API. | `string` | `""` | no | +| `sendgrid_email_verification_enabled` | Toggle to use email verification. | `bool` | `false` | no | +| `sms_sender_enabled` | Whether or not the SMS sender is enabled. | `bool` | `false` | no | +| `sms_sender_policy_content` | The content of the Open Policy Agent policy for SMS sender. It must include the string 'package cognito_custom_sender_sms_policy'. | `string` | n/a | yes | +| `sms_sender_throttle_period_in_minutes` | The throttle period for the SMS sender, in minutes. It must be a positive integer. | `number` | `15` | no | +| `aws_account_id` | The AWS account ID that the module will be deployed in. | `string` | `""` | no | +| `aws_region_name` | The AWS region name where the module will be deployed. | `string` | `""` | no | ## Outputs diff --git a/main.tf b/main.tf index 24c4eea..19cf4fd 100755 --- a/main.tf +++ b/main.tf @@ -354,11 +354,12 @@ resource "aws_lambda_function" "email_msg_sender" { environment { variables = { - DEBUG_MODE = var.email_sender_debug_mode - LOG_LEVEL = var.service_log_level - KMS_KEY_ID = module.kms_key.key_arn - EMAIL_SENDER_ENABLED = local.email_sender_enabled - EMAIL_SENDER_POLICY_PATH = local.email_sender_policy_path + APP_DEBUG_MODE = var.email_sender_debug_mode + APP_LOG_LEVEL = var.service_log_level + APP_KMS_KEY_ID = module.kms_key.key_arn + APP_EMAIL_SENDER_POLICY_PATH = local.email_sender_policy_path + APP_SENDGRID_API_KEY = var.sendgrid_api_key + APP_SENDGRID_EMAIL_VERIFICATION_ENABLED = var.sendgrid_email_verification_enabled } } diff --git a/variables.tf b/variables.tf index 2b04d88..e641e0b 100755 --- a/variables.tf +++ b/variables.tf @@ -46,6 +46,18 @@ variable "email_sender_policy_content" { default = "" } +variable "sendgrid_api_key" { + type = string + description = "The SendGrid API key used to interact with its API." + default = "" +} + +variable "sendgrid_email_verification_enabled" { + type = bool + description = "Toggle to use email verification." + default = false +} + # --------------------------------------------------------------- sms-sender --- variable "sms_sender_enabled" {