From fb9931a3fa3d472c3dea46134c7d39cb2d372a05 Mon Sep 17 00:00:00 2001 From: Chris Stotler Date: Wed, 27 Nov 2024 08:48:33 -0500 Subject: [PATCH 1/3] Adds variable validation --- variables.tf | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/variables.tf b/variables.tf index c490bfe..41b6071 100644 --- a/variables.tf +++ b/variables.tf @@ -19,4 +19,38 @@ variable "account_alternate_contacts" { phone_number = string })) }) + validation { + condition = alltrue([ + for type in var.account_alternate_contacts : + length(type.name) >= 1 && + length(type.name) <= 64 + ]) + error_message = "Invalid value for Name (must be between 1 and 64 characters)" + } + validation { + condition = alltrue([ + for type in var.account_alternate_contacts : + length(type.title) >= 1 && + length(type.title) <= 50 + ]) + error_message = "Invalid value for Title (must be between 1 and 50 characters)" + } + validation { + condition = alltrue([ + for type in var.account_alternate_contacts : + length(type.email_address) >= 1 && + length(type.email_address) <= 50 && + can(regex("^[\\s]*[\\w+=.#|!&-]+@[\\w.-]+\\.[\\w]+[\\s]*$", type.email_address)) + ]) + error_message = "Invalid value for email address (must be between 1 and 50 characters and correct syntax)" + } + validation { + condition = alltrue([ + for type in var.account_alternate_contacts : + length(type.phone_number) >= 1 && + length(type.phone_number) <= 5 && + can(regex("^[\\s0-9()+-]+$", type.phone_number)) + ]) + error_message = "Invalid value for phone number (must be between 1 and 50 characters and correct syntax)" + } } From 5cce8857cbe2121c55ab5ca6f128630fb5893d11 Mon Sep 17 00:00:00 2001 From: Chris Stotler Date: Wed, 27 Nov 2024 09:38:50 -0500 Subject: [PATCH 2/3] Fix typo in phone number length --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 41b6071..8967b17 100644 --- a/variables.tf +++ b/variables.tf @@ -48,7 +48,7 @@ variable "account_alternate_contacts" { condition = alltrue([ for type in var.account_alternate_contacts : length(type.phone_number) >= 1 && - length(type.phone_number) <= 5 && + length(type.phone_number) <= 50 && can(regex("^[\\s0-9()+-]+$", type.phone_number)) ]) error_message = "Invalid value for phone number (must be between 1 and 50 characters and correct syntax)" From f8788ff41e6334947ff259fde62d303f63940f28 Mon Sep 17 00:00:00 2001 From: Chris Stotler Date: Wed, 27 Nov 2024 10:59:06 -0500 Subject: [PATCH 3/3] Update variable lengths --- .bumpversion.cfg | 2 +- CHANGELOG.md | 8 ++++++++ variables.tf | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fab32b7..09fd8af 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.0.0 +current_version = 1.0.1 commit = True message = Bumps version to {new_version} tag = False diff --git a/CHANGELOG.md b/CHANGELOG.md index 6723aaf..7b335fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +### [1.0.1] (https://github.com/plus3it/terraform-aws-tardigrade-account-alternate-contacts/releases/tag/1.0.1) + +**Released**: 2024.11.27 + +**Summary**: + +* Adds variable validation + ### [1.0.0] (https://github.com/plus3it/terraform-aws-tardigrade-account-alternate-contacts/releases/tag/1.0.0) **Released**: 2023.02.09 diff --git a/variables.tf b/variables.tf index 8967b17..915c5bc 100644 --- a/variables.tf +++ b/variables.tf @@ -39,7 +39,7 @@ variable "account_alternate_contacts" { condition = alltrue([ for type in var.account_alternate_contacts : length(type.email_address) >= 1 && - length(type.email_address) <= 50 && + length(type.email_address) <= 254 && can(regex("^[\\s]*[\\w+=.#|!&-]+@[\\w.-]+\\.[\\w]+[\\s]*$", type.email_address)) ]) error_message = "Invalid value for email address (must be between 1 and 50 characters and correct syntax)" @@ -48,7 +48,7 @@ variable "account_alternate_contacts" { condition = alltrue([ for type in var.account_alternate_contacts : length(type.phone_number) >= 1 && - length(type.phone_number) <= 50 && + length(type.phone_number) <= 25 && can(regex("^[\\s0-9()+-]+$", type.phone_number)) ]) error_message = "Invalid value for phone number (must be between 1 and 50 characters and correct syntax)"