From a6e938fe7869154267d9a21161f7cfdbbf09a115 Mon Sep 17 00:00:00 2001 From: hv202x1 <65007683+hv202x1@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:10:27 +0100 Subject: [PATCH] refactor: add validation for repository_name AWS validates repository names only during apply, a Terraform plan can incorrectly appear valid in the plan step. This validation ensures that invalid repository names fail fast and early before any resources are created. --- variables.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/variables.tf b/variables.tf index 4af01e5..c60cb90 100644 --- a/variables.tf +++ b/variables.tf @@ -36,6 +36,14 @@ variable "repository_name" { description = "The name of the repository" type = string default = "" + + validation { + condition = can(regex( + "^(?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*$", + var.repository_name_check + )) + error_message = "Invalid repository_name: must be lowercase and match ^(?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*$" + } } variable "repository_image_tag_mutability" {