From 7cc244e41c05f5dd47d2e4e1999cb42a6368c1c9 Mon Sep 17 00:00:00 2001 From: Sueeda Oezkaya Date: Thu, 16 Jul 2026 18:56:39 +0200 Subject: [PATCH] bugfix: add plan-time regex validation for telemetry link name and description --- .../services/telemetrylink/link/resource.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stackit/internal/services/telemetrylink/link/resource.go b/stackit/internal/services/telemetrylink/link/resource.go index 5227bca1b..f060330c6 100644 --- a/stackit/internal/services/telemetrylink/link/resource.go +++ b/stackit/internal/services/telemetrylink/link/resource.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "net/http" + "regexp" "strings" "time" @@ -172,10 +173,22 @@ func (r *telemetryLinkResource) Schema(_ context.Context, _ resource.SchemaReque "display_name": schema.StringAttribute{ Description: schemaDescriptions["display_name"], Required: true, + Validators: []validator.String{ + stringvalidator.RegexMatches( + regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9\-\ ]*$`), + "The display name must start with an alphanumeric character and can only contain letters, numbers, spaces, and hyphens.", + ), + }, }, "description": schema.StringAttribute{ Description: schemaDescriptions["description"], Optional: true, + Validators: []validator.String{ + stringvalidator.RegexMatches( + regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9\-\ ]*$`), + "The description must start with an alphanumeric character and can only contain letters, numbers, spaces, and hyphens.", + ), + }, }, "region": schema.StringAttribute{ Description: schemaDescriptions["region"],