diff --git a/.ci/.semgrep-configs.yml b/.ci/.semgrep-configs.yml index 6aa390130900..821176b03bc9 100644 --- a/.ci/.semgrep-configs.yml +++ b/.ci/.semgrep-configs.yml @@ -17,7 +17,7 @@ rules: - metavariable-pattern: metavariable: "$VALUE" patterns: - - pattern-not-regex: "testAcc[a-zA-Z0-9]+Config(_[a-zA-Z0-9_]+_|_)[a-z0-9].*" + - pattern-not-regex: "testAcc[0-9A-Za-z]+Config(_[0-9A-Za-z_]+_|_)[0-9a-z].*" - pattern-not: acctest.ConfigCompose(...) - pattern-not: "..." severity: WARNING @@ -39,7 +39,7 @@ rules: - metavariable-pattern: metavariable: "$VALUE" patterns: - - pattern-not-regex: "testAcc[a-zA-Z0-9]+Config(_[a-zA-Z0-9_]+_|_)[a-z0-9].*" + - pattern-not-regex: "testAcc[0-9A-Za-z]+Config(_[0-9A-Za-z_]+_|_)[0-9a-z].*" - pattern-not-regex: "acctest\\..*" severity: WARNING diff --git a/docs/regular-expressions.md b/docs/regular-expressions.md new file mode 100644 index 000000000000..de1e99d28615 --- /dev/null +++ b/docs/regular-expressions.md @@ -0,0 +1,22 @@ +# Using Regular Expressions + +Regular expressions are a powerful tool. However, they are also very expensive in terms of memory. Ensuring correct and useful functionality is the priority but we have a few tips to minimize impact without affecting capabilities. + +* **Consider non-regular expressions options.** [`strings.Contains()`](https://pkg.go.dev/strings#Contains), [`strings.Replace()`](https://pkg.go.dev/strings#Replace), and [`strings.ReplaceAll()`](https://pkg.go.dev/strings#ReplaceAll) are dramatically faster and less memory intensive than regular expressions. If one of these will work equally well, use the non-regular expression option. +* **Order character classes consistently.** We use regular expression caching to reduce our memory footprint. This is more effective if character classes are consistently ordered. Since a character class is a set, order does not affect functionality. We have many equivalent regular expressions that only differ by character class order. Below is the order we recommend for consistency: + 1. Numeric range, _i.e._, digits (_e.g._, `0-9`) + 2. Uppercase alphabetic range (_e.g._, `A-Z`, `A-F`) + 3. Lowercase alphabetic range (_e.g._, `a-z`, `a-f`) + 4. Underscore (`_`) + 5. Everything else (except dash, `-`) in ASCII order: `\t\n\r !"#$%&()*+,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^abcdefghijklmnopqrstuvwxyz{|}~` + 6. _Last_, dash (`-`) + - Example 1, both equivalent, Wrong order: `[_a-zA-Z0-9-,.]`, Correct: `[0-9A-Za-z_,.-]` + - Example 2, both equivalent, Wrong order: `[;a-z0-9]`, Correct: `[0-9a-z;]` +* **Inside character classes, avoid unnecessary character escaping.** Go does not complain about extra character escaping but avoid it to improve cache performance. Inside a character class, _most_ characters do not need to be escaped, as Go assumes you mean the literal character. + * These characters which normally have special meaning in regular expressions, _inside character classes_ do **not** need to be escaped: `$`, `(`, `)`, `*`, `+`, `.`, `?`, `^`, `{`, `|`, `}`. + * Dash (`-`), when it is last in the character class or otherwise unambiguously not part of a range, does not need to be escaped. If in doubt, place the dash _last_ in the character class (_e.g._, `[a-c-]`) or escape the dash (_e.g._, `\-`). + * Angle brackets (`[`, `]`) always need to be escaped in a character class. + * Example 1, both equivalent, Unnecessary escapes: `[\$\(\.\?\|]`, Correct: `[$(.?|]` + * Example 2, both equivalent, Unnecessary escapes, wrong order: `[a-z\-0-9_A-Z\.]`, Correct: `[0-9A-Za-z_.-]` + + diff --git a/go.mod b/go.mod index a5c81bf4f5d7..2440341314be 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 - github.com/YakDriver/regexache v0.20.0 + github.com/YakDriver/regexache v0.23.0 github.com/aws/aws-sdk-go v1.45.4 github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 diff --git a/go.sum b/go.sum index ea9cee8b4f8b..e5f1cbe735bf 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,8 @@ github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBa github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwCL+mmXnjLWEAOYO+2l2AE4YMmqG1ZpZHBs= github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/YakDriver/regexache v0.20.0 h1:9xfyYbdBnI4DU5ao/5PErxUbzen7yPASzbnjhtCo4uk= -github.com/YakDriver/regexache v0.20.0/go.mod h1:K4BZ3MYKAqSFbYWqmbsG+OzYUDyJjnMEr27DJEsVG3U= +github.com/YakDriver/regexache v0.23.0 h1:kv3j4XKhbx/vqUilSBgizXDUXHvvH1KdYekdmGwz4C4= +github.com/YakDriver/regexache v0.23.0/go.mod h1:K4BZ3MYKAqSFbYWqmbsG+OzYUDyJjnMEr27DJEsVG3U= github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= diff --git a/internal/generate/servicepackage/main.go b/internal/generate/servicepackage/main.go index 3887718f4251..df02714630e1 100644 --- a/internal/generate/servicepackage/main.go +++ b/internal/generate/servicepackage/main.go @@ -149,7 +149,7 @@ var tmpl string // Annotation processing. var ( - annotation = regexache.MustCompile(`^//\s*@([a-zA-Z0-9]+)(\(([^)]*)\))?\s*$`) + annotation = regexache.MustCompile(`^//\s*@([0-9A-Za-z]+)(\(([^)]*)\))?\s*$`) ) type visitor struct { diff --git a/internal/generate/servicesemgrep/configs.tmpl b/internal/generate/servicesemgrep/configs.tmpl index 6aa390130900..821176b03bc9 100644 --- a/internal/generate/servicesemgrep/configs.tmpl +++ b/internal/generate/servicesemgrep/configs.tmpl @@ -17,7 +17,7 @@ rules: - metavariable-pattern: metavariable: "$VALUE" patterns: - - pattern-not-regex: "testAcc[a-zA-Z0-9]+Config(_[a-zA-Z0-9_]+_|_)[a-z0-9].*" + - pattern-not-regex: "testAcc[0-9A-Za-z]+Config(_[0-9A-Za-z_]+_|_)[0-9a-z].*" - pattern-not: acctest.ConfigCompose(...) - pattern-not: "..." severity: WARNING @@ -39,7 +39,7 @@ rules: - metavariable-pattern: metavariable: "$VALUE" patterns: - - pattern-not-regex: "testAcc[a-zA-Z0-9]+Config(_[a-zA-Z0-9_]+_|_)[a-z0-9].*" + - pattern-not-regex: "testAcc[0-9A-Za-z]+Config(_[0-9A-Za-z_]+_|_)[0-9a-z].*" - pattern-not-regex: "acctest\\..*" severity: WARNING diff --git a/internal/generate/tags/main.go b/internal/generate/tags/main.go index 9d4d09eeeb2e..108c1bbeb157 100644 --- a/internal/generate/tags/main.go +++ b/internal/generate/tags/main.go @@ -421,7 +421,7 @@ func main() { func toSnakeCase(str string) string { result := regexache.MustCompile("(.)([A-Z][a-z]+)").ReplaceAllString(str, "${1}_${2}") - result = regexache.MustCompile("([a-z0-9])([A-Z])").ReplaceAllString(result, "${1}_${2}") + result = regexache.MustCompile("([0-9a-z])([A-Z])").ReplaceAllString(result, "${1}_${2}") return strings.ToLower(result) } diff --git a/internal/service/accessanalyzer/analyzer.go b/internal/service/accessanalyzer/analyzer.go index 58124c29bada..a84994c3a86f 100644 --- a/internal/service/accessanalyzer/analyzer.go +++ b/internal/service/accessanalyzer/analyzer.go @@ -55,7 +55,7 @@ func resourceAnalyzer() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z][A-Za-z0-9_.-]*$`), "must begin with a letter and contain only alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z][0-9A-Za-z_.-]*$`), "must begin with a letter and contain only alphanumeric, underscore, period, or hyphen characters"), ), }, "arn": { diff --git a/internal/service/account/alternate_contact.go b/internal/service/account/alternate_contact.go index cf4fc19ae96b..ebea2b6f29ad 100644 --- a/internal/service/account/alternate_contact.go +++ b/internal/service/account/alternate_contact.go @@ -70,7 +70,7 @@ func resourceAlternateContact() *schema.Resource { "phone_number": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[\s0-9()+-]+$`), "must be a valid phone number"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9\s()+-]+$`), "must be a valid phone number"), }, "title": { Type: schema.TypeString, diff --git a/internal/service/account/primary_contact.go b/internal/service/account/primary_contact.go index 858fc8ac25e1..80324c7f8d24 100644 --- a/internal/service/account/primary_contact.go +++ b/internal/service/account/primary_contact.go @@ -76,7 +76,7 @@ func resourcePrimaryContact() *schema.Resource { "phone_number": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[+][\s0-9()-]+$`), "must be a valid phone number"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[+][0-9\s()-]+$`), "must be a valid phone number"), }, "postal_code": { Type: schema.TypeString, diff --git a/internal/service/apigateway/domain_name_test.go b/internal/service/apigateway/domain_name_test.go index dba2bf5df91a..293cee8850c7 100644 --- a/internal/service/apigateway/domain_name_test.go +++ b/internal/service/apigateway/domain_name_test.go @@ -42,7 +42,7 @@ func TestAccAPIGatewayDomainName_certificateARN(t *testing.T) { testAccCheckDomainNameExists(ctx, resourceName, &domainName), testAccCheckResourceAttrRegionalARNEdgeDomainName(resourceName, "arn", "apigateway", domain), resource.TestCheckResourceAttrPair(resourceName, "certificate_arn", acmCertificateResourceName, "arn"), - resource.TestMatchResourceAttr(resourceName, "cloudfront_domain_name", regexache.MustCompile(`[a-z0-9]+.cloudfront.net`)), + resource.TestMatchResourceAttr(resourceName, "cloudfront_domain_name", regexache.MustCompile(`[0-9a-z]+.cloudfront.net`)), resource.TestCheckResourceAttr(resourceName, "cloudfront_zone_id", "Z2FDTNDATAQYW2"), resource.TestCheckResourceAttrPair(resourceName, "domain_name", acmCertificateResourceName, "domain_name"), ), @@ -140,7 +140,7 @@ func TestAccAPIGatewayDomainName_regionalCertificateARN(t *testing.T) { testAccCheckDomainNameExists(ctx, resourceName, &domainName), testAccCheckResourceAttrRegionalARNRegionalDomainName(resourceName, "arn", "apigateway", rName), resource.TestCheckResourceAttr(resourceName, "domain_name", rName), - acctest.MatchResourceAttrRegionalHostname(resourceName, "regional_domain_name", "execute-api", regexache.MustCompile(`d-[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, "regional_domain_name", "execute-api", regexache.MustCompile(`d-[0-9a-z]+`)), resource.TestMatchResourceAttr(resourceName, "regional_zone_id", regexache.MustCompile(`^Z`)), ), }, @@ -189,7 +189,7 @@ func TestAccAPIGatewayDomainName_regionalCertificateName(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "certificate_private_key", key), resource.TestCheckResourceAttrSet(resourceName, "certificate_upload_date"), resource.TestCheckResourceAttr(resourceName, "domain_name", rName), - acctest.MatchResourceAttrRegionalHostname(resourceName, "regional_domain_name", "execute-api", regexache.MustCompile(`d-[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, "regional_domain_name", "execute-api", regexache.MustCompile(`d-[0-9a-z]+`)), resource.TestMatchResourceAttr(resourceName, "regional_zone_id", regexache.MustCompile(`^Z`)), ), }, diff --git a/internal/service/apigateway/rest_api_test.go b/internal/service/apigateway/rest_api_test.go index 53d6945cd5ce..fa86fc8a08b1 100644 --- a/internal/service/apigateway/rest_api_test.go +++ b/internal/service/apigateway/rest_api_test.go @@ -45,10 +45,10 @@ func TestAccAPIGatewayRestAPI_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "description", ""), resource.TestCheckResourceAttr(resourceName, "disable_execute_api_endpoint", "false"), resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), - acctest.MatchResourceAttrRegionalARN(resourceName, "execution_arn", "execute-api", regexache.MustCompile(`[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "execution_arn", "execute-api", regexache.MustCompile(`[0-9a-z]+`)), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "parameters.%", "0"), - resource.TestMatchResourceAttr(resourceName, "root_resource_id", regexache.MustCompile(`[a-z0-9]+`)), + resource.TestMatchResourceAttr(resourceName, "root_resource_id", regexache.MustCompile(`[0-9a-z]+`)), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, diff --git a/internal/service/apigatewayv2/model.go b/internal/service/apigatewayv2/model.go index 36cf197b62ae..fbf855473f54 100644 --- a/internal/service/apigatewayv2/model.go +++ b/internal/service/apigatewayv2/model.go @@ -54,7 +54,7 @@ func ResourceModel() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), "must be alphanumeric"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), "must be alphanumeric"), ), }, "schema": { diff --git a/internal/service/appconfig/application_test.go b/internal/service/appconfig/application_test.go index 3fb3cfb28507..a30d0df062f8 100644 --- a/internal/service/appconfig/application_test.go +++ b/internal/service/appconfig/application_test.go @@ -35,7 +35,7 @@ func TestAccAppConfigApplication_basic(t *testing.T) { Config: testAccApplicationConfig_name(rName), Check: resource.ComposeTestCheckFunc( testAccCheckApplicationExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[a-z0-9]{4,7}`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[0-9a-z]{4,7}`)), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index b3806812d172..88375c4753e9 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -41,7 +41,7 @@ func ResourceConfigurationProfile() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, "arn": { Type: schema.TypeString, diff --git a/internal/service/appconfig/configuration_profile_test.go b/internal/service/appconfig/configuration_profile_test.go index e33b211bba31..cf81871a59f9 100644 --- a/internal/service/appconfig/configuration_profile_test.go +++ b/internal/service/appconfig/configuration_profile_test.go @@ -37,8 +37,8 @@ func TestAccAppConfigConfigurationProfile_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckConfigurationProfileExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, "application_id", appResourceName, "id"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[a-z0-9]{4,7}/configurationprofile/[a-z0-9]{4,7}`)), - resource.TestMatchResourceAttr(resourceName, "configuration_profile_id", regexache.MustCompile(`[a-z0-9]{4,7}`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[0-9a-z]{4,7}/configurationprofile/[0-9a-z]{4,7}`)), + resource.TestMatchResourceAttr(resourceName, "configuration_profile_id", regexache.MustCompile(`[0-9a-z]{4,7}`)), resource.TestCheckResourceAttr(resourceName, "location_uri", "hosted"), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), diff --git a/internal/service/appconfig/deployment.go b/internal/service/appconfig/deployment.go index 9c6f59feecb9..942d58f3f69e 100644 --- a/internal/service/appconfig/deployment.go +++ b/internal/service/appconfig/deployment.go @@ -42,7 +42,7 @@ func ResourceDeployment() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, "arn": { Type: schema.TypeString, @@ -52,7 +52,7 @@ func ResourceDeployment() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, "configuration_version": { Type: schema.TypeString, @@ -68,7 +68,7 @@ func ResourceDeployment() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`(^[a-z0-9]{4,7}$|^AppConfig\.[A-Za-z0-9]{9,40}$)`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`(^[0-9a-z]{4,7}$|^AppConfig\.[0-9A-Za-z]{9,40}$)`), ""), }, "description": { Type: schema.TypeString, @@ -80,7 +80,7 @@ func ResourceDeployment() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, "state": { Type: schema.TypeString, diff --git a/internal/service/appconfig/deployment_strategy_test.go b/internal/service/appconfig/deployment_strategy_test.go index c858fa5b749f..323b335a2403 100644 --- a/internal/service/appconfig/deployment_strategy_test.go +++ b/internal/service/appconfig/deployment_strategy_test.go @@ -35,7 +35,7 @@ func TestAccAppConfigDeploymentStrategy_basic(t *testing.T) { Config: testAccDeploymentStrategyConfig_name(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDeploymentStrategyExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`deploymentstrategy/[a-z0-9]{4,7}`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`deploymentstrategy/[0-9a-z]{4,7}`)), resource.TestCheckResourceAttr(resourceName, "deployment_duration_in_minutes", "3"), resource.TestCheckResourceAttr(resourceName, "growth_factor", "10"), resource.TestCheckResourceAttr(resourceName, "name", rName), diff --git a/internal/service/appconfig/deployment_test.go b/internal/service/appconfig/deployment_test.go index 8e91553eec32..45b513a7e35c 100644 --- a/internal/service/appconfig/deployment_test.go +++ b/internal/service/appconfig/deployment_test.go @@ -41,7 +41,7 @@ func TestAccAppConfigDeployment_basic(t *testing.T) { Config: testAccDeploymentConfig_name(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDeploymentExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[a-z0-9]{4,7}/environment/[a-z0-9]{4,7}/deployment/1`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[0-9a-z]{4,7}/environment/[0-9a-z]{4,7}/deployment/1`)), resource.TestCheckResourceAttrPair(resourceName, "application_id", appResourceName, "id"), resource.TestCheckResourceAttrPair(resourceName, "configuration_profile_id", confProfResourceName, "configuration_profile_id"), resource.TestCheckResourceAttrPair(resourceName, "configuration_version", confVersionResourceName, "version_number"), diff --git a/internal/service/appconfig/environment.go b/internal/service/appconfig/environment.go index c6ed5ec276f2..258bb7c90723 100644 --- a/internal/service/appconfig/environment.go +++ b/internal/service/appconfig/environment.go @@ -63,7 +63,7 @@ func (r *resourceEnvironment) Schema(ctx context.Context, request resource.Schem }, Validators: []validator.String{ stringvalidator.RegexMatches( - regexache.MustCompile(`^[a-z0-9]{4,7}$`), + regexache.MustCompile(`^[0-9a-z]{4,7}$`), "value must contain 4-7 lowercase letters or numbers", ), }, diff --git a/internal/service/appconfig/environment_test.go b/internal/service/appconfig/environment_test.go index 6ef3a051394c..a5fb55f9347d 100644 --- a/internal/service/appconfig/environment_test.go +++ b/internal/service/appconfig/environment_test.go @@ -36,7 +36,7 @@ func TestAccAppConfigEnvironment_basic(t *testing.T) { Config: testAccEnvironmentConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckEnvironmentExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[a-z0-9]{4,7}/environment/[a-z0-9]{4,7}`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[0-9a-z]{4,7}/environment/[0-9a-z]{4,7}`)), resource.TestCheckResourceAttrPair(resourceName, "application_id", appResourceName, "id"), resource.TestCheckResourceAttr(resourceName, "description", ""), resource.TestCheckResourceAttr(resourceName, "monitor.#", "0"), diff --git a/internal/service/appconfig/hosted_configuration_version.go b/internal/service/appconfig/hosted_configuration_version.go index f741c2f25ee6..a7848c030d24 100644 --- a/internal/service/appconfig/hosted_configuration_version.go +++ b/internal/service/appconfig/hosted_configuration_version.go @@ -37,7 +37,7 @@ func ResourceHostedConfigurationVersion() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, "arn": { Type: schema.TypeString, @@ -47,7 +47,7 @@ func ResourceHostedConfigurationVersion() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, "content": { Type: schema.TypeString, diff --git a/internal/service/appconfig/hosted_configuration_version_test.go b/internal/service/appconfig/hosted_configuration_version_test.go index 1f9f3e0d1da8..7d50e54b5e82 100644 --- a/internal/service/appconfig/hosted_configuration_version_test.go +++ b/internal/service/appconfig/hosted_configuration_version_test.go @@ -35,7 +35,7 @@ func TestAccAppConfigHostedConfigurationVersion_basic(t *testing.T) { Config: testAccHostedConfigurationVersionConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckHostedConfigurationVersionExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[a-z0-9]{4,7}/configurationprofile/[a-z0-9]{4,7}/hostedconfigurationversion/[0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "appconfig", regexache.MustCompile(`application/[0-9a-z]{4,7}/configurationprofile/[0-9a-z]{4,7}/hostedconfigurationversion/[0-9]+`)), resource.TestCheckResourceAttrPair(resourceName, "application_id", "aws_appconfig_application.test", "id"), resource.TestCheckResourceAttrPair(resourceName, "configuration_profile_id", "aws_appconfig_configuration_profile.test", "configuration_profile_id"), resource.TestCheckResourceAttr(resourceName, "content", "{\"foo\":\"bar\"}"), diff --git a/internal/service/appconfig/sweep.go b/internal/service/appconfig/sweep.go index c930e7a19185..85f76edb7305 100644 --- a/internal/service/appconfig/sweep.go +++ b/internal/service/appconfig/sweep.go @@ -210,7 +210,7 @@ func sweepDeploymentStrategies(region string) error { id := aws.StringValue(item.Id) // Deleting AppConfig Predefined Strategies is not supported; returns BadRequestException - if regexache.MustCompile(`^AppConfig\.[A-Za-z0-9]{9,40}$`).MatchString(id) { + if regexache.MustCompile(`^AppConfig\.[0-9A-Za-z]{9,40}$`).MatchString(id) { log.Printf("[DEBUG] Skipping AppConfig Deployment Strategy (%s): predefined strategy cannot be deleted", id) continue } diff --git a/internal/service/appflow/connector_profile.go b/internal/service/appflow/connector_profile.go index 3c3755b501a6..6879f6a0ae5a 100644 --- a/internal/service/appflow/connector_profile.go +++ b/internal/service/appflow/connector_profile.go @@ -53,7 +53,7 @@ func ResourceConnectorProfile() *schema.Resource { Optional: true, ForceNew: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][\w!@#.-]+`), "must contain only alphanumeric, exclamation point (!), at sign (@), number sign (#), period (.), and hyphen (-) characters"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][\w!@#.-]+`), "must contain only alphanumeric, exclamation point (!), at sign (@), number sign (#), period (.), and hyphen (-) characters"), validation.StringLenBetween(1, 256), ), }, @@ -956,7 +956,7 @@ func ResourceConnectorProfile() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]`), "must provide a valid HTTPS url"), + validation.StringMatch(regexache.MustCompile(`^(https?)://[0-9A-Za-z-+&@#/%?=~_|!:,.;]*[0-9A-Za-z-+&@#/%=~_|]`), "must provide a valid HTTPS url"), ), }, "token_url_custom_properties": { @@ -1156,7 +1156,7 @@ func ResourceConnectorProfile() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]`), "must provide a valid HTTPS url"), + validation.StringMatch(regexache.MustCompile(`^(https?)://[0-9A-Za-z-+&@#/%?=~_|!:,.;]*[0-9A-Za-z-+&@#/%=~_|]`), "must provide a valid HTTPS url"), ), }, "application_service_path": { @@ -1180,7 +1180,7 @@ func ResourceConnectorProfile() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 2), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_]*$`), "must contain only alphanumeric characters and the underscore (_) character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]*$`), "must contain only alphanumeric characters and the underscore (_) character"), ), }, "oauth_properties": { @@ -1194,7 +1194,7 @@ func ResourceConnectorProfile() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]`), "must provide a valid HTTPS url"), + validation.StringMatch(regexache.MustCompile(`^(https?)://[0-9A-Za-z-+&@#/%?=~_|!:,.;]*[0-9A-Za-z-+&@#/%=~_|]`), "must provide a valid HTTPS url"), ), }, "oauth_scopes": { @@ -1213,7 +1213,7 @@ func ResourceConnectorProfile() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^(https?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]`), "must provide a valid HTTPS url"), + validation.StringMatch(regexache.MustCompile(`^(https?)://[0-9A-Za-z-+&@#/%?=~_|!:,.;]*[0-9A-Za-z-+&@#/%=~_|]`), "must provide a valid HTTPS url"), ), }, }, diff --git a/internal/service/appflow/flow.go b/internal/service/appflow/flow.go index 5a083e5789a0..f845bde375d2 100644 --- a/internal/service/appflow/flow.go +++ b/internal/service/appflow/flow.go @@ -48,7 +48,7 @@ func ResourceFlow() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.All(validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][\w!@#.-]+`), "must contain only alphanumeric, exclamation point (!), at sign (@), number sign (#), period (.), and hyphen (-) characters"), validation.StringLenBetween(1, 256)), + ValidateFunc: validation.All(validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][\w!@#.-]+`), "must contain only alphanumeric, exclamation point (!), at sign (@), number sign (#), period (.), and hyphen (-) characters"), validation.StringLenBetween(1, 256)), }, names.AttrDescription: { Type: schema.TypeString, diff --git a/internal/service/appintegrations/data_integration.go b/internal/service/appintegrations/data_integration.go index 07d36ae016a3..007c173137ac 100644 --- a/internal/service/appintegrations/data_integration.go +++ b/internal/service/appintegrations/data_integration.go @@ -55,7 +55,7 @@ func ResourceDataIntegration() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\/\._\-]+$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z\/\._\-]+$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), ), }, "schedule_config": { @@ -77,7 +77,7 @@ func ResourceDataIntegration() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\/\._\-]+$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z\/\._\-]+$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), ), }, "schedule_expression": { diff --git a/internal/service/appintegrations/event_integration.go b/internal/service/appintegrations/event_integration.go index aee9debe7204..8d9c8fa9dcf5 100644 --- a/internal/service/appintegrations/event_integration.go +++ b/internal/service/appintegrations/event_integration.go @@ -46,7 +46,7 @@ func ResourceEventIntegration() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\/\._\-]{1,255}$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z\/\._\-]{1,255}$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), }, "event_filter": { Type: schema.TypeList, @@ -68,7 +68,7 @@ func ResourceEventIntegration() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\/\._\-]{1,255}$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z\/\._\-]{1,255}$`), "should be not be more than 255 alphanumeric, forward slashes, dots, underscores, or hyphen characters"), }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), diff --git a/internal/service/appsync/datasource.go b/internal/service/appsync/datasource.go index 66357893ef40..f12dc6f28d54 100644 --- a/internal/service/appsync/datasource.go +++ b/internal/service/appsync/datasource.go @@ -213,7 +213,7 @@ func ResourceDataSource() *schema.Resource { "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[_A-Za-z][_0-9A-Za-z]*`), "must match [_A-Za-z][_0-9A-Za-z]*"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[A-Za-z_][0-9A-Za-z_]*`), "must match [A-Za-z_][0-9A-Za-z_]*"), }, "relational_database_config": { Type: schema.TypeList, diff --git a/internal/service/appsync/function.go b/internal/service/appsync/function.go index d43b17ac41a5..f1135e3ce7b5 100644 --- a/internal/service/appsync/function.go +++ b/internal/service/appsync/function.go @@ -77,7 +77,7 @@ func ResourceFunction() *schema.Resource { "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[_A-Za-z][_0-9A-Za-z]*`), "must match [_A-Za-z][_0-9A-Za-z]*"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[A-Za-z_][0-9A-Za-z_]*`), "must match [A-Za-z_][0-9A-Za-z_]*"), }, "request_mapping_template": { Type: schema.TypeString, diff --git a/internal/service/appsync/graphql_api.go b/internal/service/appsync/graphql_api.go index ce677c0163b3..e59d2ab0c20e 100644 --- a/internal/service/appsync/graphql_api.go +++ b/internal/service/appsync/graphql_api.go @@ -188,8 +188,8 @@ func ResourceGraphQLAPI() *schema.Resource { Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`[_A-Za-z][_0-9A-Za-z]*`).MatchString(value) { - errors = append(errors, fmt.Errorf("%q must match [_A-Za-z][_0-9A-Za-z]*", k)) + if !regexache.MustCompile(`[A-Za-z_][0-9A-Za-z_]*`).MatchString(value) { + errors = append(errors, fmt.Errorf("%q must match [A-Za-z_][0-9A-Za-z_]*", k)) } return }, diff --git a/internal/service/athena/database.go b/internal/service/athena/database.go index bbdb56013c58..b6690f4f681f 100644 --- a/internal/service/athena/database.go +++ b/internal/service/athena/database.go @@ -95,7 +95,7 @@ func ResourceDatabase() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile("^[_a-z0-9]+$"), "must be lowercase letters, numbers, or underscore ('_')"), + ValidateFunc: validation.StringMatch(regexache.MustCompile("^[0-9a-z_]+$"), "must be lowercase letters, numbers, or underscore ('_')"), }, "properties": { Type: schema.TypeMap, diff --git a/internal/service/athena/workgroup.go b/internal/service/athena/workgroup.go index 35d2117b0860..5340d4994da8 100644 --- a/internal/service/athena/workgroup.go +++ b/internal/service/athena/workgroup.go @@ -157,7 +157,7 @@ func ResourceWorkGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._-]+$`), "must contain only alphanumeric characters, periods, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z._-]+$`), "must contain only alphanumeric characters, periods, underscores, and hyphens"), ), }, "state": { diff --git a/internal/service/backup/plan.go b/internal/service/backup/plan.go index 524fa6274183..9093e0f7a4b1 100644 --- a/internal/service/backup/plan.go +++ b/internal/service/backup/plan.go @@ -56,7 +56,7 @@ func ResourcePlan() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 50), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_\.]+$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, "target_vault_name": { @@ -64,7 +64,7 @@ func ResourcePlan() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 50), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_]+$`), "must contain only alphanumeric characters, hyphens, and underscores"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric characters, hyphens, and underscores"), ), }, "schedule": { diff --git a/internal/service/backup/selection.go b/internal/service/backup/selection.go index 9d96691fdaed..76c9bf217b8d 100644 --- a/internal/service/backup/selection.go +++ b/internal/service/backup/selection.go @@ -43,7 +43,7 @@ func ResourceSelection() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 50), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_\.]+$`), "must contain only alphanumeric, hyphen, underscore, and period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric, hyphen, underscore, and period characters"), ), }, "plan_id": { diff --git a/internal/service/backup/validate.go b/internal/service/backup/validate.go index b9f6503e96cb..7c04deccb599 100644 --- a/internal/service/backup/validate.go +++ b/internal/service/backup/validate.go @@ -11,7 +11,7 @@ import ( func validReportPlanName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[a-zA-Z]{1}[_a-zA-Z0-9]{0,255}$`).MatchString(value) { + if !regexache.MustCompile(`^[A-Za-z]{1}[0-9A-Za-z_]{0,255}$`).MatchString(value) { errors = append(errors, fmt.Errorf("%q (%q) must be must be between 1 and 256 characters, starting with a letter, and consisting of letters, numbers, and underscores.", k, v)) } return @@ -20,7 +20,7 @@ func validReportPlanName(v interface{}, k string) (ws []string, errors []error) // The pattern for framework and report plan name is the same but separate functions are used in the event that there are future differences func validFrameworkName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[a-zA-Z]{1}[_a-zA-Z0-9]{0,255}$`).MatchString(value) { + if !regexache.MustCompile(`^[A-Za-z]{1}[0-9A-Za-z_]{0,255}$`).MatchString(value) { errors = append(errors, fmt.Errorf("%q (%q) must be must be between 1 and 256 characters, starting with a letter, and consisting of letters, numbers, and underscores.", k, v)) } return diff --git a/internal/service/backup/vault.go b/internal/service/backup/vault.go index 845fb0c7d4da..e731ab9e26de 100644 --- a/internal/service/backup/vault.go +++ b/internal/service/backup/vault.go @@ -65,7 +65,7 @@ func ResourceVault() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 50), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_]*$`), "must consist of letters, numbers, and hyphens."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]*$`), "must consist of letters, numbers, and hyphens."), ), }, "recovery_points": { diff --git a/internal/service/backup/vault_lock_configuration.go b/internal/service/backup/vault_lock_configuration.go index 3a8477061a7b..3db045432b00 100644 --- a/internal/service/backup/vault_lock_configuration.go +++ b/internal/service/backup/vault_lock_configuration.go @@ -34,7 +34,7 @@ func ResourceVaultLockConfiguration() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_\.]{1,50}$`), "must consist of lowercase letters, numbers, and hyphens."), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{1,50}$`), "must consist of lowercase letters, numbers, and hyphens."), }, "backup_vault_arn": { Type: schema.TypeString, diff --git a/internal/service/backup/vault_notifications.go b/internal/service/backup/vault_notifications.go index f54f4f19b7dc..1d2d10bd31cc 100644 --- a/internal/service/backup/vault_notifications.go +++ b/internal/service/backup/vault_notifications.go @@ -35,7 +35,7 @@ func ResourceVaultNotifications() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_\.]{1,50}$`), "must consist of lowercase letters, numbers, and hyphens."), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{1,50}$`), "must consist of lowercase letters, numbers, and hyphens."), }, "sns_topic_arn": { Type: schema.TypeString, diff --git a/internal/service/batch/job_definition.go b/internal/service/batch/job_definition.go index 862d6646b314..fbd4075f28be 100644 --- a/internal/service/batch/job_definition.go +++ b/internal/service/batch/job_definition.go @@ -134,7 +134,7 @@ func ResourceJobDefinition() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 512), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\.:\s]*\*?$`), "must contain letters, numbers, periods, colons, and white space, and can optionally end with an asterisk"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z.:\s]*\*?$`), "must contain letters, numbers, periods, colons, and white space, and can optionally end with an asterisk"), ), }, "on_status_reason": { @@ -143,7 +143,7 @@ func ResourceJobDefinition() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 512), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\.:\s]*\*?$`), "must contain letters, numbers, periods, colons, and white space, and can optionally end with an asterisk"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z.:\s]*\*?$`), "must contain letters, numbers, periods, colons, and white space, and can optionally end with an asterisk"), ), }, }, diff --git a/internal/service/batch/job_queue.go b/internal/service/batch/job_queue.go index 15711d82f636..245721c22605 100644 --- a/internal/service/batch/job_queue.go +++ b/internal/service/batch/job_queue.go @@ -75,7 +75,7 @@ func (r *resourceJobQueue) Schema(ctx context.Context, request resource.SchemaRe stringplanmodifier.RequiresReplace(), }, Validators: []validator.String{ - stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9a-zA-Z]{1}[0-9a-zA-Z_\-]{0,127}$`), + stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9A-Za-z]{1}[0-9A-Za-z_-]{0,127}$`), "must be up to 128 letters (uppercase and lowercase), numbers, underscores and dashes, and must start with an alphanumeric"), }, }, diff --git a/internal/service/batch/job_queue_schema.go b/internal/service/batch/job_queue_schema.go index 417d3b26d3b4..bd19814922cd 100644 --- a/internal/service/batch/job_queue_schema.go +++ b/internal/service/batch/job_queue_schema.go @@ -38,7 +38,7 @@ func jobQueueSchema0(ctx context.Context) schema.Schema { stringplanmodifier.RequiresReplace(), }, Validators: []validator.String{ - stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9a-zA-Z]{1}[0-9a-zA-Z_\-]{0,127}$`), + stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9A-Za-z]{1}[0-9A-Za-z_-]{0,127}$`), "must be up to 128 letters (uppercase and lowercase), numbers, underscores and dashes, and must start with an alphanumeric"), }, }, diff --git a/internal/service/batch/validate.go b/internal/service/batch/validate.go index b7100969b8fb..b45171b5b440 100644 --- a/internal/service/batch/validate.go +++ b/internal/service/batch/validate.go @@ -11,7 +11,7 @@ import ( func validName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[0-9a-zA-Z]{1}[0-9a-zA-Z_\-]{0,127}$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z]{1}[0-9A-Za-z_-]{0,127}$`).MatchString(value) { errors = append(errors, fmt.Errorf("%q (%q) must be up to 128 letters (uppercase and lowercase), numbers, underscores and dashes, and must start with an alphanumeric.", k, v)) } return @@ -19,7 +19,7 @@ func validName(v interface{}, k string) (ws []string, errors []error) { func validPrefix(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[0-9a-zA-Z]{1}[0-9a-zA-Z_\-]{0,101}$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z]{1}[0-9A-Za-z_-]{0,101}$`).MatchString(value) { errors = append(errors, fmt.Errorf("%q (%q) must be up to 102 letters (uppercase and lowercase), numbers, underscores and dashes, and must start with an alphanumeric.", k, v)) } return @@ -27,7 +27,7 @@ func validPrefix(v interface{}, k string) (ws []string, errors []error) { func validShareIdentifier(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[a-zA-Z0-9]{0,254}[a-zA-Z0-9*]?$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z]{0,254}[0-9A-Za-z*]?$`).MatchString(value) { errors = append(errors, fmt.Errorf("%q (%q) must be limited to 255 alphanumeric characters, where the last character can be an asterisk (*).", k, v)) } return diff --git a/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go b/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go index 5cd566c01b20..9a4680c06e88 100644 --- a/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go +++ b/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go @@ -123,7 +123,7 @@ func AmazonTranscribeCallAnalyticsProcessorConfigurationSchema() *schema.Schema Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(1, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid Category Name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid Category Name matching expression: ^[0-9A-Za-z_.-]+"), ), }, }, @@ -155,7 +155,7 @@ func AmazonTranscribeCallAnalyticsProcessorConfigurationSchema() *schema.Schema Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid language model name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid language model name matching expression: ^[0-9A-Za-z_.-]+"), ), }, "partial_results_stability": { @@ -183,7 +183,7 @@ func AmazonTranscribeCallAnalyticsProcessorConfigurationSchema() *schema.Schema Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid vocabulary filter name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid vocabulary filter name matching expression: ^[0-9A-Za-z_.-]+"), ), }, "vocabulary_name": { @@ -191,7 +191,7 @@ func AmazonTranscribeCallAnalyticsProcessorConfigurationSchema() *schema.Schema Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid vocabulary name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid vocabulary name matching expression: ^[0-9A-Za-z_.-]+"), ), }, }, @@ -266,7 +266,7 @@ func AmazonTranscribeProcessorConfigurationSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid language model name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid language model name matching expression: ^[0-9A-Za-z_.-]+"), ), }, "partial_results_stability": { @@ -297,7 +297,7 @@ func AmazonTranscribeProcessorConfigurationSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid vocabulary filter name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid vocabulary filter name matching expression: ^[0-9A-Za-z_.-]+"), ), }, "vocabulary_name": { @@ -305,7 +305,7 @@ func AmazonTranscribeProcessorConfigurationSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 200), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must be a valid vocabulary name matching expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must be a valid vocabulary name matching expression: ^[0-9A-Za-z_.-]+"), ), }, }, @@ -397,7 +397,7 @@ func RealTimeAlertConfigurationSchema() *schema.Schema { "rule_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must match the expression: ^[0-9a-zA-Z._-]+"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must match the expression: ^[0-9A-Za-z_.-]+"), }, }, }, @@ -415,7 +415,7 @@ func RealTimeAlertConfigurationSchema() *schema.Schema { MaxItems: 100, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[\s0-9a-zA-Z'-]+`), "Must match the expression: ^[\\s0-9a-zA-Z'-]+"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z\s'-]+`), "Must match the expression: ^[0-9A-Za-z\\s'-]+"), }, }, "negate": { @@ -426,7 +426,7 @@ func RealTimeAlertConfigurationSchema() *schema.Schema { "rule_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must match the expression: ^[0-9a-zA-Z._-]+"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must match the expression: ^[0-9A-Za-z_.-]+"), }, }, }, @@ -440,7 +440,7 @@ func RealTimeAlertConfigurationSchema() *schema.Schema { "rule_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "Must match the expression: ^[0-9a-zA-Z._-]+"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "Must match the expression: ^[0-9A-Za-z_.-]+"), }, "sentiment_type": { Type: schema.TypeString, diff --git a/internal/service/chimesdkvoice/voice_profile_domain.go b/internal/service/chimesdkvoice/voice_profile_domain.go index 793215b50bfd..f6801dad62b4 100644 --- a/internal/service/chimesdkvoice/voice_profile_domain.go +++ b/internal/service/chimesdkvoice/voice_profile_domain.go @@ -67,7 +67,7 @@ func ResourceVoiceProfileDomain() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 200), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9 _.-]+`), "Name must match expression: ^[0-9a-zA-Z._-]+"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_ .-]+`), "Name must match expression: ^[0-9A-Za-z_ .-]+"), ), }, "server_side_encryption_configuration": { diff --git a/internal/service/cloudcontrol/resource.go b/internal/service/cloudcontrol/resource.go index 0b98bbaf63d2..4138f66a8567 100644 --- a/internal/service/cloudcontrol/resource.go +++ b/internal/service/cloudcontrol/resource.go @@ -66,7 +66,7 @@ func ResourceResource() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}`), "must be three alphanumeric sections separated by double colons (::)"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}`), "must be three alphanumeric sections separated by double colons (::)"), }, "type_version_id": { Type: schema.TypeString, diff --git a/internal/service/cloudcontrol/resource_data_source.go b/internal/service/cloudcontrol/resource_data_source.go index ad0169cc0f44..165eb80c1a52 100644 --- a/internal/service/cloudcontrol/resource_data_source.go +++ b/internal/service/cloudcontrol/resource_data_source.go @@ -35,7 +35,7 @@ func DataSourceResource() *schema.Resource { "type_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}`), "must be three alphanumeric sections separated by double colons (::)"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}`), "must be three alphanumeric sections separated by double colons (::)"), }, "type_version_id": { Type: schema.TypeString, diff --git a/internal/service/cloudformation/stack_data_source_test.go b/internal/service/cloudformation/stack_data_source_test.go index a93d5f39f003..4380f88d09d0 100644 --- a/internal/service/cloudformation/stack_data_source_test.go +++ b/internal/service/cloudformation/stack_data_source_test.go @@ -28,7 +28,7 @@ func TestAccCloudFormationStackDataSource_DataSource_basic(t *testing.T) { Config: testAccStackDataSourceConfig_basic(stackName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "outputs.%", "1"), - resource.TestMatchResourceAttr(resourceName, "outputs.VPCId", regexache.MustCompile("^vpc-[a-z0-9]+")), + resource.TestMatchResourceAttr(resourceName, "outputs.VPCId", regexache.MustCompile("^vpc-[0-9a-z]+")), resource.TestCheckResourceAttr(resourceName, "capabilities.#", "0"), resource.TestCheckResourceAttr(resourceName, "disable_rollback", "false"), resource.TestCheckResourceAttr(resourceName, "notification_arns.#", "0"), @@ -115,7 +115,7 @@ func TestAccCloudFormationStackDataSource_DataSource_yaml(t *testing.T) { Config: testAccStackDataSourceConfig_yaml(stackName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "outputs.%", "1"), - resource.TestMatchResourceAttr(resourceName, "outputs.VPCId", regexache.MustCompile("^vpc-[a-z0-9]+")), + resource.TestMatchResourceAttr(resourceName, "outputs.VPCId", regexache.MustCompile("^vpc-[0-9a-z]+")), resource.TestCheckResourceAttr(resourceName, "capabilities.#", "0"), resource.TestCheckResourceAttr(resourceName, "disable_rollback", "false"), resource.TestCheckResourceAttr(resourceName, "notification_arns.#", "0"), diff --git a/internal/service/cloudformation/stack_set.go b/internal/service/cloudformation/stack_set.go index fc60f906918a..38b68396d32d 100644 --- a/internal/service/cloudformation/stack_set.go +++ b/internal/service/cloudformation/stack_set.go @@ -124,8 +124,8 @@ func ResourceStackSet() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]+$`), "must contain only alphanumeric and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and hyphen characters"), ), }, "operation_preferences": { @@ -169,7 +169,7 @@ func ResourceStackSet() *schema.Resource { MinItems: 1, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]{1,128}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]{1,128}$`), ""), }, }, }, diff --git a/internal/service/cloudformation/stack_set_instance.go b/internal/service/cloudformation/stack_set_instance.go index e384d89148bf..f462304da97d 100644 --- a/internal/service/cloudformation/stack_set_instance.go +++ b/internal/service/cloudformation/stack_set_instance.go @@ -70,7 +70,7 @@ func ResourceStackSetInstance() *schema.Resource { MinItems: 1, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^(ou-[a-z0-9]{4,32}-[a-z0-9]{8,32}|r-[a-z0-9]{4,32})$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^(ou-[0-9a-z]{4,32}-[0-9a-z]{8,32}|r-[0-9a-z]{4,32})$`), ""), }, }, }, @@ -118,7 +118,7 @@ func ResourceStackSetInstance() *schema.Resource { MinItems: 1, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]{1,128}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]{1,128}$`), ""), }, }, }, diff --git a/internal/service/cloudformation/type.go b/internal/service/cloudformation/type.go index e017aef31679..66f114b11add 100644 --- a/internal/service/cloudformation/type.go +++ b/internal/service/cloudformation/type.go @@ -72,7 +72,7 @@ func ResourceType() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 512), - validation.StringMatch(regexache.MustCompile(`[\.\-_/#A-Za-z0-9]+`), "must contain only alphanumeric, period, hyphen, forward slash, and octothorp characters"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_./#-]+`), "must contain only alphanumeric, period, hyphen, forward slash, and octothorp characters"), ), }, "log_role_arn": { @@ -119,7 +119,7 @@ func ResourceType() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(10, 204), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}(::MODULE){0,1}`), "three alphanumeric character sections separated by double colons (::)"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}(::MODULE){0,1}`), "three alphanumeric character sections separated by double colons (::)"), ), }, "version_id": { diff --git a/internal/service/cloudformation/type_data_source.go b/internal/service/cloudformation/type_data_source.go index be077614cc79..76cb71ef4a2a 100644 --- a/internal/service/cloudformation/type_data_source.go +++ b/internal/service/cloudformation/type_data_source.go @@ -94,7 +94,7 @@ func DataSourceType() *schema.Resource { Computed: true, ValidateFunc: validation.All( validation.StringLenBetween(10, 204), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}(::MODULE){0,1}`), "three alphanumeric character sections separated by double colons (::)"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}::[0-9A-Za-z]{2,64}(::MODULE){0,1}`), "three alphanumeric character sections separated by double colons (::)"), ), }, "version_id": { diff --git a/internal/service/cloudfront/distribution_test.go b/internal/service/cloudfront/distribution_test.go index 0f83ce084fd5..d1c94d4702d5 100644 --- a/internal/service/cloudfront/distribution_test.go +++ b/internal/service/cloudfront/distribution_test.go @@ -222,7 +222,7 @@ func TestAccCloudFrontDistribution_originPolicyDefault(t *testing.T) { { Config: testAccDistributionConfig_originRequestPolicyDefault(rName), Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr("aws_cloudfront_distribution.custom_distribution", "default_cache_behavior.0.origin_request_policy_id", regexache.MustCompile("[A-z0-9]+")), + resource.TestMatchResourceAttr("aws_cloudfront_distribution.custom_distribution", "default_cache_behavior.0.origin_request_policy_id", regexache.MustCompile("[0-9A-z]+")), ), }, { @@ -255,7 +255,7 @@ func TestAccCloudFrontDistribution_originPolicyOrdered(t *testing.T) { { Config: testAccDistributionConfig_originRequestPolicyOrdered(rName), Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr("aws_cloudfront_distribution.custom_distribution", "ordered_cache_behavior.0.origin_request_policy_id", regexache.MustCompile("[A-z0-9]+")), + resource.TestMatchResourceAttr("aws_cloudfront_distribution.custom_distribution", "ordered_cache_behavior.0.origin_request_policy_id", regexache.MustCompile("[0-9A-Za-z]+")), ), }, { @@ -380,7 +380,7 @@ func TestAccCloudFrontDistribution_orderedCacheBehaviorCachePolicy(t *testing.T) Check: resource.ComposeTestCheckFunc( testAccCheckDistributionExists(ctx, resourceName, &distribution), resource.TestCheckResourceAttr(resourceName, "ordered_cache_behavior.0.path_pattern", "images2/*.jpg"), - resource.TestMatchResourceAttr(resourceName, "ordered_cache_behavior.0.cache_policy_id", regexache.MustCompile(`^[a-z0-9]+`)), + resource.TestMatchResourceAttr(resourceName, "ordered_cache_behavior.0.cache_policy_id", regexache.MustCompile(`^[0-9a-z]+`)), ), }, { @@ -417,7 +417,7 @@ func TestAccCloudFrontDistribution_orderedCacheBehaviorResponseHeadersPolicy(t * Check: resource.ComposeTestCheckFunc( testAccCheckDistributionExists(ctx, resourceName, &distribution), resource.TestCheckResourceAttr(resourceName, "ordered_cache_behavior.0.path_pattern", "images2/*.jpg"), - resource.TestMatchResourceAttr(resourceName, "ordered_cache_behavior.0.response_headers_policy_id", regexache.MustCompile(`^[a-z0-9]+`)), + resource.TestMatchResourceAttr(resourceName, "ordered_cache_behavior.0.response_headers_policy_id", regexache.MustCompile(`^[0-9a-z]+`)), ), }, { @@ -685,7 +685,7 @@ func TestAccCloudFrontDistribution_noOptionalItems(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDistributionExists(ctx, resourceName, &distribution), resource.TestCheckResourceAttr(resourceName, "aliases.#", "0"), - acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "cloudfront", regexache.MustCompile(`distribution/[A-Z0-9]+$`)), + acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "cloudfront", regexache.MustCompile(`distribution/[0-9A-Z]+$`)), resource.TestCheckResourceAttr(resourceName, "custom_error_response.#", "0"), resource.TestCheckResourceAttr(resourceName, "default_cache_behavior.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_cache_behavior.0.allowed_methods.#", "7"), @@ -706,9 +706,9 @@ func TestAccCloudFrontDistribution_noOptionalItems(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_cache_behavior.0.trusted_key_groups.#", "0"), resource.TestCheckResourceAttr(resourceName, "default_cache_behavior.0.trusted_signers.#", "0"), resource.TestCheckResourceAttr(resourceName, "default_cache_behavior.0.viewer_protocol_policy", "allow-all"), - resource.TestMatchResourceAttr(resourceName, "domain_name", regexache.MustCompile(`^[a-z0-9]+\.cloudfront\.net$`)), + resource.TestMatchResourceAttr(resourceName, "domain_name", regexache.MustCompile(`^[0-9a-z]+\.cloudfront\.net$`)), resource.TestCheckResourceAttr(resourceName, "enabled", "true"), - resource.TestMatchResourceAttr(resourceName, "etag", regexache.MustCompile(`^[A-Z0-9]+$`)), + resource.TestMatchResourceAttr(resourceName, "etag", regexache.MustCompile(`^[0-9A-Z]+$`)), resource.TestCheckResourceAttr(resourceName, "hosted_zone_id", "Z2FDTNDATAQYW2"), resource.TestCheckResourceAttrSet(resourceName, "http_version"), resource.TestCheckResourceAttr(resourceName, "is_ipv6_enabled", "false"), diff --git a/internal/service/cloudfront/origin_access_identity_test.go b/internal/service/cloudfront/origin_access_identity_test.go index 8225f9be997e..9c23a994a6de 100644 --- a/internal/service/cloudfront/origin_access_identity_test.go +++ b/internal/service/cloudfront/origin_access_identity_test.go @@ -36,10 +36,10 @@ func TestAccCloudFrontOriginAccessIdentity_basic(t *testing.T) { testAccCheckOriginAccessIdentityExistence(ctx, resourceName, &origin), resource.TestCheckResourceAttr(resourceName, "comment", "some comment"), resource.TestMatchResourceAttr(resourceName, "caller_reference", regexache.MustCompile(fmt.Sprintf("^%s", id.UniqueIdPrefix))), - resource.TestMatchResourceAttr(resourceName, "s3_canonical_user_id", regexache.MustCompile("^[a-z0-9]+")), - resource.TestMatchResourceAttr(resourceName, "cloudfront_access_identity_path", regexache.MustCompile("^origin-access-identity/cloudfront/[A-Z0-9]+")), + resource.TestMatchResourceAttr(resourceName, "s3_canonical_user_id", regexache.MustCompile("^[0-9a-z]+")), + resource.TestMatchResourceAttr(resourceName, "cloudfront_access_identity_path", regexache.MustCompile("^origin-access-identity/cloudfront/[0-9A-Z]+")), //lintignore:AWSAT001 - resource.TestMatchResourceAttr(resourceName, "iam_arn", regexache.MustCompile(fmt.Sprintf("^arn:%s:iam::cloudfront:user/CloudFront Origin Access Identity [A-Z0-9]+", acctest.Partition()))), + resource.TestMatchResourceAttr(resourceName, "iam_arn", regexache.MustCompile(fmt.Sprintf("^arn:%s:iam::cloudfront:user/CloudFront Origin Access Identity [0-9A-Z]+", acctest.Partition()))), ), }, { @@ -67,10 +67,10 @@ func TestAccCloudFrontOriginAccessIdentity_noComment(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckOriginAccessIdentityExistence(ctx, resourceName, &origin), resource.TestMatchResourceAttr(resourceName, "caller_reference", regexache.MustCompile(fmt.Sprintf("^%s", id.UniqueIdPrefix))), - resource.TestMatchResourceAttr(resourceName, "s3_canonical_user_id", regexache.MustCompile("^[a-z0-9]+")), - resource.TestMatchResourceAttr(resourceName, "cloudfront_access_identity_path", regexache.MustCompile("^origin-access-identity/cloudfront/[A-Z0-9]+")), + resource.TestMatchResourceAttr(resourceName, "s3_canonical_user_id", regexache.MustCompile("^[0-9a-z]+")), + resource.TestMatchResourceAttr(resourceName, "cloudfront_access_identity_path", regexache.MustCompile("^origin-access-identity/cloudfront/[0-9A-Z]+")), //lintignore:AWSAT001 - resource.TestMatchResourceAttr(resourceName, "iam_arn", regexache.MustCompile(fmt.Sprintf("^arn:%s:iam::cloudfront:user/CloudFront Origin Access Identity [A-Z0-9]+", acctest.Partition()))), + resource.TestMatchResourceAttr(resourceName, "iam_arn", regexache.MustCompile(fmt.Sprintf("^arn:%s:iam::cloudfront:user/CloudFront Origin Access Identity [0-9A-Z]+", acctest.Partition()))), ), }, { diff --git a/internal/service/cloudsearch/domain.go b/internal/service/cloudsearch/domain.go index 858ec5b909da..9901fbe28736 100644 --- a/internal/service/cloudsearch/domain.go +++ b/internal/service/cloudsearch/domain.go @@ -140,7 +140,7 @@ func ResourceDomain() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z]([a-z0-9-]){2,27}$`), "Search domain names must start with a lowercase letter (a-z) and be at least 3 and no more than 28 lower-case letters, digits or hyphens"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z]([0-9a-z-]){2,27}$`), "Search domain names must start with a lowercase letter (a-z) and be at least 3 and no more than 28 lower-case letters, digits or hyphens"), }, "scaling_parameters": { Type: schema.TypeList, @@ -496,7 +496,7 @@ func resourceDomainDelete(ctx context.Context, d *schema.ResourceData, meta inte func validateIndexName(v interface{}, k string) (ws []string, es []error) { value := v.(string) - if !regexache.MustCompile(`^(\*?[a-z][a-z0-9_]{2,63}|[a-z][a-z0-9_]{2,63}\*?)$`).MatchString(value) { + if !regexache.MustCompile(`^(\*?[a-z][0-9a-z_]{2,63}|[a-z][0-9a-z_]{2,63}\*?)$`).MatchString(value) { es = append(es, fmt.Errorf( "%q must begin with a letter and be at least 3 and no more than 64 characters long", k)) } diff --git a/internal/service/cloudwatch/metric_stream.go b/internal/service/cloudwatch/metric_stream.go index aab468a78302..d9e12053e9d3 100644 --- a/internal/service/cloudwatch/metric_stream.go +++ b/internal/service/cloudwatch/metric_stream.go @@ -446,7 +446,7 @@ func waitMetricStreamRunning(ctx context.Context, conn *cloudwatch.CloudWatch, n func validateMetricStreamName(v interface{}, k string) (ws []string, errors []error) { return validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[\-_A-Za-z0-9]*$`), "must match [\\-_A-Za-z0-9]"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]*$`), "must match [0-9A-Za-z_-]"), )(v, k) } diff --git a/internal/service/cloudwatch/validate.go b/internal/service/cloudwatch/validate.go index 552c5b0cc7a3..00052d3a37ba 100644 --- a/internal/service/cloudwatch/validate.go +++ b/internal/service/cloudwatch/validate.go @@ -17,7 +17,7 @@ func validDashboardName(v interface{}, k string) (ws []string, errors []error) { } // http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutDashboard.html - pattern := `^[\-_A-Za-z0-9]+$` + pattern := `^[0-9A-Za-z_-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q doesn't comply with restrictions (%q): %q", diff --git a/internal/service/codebuild/project.go b/internal/service/codebuild/project.go index effbdf540c5c..4d055badb820 100644 --- a/internal/service/codebuild/project.go +++ b/internal/service/codebuild/project.go @@ -1948,12 +1948,12 @@ func environmentVariablesToMap(environmentVariables []*codebuild.EnvironmentVari func ValidProjectName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[A-Za-z0-9]`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z]`).MatchString(value) { errors = append(errors, fmt.Errorf( "first character of %q must be a letter or number", value)) } - if !regexache.MustCompile(`^[A-Za-z0-9\-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z_-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only alphanumeric characters, hyphens and underscores allowed in %q", value)) } @@ -1974,7 +1974,7 @@ func validProjectS3LogsLocation(v interface{}, k string) (ws []string, errors [] return } - simplePattern := `^[a-z0-9][^/]*\/(.+)$` + simplePattern := `^[0-9a-z][^/]*\/(.+)$` if !regexache.MustCompile(simplePattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q does not match pattern (%q): %q", diff --git a/internal/service/codegurureviewer/repository_association.go b/internal/service/codegurureviewer/repository_association.go index a0b3eb99cb18..5571422c5862 100644 --- a/internal/service/codegurureviewer/repository_association.go +++ b/internal/service/codegurureviewer/repository_association.go @@ -85,7 +85,7 @@ func ResourceRepositoryAssociation() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9-]+`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z-]+`), ""), ), }, }, diff --git a/internal/service/codepipeline/codepipeline.go b/internal/service/codepipeline/codepipeline.go index 61066ba890f0..8183c598c67b 100644 --- a/internal/service/codepipeline/codepipeline.go +++ b/internal/service/codepipeline/codepipeline.go @@ -99,7 +99,7 @@ func ResourcePipeline() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 100), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9.@\-_]+`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_.@-]+`), ""), ), }, "role_arn": { @@ -143,7 +143,7 @@ func ResourcePipeline() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 100), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9.@\-_]+`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_.@-]+`), ""), ), }, "namespace": { @@ -151,7 +151,7 @@ func ResourcePipeline() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 100), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9@\-_]+`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_@-]+`), ""), ), }, "output_artifacts": { @@ -201,7 +201,7 @@ func ResourcePipeline() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 100), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9.@\-_]+`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_.@-]+`), ""), ), }, }, diff --git a/internal/service/codepipeline/webhook.go b/internal/service/codepipeline/webhook.go index c0f54289751f..820c1ae0c745 100644 --- a/internal/service/codepipeline/webhook.go +++ b/internal/service/codepipeline/webhook.go @@ -97,7 +97,7 @@ func ResourceWebhook() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 100), - validation.StringMatch(regexache.MustCompile(`[A-Za-z0-9.@\-_]+`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_.@-]+`), ""), ), }, "url": { diff --git a/internal/service/codestarnotifications/notification_rule.go b/internal/service/codestarnotifications/notification_rule.go index 4b46414fc75f..695c109ced37 100644 --- a/internal/service/codestarnotifications/notification_rule.go +++ b/internal/service/codestarnotifications/notification_rule.go @@ -64,7 +64,7 @@ func resourceNotificationRule() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9\-_ ]+$`), "must be one or more alphanumeric, hyphen, underscore or space characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_ -]+$`), "must be one or more alphanumeric, hyphen, underscore or space characters"), ), }, "resource": { diff --git a/internal/service/cognitoidp/user_pool_test.go b/internal/service/cognitoidp/user_pool_test.go index 04dc0dbd721f..77bc41f5caba 100644 --- a/internal/service/cognitoidp/user_pool_test.go +++ b/internal/service/cognitoidp/user_pool_test.go @@ -49,7 +49,7 @@ func TestAccCognitoIDPUserPool_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolExists(ctx, resourceName, nil), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "cognito-idp", regexache.MustCompile(`userpool/.+`)), - resource.TestMatchResourceAttr(resourceName, "endpoint", regexache.MustCompile(`^cognito-idp\.[^.]+\.amazonaws.com/[\w-]+_[0-9a-zA-Z]+$`)), + resource.TestMatchResourceAttr(resourceName, "endpoint", regexache.MustCompile(`^cognito-idp\.[^.]+\.amazonaws.com/[\w-]+_[0-9A-Za-z]+$`)), resource.TestCheckResourceAttr(resourceName, "name", rName), resource.TestCheckResourceAttrSet(resourceName, "creation_date"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), diff --git a/internal/service/cognitoidp/validate.go b/internal/service/cognitoidp/validate.go index 6d95b1ee12dd..d04108d8877f 100644 --- a/internal/service/cognitoidp/validate.go +++ b/internal/service/cognitoidp/validate.go @@ -76,7 +76,7 @@ func validUserPoolEmailVerificationSubject(v interface{}, k string) (ws []string func validUserPoolID(v interface{}, k string) (ws []string, es []error) { value := v.(string) - if !regexache.MustCompile(`^[\w-]+_[0-9a-zA-Z]+$`).MatchString(value) { + if !regexache.MustCompile(`^[\w-]+_[0-9A-Za-z]+$`).MatchString(value) { es = append(es, fmt.Errorf("%q must be the region name followed by an underscore and then alphanumeric pattern", k)) } return diff --git a/internal/service/comprehend/document_classifier.go b/internal/service/comprehend/document_classifier.go index 7d4e23d4179b..21da16f2340d 100644 --- a/internal/service/comprehend/document_classifier.go +++ b/internal/service/comprehend/document_classifier.go @@ -742,7 +742,7 @@ func flattenDocumentClassifierOutputDataConfig(apiObject *types.DocumentClassifi "output_s3_uri": s3Uri, } - re := regexache.MustCompile(`^(s3://[-a-z0-9.]{3,63}(/.+)?/)[-a-zA-Z0-9]+/output/output\.tar\.gz`) + re := regexache.MustCompile(`^(s3://[0-9a-z.-]{3,63}(/.+)?/)[0-9A-Za-z-]+/output/output\.tar\.gz`) match := re.FindStringSubmatch(s3Uri) if match != nil && match[1] != "" { m["s3_uri"] = match[1] diff --git a/internal/service/comprehend/document_classifier_test.go b/internal/service/comprehend/document_classifier_test.go index 66c79df5a21e..f1a0898e09a0 100644 --- a/internal/service/comprehend/document_classifier_test.go +++ b/internal/service/comprehend/document_classifier_test.go @@ -464,7 +464,7 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_basic(t *testing.T) { testAccCheckDocumentClassifierPublishedVersions(ctx, resourceName, 1), resource.TestCheckResourceAttr(resourceName, "output_data_config.#", "1"), resource.TestMatchResourceAttr(resourceName, "output_data_config.0.s3_uri", regexache.MustCompile(`s3://.+/outputs`)), - resource.TestMatchResourceAttr(resourceName, "output_data_config.0.output_s3_uri", regexache.MustCompile(`s3://.+/outputs/[-A-Za-z0-9]+/output/output.tar.gz`)), + resource.TestMatchResourceAttr(resourceName, "output_data_config.0.output_s3_uri", regexache.MustCompile(`s3://.+/outputs/[0-9A-Za-z-]+/output/output.tar.gz`)), ), }, { diff --git a/internal/service/configservice/config_rule_test.go b/internal/service/configservice/config_rule_test.go index 7996e9807994..0fd6a5275c2a 100644 --- a/internal/service/configservice/config_rule_test.go +++ b/internal/service/configservice/config_rule_test.go @@ -63,9 +63,9 @@ func testAccConfigRule_ownerAws(t *testing.T) { // nosemgrep:ci.aws-in-func-name Check: resource.ComposeTestCheckFunc( testAccCheckConfigRuleExists(ctx, resourceName, &cr), testAccCheckConfigRuleName(resourceName, rName, &cr), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "config", regexache.MustCompile("config-rule/config-rule-[a-z0-9]+$")), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "config", regexache.MustCompile("config-rule/config-rule-[0-9a-z]+$")), resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestMatchResourceAttr(resourceName, "rule_id", regexache.MustCompile("config-rule-[a-z0-9]+$")), + resource.TestMatchResourceAttr(resourceName, "rule_id", regexache.MustCompile("config-rule-[0-9a-z]+$")), resource.TestCheckResourceAttr(resourceName, "description", "Terraform Acceptance tests"), resource.TestCheckResourceAttr(resourceName, "source.#", "1"), resource.TestCheckResourceAttr(resourceName, "source.0.owner", "AWS"), @@ -106,9 +106,9 @@ func testAccConfigRule_customlambda(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckConfigRuleExists(ctx, resourceName, &cr), testAccCheckConfigRuleName(resourceName, expectedName, &cr), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "config", regexache.MustCompile("config-rule/config-rule-[a-z0-9]+$")), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "config", regexache.MustCompile("config-rule/config-rule-[0-9a-z]+$")), resource.TestCheckResourceAttr(resourceName, "name", expectedName), - resource.TestMatchResourceAttr(resourceName, "rule_id", regexache.MustCompile("config-rule-[a-z0-9]+$")), + resource.TestMatchResourceAttr(resourceName, "rule_id", regexache.MustCompile("config-rule-[0-9a-z]+$")), resource.TestCheckResourceAttr(resourceName, "description", "Terraform Acceptance tests"), resource.TestCheckResourceAttr(resourceName, "maximum_execution_frequency", "Six_Hours"), resource.TestCheckResourceAttr(resourceName, "source.#", "1"), @@ -151,9 +151,9 @@ func testAccConfigRule_ownerPolicy(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckConfigRuleExists(ctx, resourceName, &cr), testAccCheckConfigRuleName(resourceName, rName, &cr), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "config", regexache.MustCompile("config-rule/config-rule-[a-z0-9]+$")), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "config", regexache.MustCompile("config-rule/config-rule-[0-9a-z]+$")), resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestMatchResourceAttr(resourceName, "rule_id", regexache.MustCompile("config-rule-[a-z0-9]+$")), + resource.TestMatchResourceAttr(resourceName, "rule_id", regexache.MustCompile("config-rule-[0-9a-z]+$")), resource.TestCheckResourceAttr(resourceName, "source.#", "1"), resource.TestCheckResourceAttr(resourceName, "source.0.owner", "CUSTOM_POLICY"), resource.TestCheckResourceAttr(resourceName, "source.0.source_detail.#", "1"), diff --git a/internal/service/configservice/conformance_pack.go b/internal/service/configservice/conformance_pack.go index 213666045628..2b7609f8d8cb 100644 --- a/internal/service/configservice/conformance_pack.go +++ b/internal/service/configservice/conformance_pack.go @@ -73,8 +73,8 @@ func ResourceConformancePack() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]+$`), "must contain only alphanumeric and hyphen characters")), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and hyphen characters")), }, "template_body": { Type: schema.TypeString, diff --git a/internal/service/configservice/organization_conformance_pack.go b/internal/service/configservice/organization_conformance_pack.go index 7f51b4fcd7a1..626708afa318 100644 --- a/internal/service/configservice/organization_conformance_pack.go +++ b/internal/service/configservice/organization_conformance_pack.go @@ -89,8 +89,8 @@ func ResourceOrganizationConformancePack() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]+$`), "must contain only alphanumeric and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and hyphen characters"), ), }, "template_body": { diff --git a/internal/service/connect/instance.go b/internal/service/connect/instance.go index fd48bc462e5a..f6fb09e3f590 100644 --- a/internal/service/connect/instance.go +++ b/internal/service/connect/instance.go @@ -94,7 +94,7 @@ func ResourceInstance() *schema.Resource { AtLeastOneOf: []string{"directory_id", "instance_alias"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^([\da-zA-Z]+)([\da-zA-Z-]+)$`), "must contain only alphanumeric or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^([0-9A-Za-z]+)([0-9A-Za-z-]+)$`), "must contain only alphanumeric or hyphen characters"), validation.StringDoesNotMatch(regexache.MustCompile(`^(d-).+$`), "can not start with d-"), ), }, diff --git a/internal/service/connect/vocabulary.go b/internal/service/connect/vocabulary.go index 7968ac55cd4e..2bf7d1bd6fbe 100644 --- a/internal/service/connect/vocabulary.go +++ b/internal/service/connect/vocabulary.go @@ -81,7 +81,7 @@ func ResourceVocabulary() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 140), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+`), "must contain only alphanumeric, period, underscore, and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), "must contain only alphanumeric, period, underscore, and hyphen characters"), ), }, "state": { diff --git a/internal/service/datasync/task.go b/internal/service/datasync/task.go index fca0a9630cbc..a4d920cd972b 100644 --- a/internal/service/datasync/task.go +++ b/internal/service/datasync/task.go @@ -207,7 +207,7 @@ func ResourceTask() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\ \_\*\?\,\|\^\-\/\#\s\(\)\+]*$`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_ *?,|^\/#\s()+-]*$`), "Schedule expressions must have the following syntax: rate(\\\\s?(minutes?|hours?|days?)), cron() or at(yyyy-MM-dd'T'HH:mm:ss)."), ), }, diff --git a/internal/service/datasync/uri.go b/internal/service/datasync/uri.go index f2aa07c68782..f99c702f0769 100644 --- a/internal/service/datasync/uri.go +++ b/internal/service/datasync/uri.go @@ -11,8 +11,8 @@ import ( ) var ( - locationURIPattern = regexache.MustCompile(`^(azure-blob|efs|fsx[a-z0-9-]+|hdfs|nfs|s3|smb)://(.+)$`) - locationURIGlobalIDAndSubdirPattern = regexache.MustCompile(`^([a-zA-Z0-9.\-]+)(?::\d{0,5})?(/.*)$`) + locationURIPattern = regexache.MustCompile(`^(azure-blob|efs|fsx[0-9a-z-]+|hdfs|nfs|s3|smb)://(.+)$`) + locationURIGlobalIDAndSubdirPattern = regexache.MustCompile(`^([0-9A-Za-z.-]+)(?::\d{0,5})?(/.*)$`) s3OutpostsAccessPointARNResourcePattern = regexache.MustCompile(`^outpost/.*/accesspoint/.*?(/.*)$`) ) diff --git a/internal/service/directconnect/macsec_key.go b/internal/service/directconnect/macsec_key.go index 98a5ca9093d7..84f1c39a70ff 100644 --- a/internal/service/directconnect/macsec_key.go +++ b/internal/service/directconnect/macsec_key.go @@ -37,7 +37,7 @@ func ResourceMacSecKeyAssociation() *schema.Resource { Optional: true, // CAK requires CKN RequiredWith: []string{"ckn"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-fA-F0-9]{64}$`), "Must be 64-character hex code string"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Fa-f]{64}$`), "Must be 64-character hex code string"), ForceNew: true, }, "ckn": { @@ -45,7 +45,7 @@ func ResourceMacSecKeyAssociation() *schema.Resource { Computed: true, Optional: true, AtLeastOneOf: []string{"ckn", "secret_arn"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-fA-F0-9]{64}$`), "Must be 64-character hex code string"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Fa-f]{64}$`), "Must be 64-character hex code string"), ForceNew: true, }, "connection_id": { diff --git a/internal/service/dms/certificate.go b/internal/service/dms/certificate.go index c82e5df91597..370cc5fd007d 100644 --- a/internal/service/dms/certificate.go +++ b/internal/service/dms/certificate.go @@ -46,7 +46,7 @@ func ResourceCertificate() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile("^[a-zA-Z][a-zA-Z0-9-]+$"), "must start with a letter, only contain alphanumeric characters and hyphens"), + validation.StringMatch(regexache.MustCompile("^[A-Za-z][0-9A-Za-z-]+$"), "must start with a letter, only contain alphanumeric characters and hyphens"), validation.StringDoesNotMatch(regexache.MustCompile(`--`), "cannot contain two consecutive hyphens"), validation.StringDoesNotMatch(regexache.MustCompile(`-$`), "cannot end in a hyphen"), ), diff --git a/internal/service/dms/certificate_data_source.go b/internal/service/dms/certificate_data_source.go index 607152db55f6..bb052066c4c1 100644 --- a/internal/service/dms/certificate_data_source.go +++ b/internal/service/dms/certificate_data_source.go @@ -39,7 +39,7 @@ func DataSourceCertificate() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile("^[a-zA-Z][a-zA-Z0-9-]+$"), "must start with a letter, only contain alphanumeric characters and hyphens"), + validation.StringMatch(regexache.MustCompile("^[A-Za-z][0-9A-Za-z-]+$"), "must start with a letter, only contain alphanumeric characters and hyphens"), validation.StringDoesNotMatch(regexache.MustCompile(`--`), "cannot contain two consecutive hyphens"), validation.StringDoesNotMatch(regexache.MustCompile(`-$`), "cannot end in a hyphen"), ), diff --git a/internal/service/dms/validate.go b/internal/service/dms/validate.go index 9ee269bcafeb..6666c3c8354d 100644 --- a/internal/service/dms/validate.go +++ b/internal/service/dms/validate.go @@ -16,7 +16,7 @@ func validEndpointID(v interface{}, k string) (ws []string, es []error) { if len(val) > 255 { es = append(es, fmt.Errorf("%q must not be longer than 255 characters", k)) } - if !regexache.MustCompile("^[a-zA-Z][a-zA-Z0-9-]+$").MatchString(val) { + if !regexache.MustCompile("^[A-Za-z][0-9A-Za-z-]+$").MatchString(val) { es = append(es, fmt.Errorf("%q must start with a letter, only contain alphanumeric characters and hyphens", k)) } if strings.Contains(val, "--") { @@ -35,7 +35,7 @@ func validReplicationInstanceID(v interface{}, k string) (ws []string, es []erro if len(val) > 63 { es = append(es, fmt.Errorf("%q must not be longer than 63 characters", k)) } - if !regexache.MustCompile("^[a-zA-Z][a-zA-Z0-9-]+$").MatchString(val) { + if !regexache.MustCompile("^[A-Za-z][0-9A-Za-z-]+$").MatchString(val) { es = append(es, fmt.Errorf("%q must start with a letter, only contain alphanumeric characters and hyphens", k)) } if strings.Contains(val, "--") { @@ -57,7 +57,7 @@ func validReplicationSubnetGroupID(v interface{}, k string) (ws []string, es []e if len(val) > 255 { es = append(es, fmt.Errorf("%q must not be longer than 255 characters", k)) } - if !regexache.MustCompile(`^[a-zA-Z0-9. _-]+$`).MatchString(val) { + if !regexache.MustCompile(`^[0-9A-Za-z_ .-]+$`).MatchString(val) { es = append(es, fmt.Errorf("%q must only contain alphanumeric characters, periods, spaces, underscores and hyphens", k)) } @@ -70,7 +70,7 @@ func validReplicationTaskID(v interface{}, k string) (ws []string, es []error) { if len(val) > 255 { es = append(es, fmt.Errorf("%q must not be longer than 255 characters", k)) } - if !regexache.MustCompile("^[a-zA-Z][a-zA-Z0-9-]+$").MatchString(val) { + if !regexache.MustCompile("^[A-Za-z][0-9A-Za-z-]+$").MatchString(val) { es = append(es, fmt.Errorf("%q must start with a letter, only contain alphanumeric characters and hyphens", k)) } if strings.Contains(val, "--") { diff --git a/internal/service/docdb/validate.go b/internal/service/docdb/validate.go index b7b7709f4816..76b8e5f45ee1 100644 --- a/internal/service/docdb/validate.go +++ b/internal/service/docdb/validate.go @@ -171,7 +171,7 @@ func validParamGroupNamePrefix(v interface{}, k string) (ws []string, errors []e func validSubnetGroupName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[ .0-9a-z-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9a-z_ .-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } @@ -188,7 +188,7 @@ func validSubnetGroupName(v interface{}, k string) (ws []string, errors []error) func validSubnetGroupNamePrefix(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[ .0-9a-z-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9a-z_ .-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } diff --git a/internal/service/ds/validate.go b/internal/service/ds/validate.go index 26489f9e8301..b8ea7d7f0dbc 100644 --- a/internal/service/ds/validate.go +++ b/internal/service/ds/validate.go @@ -13,8 +13,8 @@ import ( var ( directoryIDRegex = regexache.MustCompile(`^d-[0-9a-f]{10}$`) - domain = regexache.MustCompile(`^([a-zA-Z0-9]+[\\.-])+([a-zA-Z0-9])+$`) - domainWithTrailingDot = regexache.MustCompile(`^([a-zA-Z0-9]+[\\.-])+([a-zA-Z0-9])+[.]?$`) + domain = regexache.MustCompile(`^([0-9A-Za-z]+[\\.-])+([0-9A-Za-z])+$`) + domainWithTrailingDot = regexache.MustCompile(`^([0-9A-Za-z]+[\\.-])+([0-9A-Za-z])+[.]?$`) ) var directoryIDValidator validator.String = stringvalidator.RegexMatches(directoryIDRegex, "must be a valid Directory Service Directory ID") diff --git a/internal/service/dynamodb/global_table_test.go b/internal/service/dynamodb/global_table_test.go index 15a352bc88d8..8b9778422406 100644 --- a/internal/service/dynamodb/global_table_test.go +++ b/internal/service/dynamodb/global_table_test.go @@ -51,7 +51,7 @@ func TestAccDynamoDBGlobalTable_basic(t *testing.T) { Config: testAccGlobalTableConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGlobalTableExists(ctx, resourceName), - acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "dynamodb", regexache.MustCompile("global-table/[a-z0-9-]+$")), + acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "dynamodb", regexache.MustCompile("global-table/[0-9a-z-]+$")), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "replica.#", "1"), ), @@ -84,7 +84,7 @@ func TestAccDynamoDBGlobalTable_multipleRegions(t *testing.T) { Config: testAccGlobalTableConfig_multipleRegions1(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGlobalTableExists(ctx, resourceName), - acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "dynamodb", regexache.MustCompile("global-table/[a-z0-9-]+$")), + acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "dynamodb", regexache.MustCompile("global-table/[0-9a-z-]+$")), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "replica.#", "1"), ), diff --git a/internal/service/dynamodb/table_item.go b/internal/service/dynamodb/table_item.go index 13dd35d6a4c1..fae285cb8eee 100644 --- a/internal/service/dynamodb/table_item.go +++ b/internal/service/dynamodb/table_item.go @@ -282,7 +282,7 @@ func BuildExpressionAttributeNames(attrs map[string]*dynamodb.AttributeValue) ma } func cleanKeyName(key string) string { - reg, err := regexp.Compile("[^a-zA-Z]+") + reg, err := regexp.Compile("[A-Za-z^]+") // suspect regexp if err != nil { log.Printf("[ERROR] clean keyname errored %v", err) } diff --git a/internal/service/dynamodb/validate.go b/internal/service/dynamodb/validate.go index 4bd655dd1657..975c23d4b364 100644 --- a/internal/service/dynamodb/validate.go +++ b/internal/service/dynamodb/validate.go @@ -17,7 +17,7 @@ func validGlobalTableName(v interface{}, k string) (ws []string, errors []error) if (len(value) > 255) || (len(value) < 3) { errors = append(errors, fmt.Errorf("%s length must be between 3 and 255 characters: %q", k, value)) } - pattern := `^[a-zA-Z0-9_.-]+$` + pattern := `^[0-9A-Za-z_.-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf("%s must only include alphanumeric, underscore, period, or hyphen characters: %q", k, value)) } diff --git a/internal/service/ec2/ec2_availability_zone_data_source_test.go b/internal/service/ec2/ec2_availability_zone_data_source_test.go index b8eaaa081a4f..d32191e99fa2 100644 --- a/internal/service/ec2/ec2_availability_zone_data_source_test.go +++ b/internal/service/ec2/ec2_availability_zone_data_source_test.go @@ -90,7 +90,7 @@ func TestAccEC2AvailabilityZoneDataSource_localZone(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(dataSourceName, "group_name"), resource.TestCheckResourceAttrPair(dataSourceName, "name", availabilityZonesDataSourceName, "names.0"), - resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[a-z0-9][a-z0-9-]+$`)), + resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[0-9a-z][0-9a-z-]+$`)), resource.TestCheckResourceAttrSet(dataSourceName, "network_border_group"), resource.TestCheckResourceAttr(dataSourceName, "opt_in_status", ec2.AvailabilityZoneOptInStatusOptedIn), resource.TestCheckResourceAttrSet(dataSourceName, "parent_zone_id"), @@ -148,7 +148,7 @@ func TestAccEC2AvailabilityZoneDataSource_wavelengthZone(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(dataSourceName, "group_name"), resource.TestCheckResourceAttrPair(dataSourceName, "name", availabilityZonesDataSourceName, "names.0"), - resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[a-z0-9][a-z0-9-]+$`)), + resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[0-9a-z][0-9a-z-]+$`)), resource.TestCheckResourceAttrSet(dataSourceName, "network_border_group"), resource.TestCheckResourceAttr(dataSourceName, "opt_in_status", ec2.AvailabilityZoneOptInStatusOptedIn), resource.TestCheckResourceAttrSet(dataSourceName, "parent_zone_id"), diff --git a/internal/service/ec2/ec2_instance_test.go b/internal/service/ec2/ec2_instance_test.go index 178049caa20d..a05cefe68efd 100644 --- a/internal/service/ec2/ec2_instance_test.go +++ b/internal/service/ec2/ec2_instance_test.go @@ -204,7 +204,7 @@ func TestAccEC2Instance_basic(t *testing.T) { Config: testAccInstanceConfig_basic(), Check: resource.ComposeTestCheckFunc( testAccCheckInstanceExists(ctx, resourceName, &v), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "ec2", regexache.MustCompile(`instance/i-[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "ec2", regexache.MustCompile(`instance/i-[0-9a-z]+`)), resource.TestCheckResourceAttr(resourceName, "instance_initiated_shutdown_behavior", "stop"), ), }, @@ -371,7 +371,7 @@ func TestAccEC2Instance_atLeastOneOtherEBSVolume(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "root_block_device.#", "0"), // This is an instance store AMI resource.TestCheckResourceAttr(resourceName, "ebs_block_device.#", "0"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "ec2", regexache.MustCompile(`instance/i-[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "ec2", regexache.MustCompile(`instance/i-[0-9a-z]+`)), ), }, { @@ -782,7 +782,7 @@ func TestAccEC2Instance_blockDevices(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckInstanceExists(ctx, resourceName, &v), resource.TestCheckResourceAttr(resourceName, "root_block_device.#", "1"), - resource.TestMatchResourceAttr(resourceName, "root_block_device.0.volume_id", regexache.MustCompile("vol-[a-z0-9]+")), + resource.TestMatchResourceAttr(resourceName, "root_block_device.0.volume_id", regexache.MustCompile("vol-[0-9a-z]+")), resource.TestCheckResourceAttr(resourceName, "root_block_device.0.volume_size", rootVolumeSize), resource.TestCheckResourceAttr(resourceName, "root_block_device.0.volume_type", "gp2"), resource.TestCheckResourceAttr(resourceName, "ebs_block_device.#", "5"), @@ -792,7 +792,7 @@ func TestAccEC2Instance_blockDevices(t *testing.T) { "volume_type": "gp2", }), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "ebs_block_device.*", map[string]*regexp.Regexp{ - "volume_id": regexache.MustCompile("vol-[a-z0-9]+"), + "volume_id": regexache.MustCompile("vol-[0-9a-z]+"), }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "ebs_block_device.*", map[string]string{ "device_name": "/dev/sdc", @@ -814,7 +814,7 @@ func TestAccEC2Instance_blockDevices(t *testing.T) { "iops": "4000", }), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "ebs_block_device.*", map[string]*regexp.Regexp{ - "volume_id": regexache.MustCompile("vol-[a-z0-9]+"), + "volume_id": regexache.MustCompile("vol-[0-9a-z]+"), }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "ebs_block_device.*", map[string]string{ "device_name": "/dev/sdd", @@ -822,7 +822,7 @@ func TestAccEC2Instance_blockDevices(t *testing.T) { "volume_size": "12", }), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "ebs_block_device.*", map[string]*regexp.Regexp{ - "volume_id": regexache.MustCompile("vol-[a-z0-9]+"), + "volume_id": regexache.MustCompile("vol-[0-9a-z]+"), }), resource.TestCheckResourceAttr(resourceName, "ephemeral_block_device.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "ephemeral_block_device.*", map[string]string{ diff --git a/internal/service/ec2/ec2_key_pair_test.go b/internal/service/ec2/ec2_key_pair_test.go index 782ee3889b72..778bf4b8337c 100644 --- a/internal/service/ec2/ec2_key_pair_test.go +++ b/internal/service/ec2/ec2_key_pair_test.go @@ -41,7 +41,7 @@ func TestAccEC2KeyPair_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckKeyPairExists(ctx, resourceName, &keyPair), acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "ec2", fmt.Sprintf("key-pair/%s", rName)), - resource.TestMatchResourceAttr(resourceName, "fingerprint", regexache.MustCompile(`[a-f0-9]{2}(:[a-f0-9]{2}){15}`)), + resource.TestMatchResourceAttr(resourceName, "fingerprint", regexache.MustCompile(`[0-9a-f]{2}(:[0-9a-f]{2}){15}`)), resource.TestCheckResourceAttr(resourceName, "key_name", rName), resource.TestCheckResourceAttr(resourceName, "key_name_prefix", ""), resource.TestCheckResourceAttr(resourceName, "public_key", publicKey), diff --git a/internal/service/ec2/ec2_spot_fleet_request_test.go b/internal/service/ec2/ec2_spot_fleet_request_test.go index 645d385a6748..3d956825fb91 100644 --- a/internal/service/ec2/ec2_spot_fleet_request_test.go +++ b/internal/service/ec2/ec2_spot_fleet_request_test.go @@ -1911,7 +1911,7 @@ func testAccCheckSpotFleetRequest_IAMInstanceProfileARN(sfr *ec2.SpotFleetReques return fmt.Errorf("Expected IamInstanceProfile to be set, got nil") } //Validate the string whether it is ARN - re := regexache.MustCompile(fmt.Sprintf(`arn:%s:iam::\d{12}:instance-profile/?[a-zA-Z0-9+=,.@-_].*`, acctest.Partition())) + re := regexache.MustCompile(fmt.Sprintf(`arn:%s:iam::\d{12}:instance-profile/?[0-9A-Za-z_+=,.@-].*`, acctest.Partition())) if !re.MatchString(*profile.Arn) { return fmt.Errorf("Expected IamInstanceProfile input as ARN, got %s", *profile.Arn) } diff --git a/internal/service/ec2/ipam_pool_cidr_allocation_test.go b/internal/service/ec2/ipam_pool_cidr_allocation_test.go index 66b7295c2aa5..55fdab7e34ef 100644 --- a/internal/service/ec2/ipam_pool_cidr_allocation_test.go +++ b/internal/service/ec2/ipam_pool_cidr_allocation_test.go @@ -38,8 +38,8 @@ func TestAccIPAMPoolCIDRAllocation_ipv4Basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckIPAMPoolCIDRAllocationExists(ctx, resourceName, &allocation), resource.TestCheckResourceAttr(resourceName, "cidr", cidr), - resource.TestMatchResourceAttr(resourceName, "id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+_ipam-pool(-[\da-f]+)$`)), - resource.TestMatchResourceAttr(resourceName, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+$`)), + resource.TestMatchResourceAttr(resourceName, "id", regexache.MustCompile(`^ipam-pool-alloc-[0-9a-f]+_ipam-pool(-[0-9a-f]+)$`)), + resource.TestMatchResourceAttr(resourceName, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[0-9a-f]+$`)), resource.TestCheckResourceAttrPair(resourceName, "ipam_pool_id", "aws_vpc_ipam_pool.test", "id"), ), }, @@ -155,12 +155,12 @@ func TestAccIPAMPoolCIDRAllocation_multiple(t *testing.T) { testAccCheckIPAMPoolCIDRAllocationExists(ctx, resourceName, &allocation1), testAccCheckIPAMPoolCIDRAllocationExists(ctx, resourceName2, &allocation2), resource.TestCheckResourceAttr(resourceName, "cidr", cidr1), - resource.TestMatchResourceAttr(resourceName, "id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+_ipam-pool(-[\da-f]+)$`)), - resource.TestMatchResourceAttr(resourceName, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+$`)), + resource.TestMatchResourceAttr(resourceName, "id", regexache.MustCompile(`^ipam-pool-alloc-[a-f\d]+_ipam-pool(-[a-f\d]+)$`)), + resource.TestMatchResourceAttr(resourceName, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[a-f\d]+$`)), resource.TestCheckResourceAttrPair(resourceName, "ipam_pool_id", "aws_vpc_ipam_pool.test", "id"), resource.TestCheckResourceAttr(resourceName2, "cidr", cidr2), - resource.TestMatchResourceAttr(resourceName2, "id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+_ipam-pool(-[\da-f]+)$`)), - resource.TestMatchResourceAttr(resourceName2, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+$`)), + resource.TestMatchResourceAttr(resourceName2, "id", regexache.MustCompile(`^ipam-pool-alloc-[a-f\d]+_ipam-pool(-[a-f\d]+)$`)), + resource.TestMatchResourceAttr(resourceName2, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[a-f\d]+$`)), resource.TestCheckResourceAttrPair(resourceName2, "ipam_pool_id", "aws_vpc_ipam_pool.test", "id"), ), }, @@ -199,8 +199,8 @@ func TestAccIPAMPoolCIDRAllocation_differentRegion(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckIPAMPoolCIDRAllocationExistsWithProvider(ctx, resourceName, &allocation, acctest.RegionProviderFunc(acctest.AlternateRegion(), &providers)), resource.TestCheckResourceAttr(resourceName, "cidr", cidr), - resource.TestMatchResourceAttr(resourceName, "id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+_ipam-pool(-[\da-f]+)$`)), - resource.TestMatchResourceAttr(resourceName, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[\da-f]+$`)), + resource.TestMatchResourceAttr(resourceName, "id", regexache.MustCompile(`^ipam-pool-alloc-[a-f\d]+_ipam-pool(-[a-f\d]+)$`)), + resource.TestMatchResourceAttr(resourceName, "ipam_pool_allocation_id", regexache.MustCompile(`^ipam-pool-alloc-[a-f\d]+$`)), resource.TestCheckResourceAttrPair(resourceName, "ipam_pool_id", "aws_vpc_ipam_pool.test", "id"), ), }, diff --git a/internal/service/ec2/ipam_resource_discovery_association_test.go b/internal/service/ec2/ipam_resource_discovery_association_test.go index 1ef9c8549d1e..64c9569e43f7 100644 --- a/internal/service/ec2/ipam_resource_discovery_association_test.go +++ b/internal/service/ec2/ipam_resource_discovery_association_test.go @@ -35,7 +35,7 @@ func testAccIPAMResourceDiscoveryAssociation_basic(t *testing.T) { Config: testAccIPAMResourceDiscoveryAssociationConfig_basic(), Check: resource.ComposeTestCheckFunc( testAccCheckIPAMResourceDiscoveryAssociationExists(ctx, resourceName, &rda), - acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "ec2", regexache.MustCompile(`ipam-resource-discovery-association/ipam-res-disco-assoc-[\da-f]+$`)), + acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "ec2", regexache.MustCompile(`ipam-resource-discovery-association/ipam-res-disco-assoc-[0-9a-f]+$`)), resource.TestCheckResourceAttrPair(resourceName, "ipam_id", ipamName, "id"), resource.TestCheckResourceAttrPair(resourceName, "ipam_resource_discovery_id", rdName, "id"), acctest.CheckResourceAttrAccountID(resourceName, "owner_id"), diff --git a/internal/service/ec2/ipam_resource_discovery_test.go b/internal/service/ec2/ipam_resource_discovery_test.go index cc1e23221c57..de737a75d1af 100644 --- a/internal/service/ec2/ipam_resource_discovery_test.go +++ b/internal/service/ec2/ipam_resource_discovery_test.go @@ -54,7 +54,7 @@ func testAccIPAMResourceDiscovery_basic(t *testing.T) { Config: testAccIPAMResourceDiscoveryConfig_base, Check: resource.ComposeTestCheckFunc( testAccCheckIPAMResourceDiscoveryExists(ctx, resourceName, &rd), - acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "ec2", regexache.MustCompile(`ipam-resource-discovery/ipam-res-disco-[\da-f]+$`)), + acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "ec2", regexache.MustCompile(`ipam-resource-discovery/ipam-res-disco-[0-9a-f]+$`)), resource.TestCheckResourceAttr(resourceName, "description", "test"), resource.TestCheckResourceAttrPair(resourceName, "ipam_resource_discovery_region", dataSourceRegion, "name"), resource.TestCheckResourceAttr(resourceName, "is_default", "false"), diff --git a/internal/service/ec2/ipam_test.go b/internal/service/ec2/ipam_test.go index 457570852b29..9736ced00b33 100644 --- a/internal/service/ec2/ipam_test.go +++ b/internal/service/ec2/ipam_test.go @@ -39,10 +39,10 @@ func TestAccIPAM_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "description", ""), resource.TestCheckResourceAttr(resourceName, "operating_regions.#", "1"), resource.TestCheckResourceAttr(resourceName, "scope_count", "2"), - resource.TestMatchResourceAttr(resourceName, "private_default_scope_id", regexache.MustCompile(`^ipam-scope-[\da-f]+`)), - resource.TestMatchResourceAttr(resourceName, "public_default_scope_id", regexache.MustCompile(`^ipam-scope-[\da-f]+`)), - resource.TestMatchResourceAttr(resourceName, "default_resource_discovery_association_id", regexache.MustCompile(`^ipam-res-disco-assoc-[\da-f]+`)), - resource.TestMatchResourceAttr(resourceName, "default_resource_discovery_id", regexache.MustCompile(`^ipam-res-disco-[\da-f]+`)), + resource.TestMatchResourceAttr(resourceName, "private_default_scope_id", regexache.MustCompile(`^ipam-scope-[0-9a-f]+`)), + resource.TestMatchResourceAttr(resourceName, "public_default_scope_id", regexache.MustCompile(`^ipam-scope-[0-9a-f]+`)), + resource.TestMatchResourceAttr(resourceName, "default_resource_discovery_association_id", regexache.MustCompile(`^ipam-res-disco-assoc-[0-9a-f]+`)), + resource.TestMatchResourceAttr(resourceName, "default_resource_discovery_id", regexache.MustCompile(`^ipam-res-disco-[0-9a-f]+`)), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, diff --git a/internal/service/ec2/validate.go b/internal/service/ec2/validate.go index 264918213702..a3ad8d85123a 100644 --- a/internal/service/ec2/validate.go +++ b/internal/service/ec2/validate.go @@ -19,7 +19,7 @@ func validSecurityGroupRuleDescription(v interface{}, k string) (ws []string, er // https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_IpRange.html. Note that // "" is an allowable description value. - pattern := `^[A-Za-z0-9 \.\_\-\:\/\(\)\#\,\@\[\]\+\=\&\;\{\}\!\$\*]*$` + pattern := `^[0-9A-Za-z_ .:/()#,@\[\]+=&;{}!$*-]*$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q doesn't comply with restrictions (%q): %q", diff --git a/internal/service/ec2/vpnclient_network_association_test.go b/internal/service/ec2/vpnclient_network_association_test.go index 6cdbb56dce3c..e45f4a68f0ea 100644 --- a/internal/service/ec2/vpnclient_network_association_test.go +++ b/internal/service/ec2/vpnclient_network_association_test.go @@ -38,7 +38,7 @@ func testAccClientVPNNetworkAssociation_basic(t *testing.T) { Config: testAccClientVPNNetworkAssociationConfig_basic(t, rName), Check: resource.ComposeTestCheckFunc( testAccCheckClientVPNNetworkAssociationExists(ctx, resourceName, &assoc), - resource.TestMatchResourceAttr(resourceName, "association_id", regexache.MustCompile("^cvpn-assoc-[a-z0-9]+$")), + resource.TestMatchResourceAttr(resourceName, "association_id", regexache.MustCompile("^cvpn-assoc-[0-9a-z]+$")), resource.TestCheckResourceAttrPair(resourceName, "id", resourceName, "association_id"), resource.TestCheckResourceAttrPair(resourceName, "client_vpn_endpoint_id", endpointResourceName, "id"), resource.TestCheckResourceAttrPair(resourceName, "subnet_id", subnetResourceName, "id"), @@ -74,8 +74,8 @@ func testAccClientVPNNetworkAssociation_multipleSubnets(t *testing.T) { Config: testAccClientVPNNetworkAssociationConfig_multipleSubnets(t, rName), Check: resource.ComposeTestCheckFunc( testAccCheckClientVPNNetworkAssociationExists(ctx, resourceNames[0], &assoc), - resource.TestMatchResourceAttr(resourceNames[0], "association_id", regexache.MustCompile("^cvpn-assoc-[a-z0-9]+$")), - resource.TestMatchResourceAttr(resourceNames[1], "association_id", regexache.MustCompile("^cvpn-assoc-[a-z0-9]+$")), + resource.TestMatchResourceAttr(resourceNames[0], "association_id", regexache.MustCompile("^cvpn-assoc-[0-9a-z]+$")), + resource.TestMatchResourceAttr(resourceNames[1], "association_id", regexache.MustCompile("^cvpn-assoc-[0-9a-z]+$")), resource.TestCheckResourceAttrPair(resourceNames[0], "id", resourceNames[0], "association_id"), resource.TestCheckResourceAttrPair(resourceNames[0], "client_vpn_endpoint_id", endpointResourceName, "id"), resource.TestCheckResourceAttrPair(resourceNames[0], "subnet_id", subnetResourceNames[0], "id"), diff --git a/internal/service/ec2/vpnsite_connection.go b/internal/service/ec2/vpnsite_connection.go index 99ab79f47fe1..ed816741103a 100644 --- a/internal/service/ec2/vpnsite_connection.go +++ b/internal/service/ec2/vpnsite_connection.go @@ -1672,7 +1672,7 @@ func validVPNConnectionTunnelPreSharedKey() schema.SchemaValidateFunc { return validation.All( validation.StringLenBetween(8, 64), validation.StringDoesNotMatch(regexache.MustCompile(`^0`), "cannot start with zero character"), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z_.]+$`), "can only contain alphanumeric, period and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.]+$`), "can only contain alphanumeric, period and underscore characters"), ) } diff --git a/internal/service/ecr/pull_through_cache_rule.go b/internal/service/ecr/pull_through_cache_rule.go index 8afcb665d27f..de356d55963d 100644 --- a/internal/service/ecr/pull_through_cache_rule.go +++ b/internal/service/ecr/pull_through_cache_rule.go @@ -37,7 +37,7 @@ func ResourcePullThroughCacheRule() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(2, 20), validation.StringMatch( - regexache.MustCompile(`^[a-z0-9]+(?:[._-][a-z0-9]+)*$`), + regexache.MustCompile(`^[0-9a-z]+(?:[._-][0-9a-z]+)*$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, diff --git a/internal/service/ecr/pull_through_cache_rule_data_source.go b/internal/service/ecr/pull_through_cache_rule_data_source.go index e524852a4612..65bd84917545 100644 --- a/internal/service/ecr/pull_through_cache_rule_data_source.go +++ b/internal/service/ecr/pull_through_cache_rule_data_source.go @@ -26,7 +26,7 @@ func DataSourcePullThroughCacheRule() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(2, 20), validation.StringMatch( - regexache.MustCompile(`^[a-z0-9]+(?:[._-][a-z0-9]+)*$`), + regexache.MustCompile(`^[0-9a-z]+(?:[._-][0-9a-z]+)*$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, diff --git a/internal/service/ecr/registry_scanning_configuration.go b/internal/service/ecr/registry_scanning_configuration.go index 302db9232804..54a36925d27a 100644 --- a/internal/service/ecr/registry_scanning_configuration.go +++ b/internal/service/ecr/registry_scanning_configuration.go @@ -51,7 +51,7 @@ func ResourceRegistryScanningConfiguration() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9*](?:[._\-/a-z0-9*]?[a-z0-9*]+)*$`), "must contain only lowercase alphanumeric, dot, underscore, hyphen, wildcard, and colon characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z*](?:[0-9a-z_./*-]?[0-9a-z*]+)*$`), "must contain only lowercase alphanumeric, dot, underscore, hyphen, wildcard, and colon characters"), ), }, "filter_type": { diff --git a/internal/service/ecrpublic/repository.go b/internal/service/ecrpublic/repository.go index 23d7f76b9d27..9696fe6f1f08 100644 --- a/internal/service/ecrpublic/repository.go +++ b/internal/service/ecrpublic/repository.go @@ -52,7 +52,7 @@ func ResourceRepository() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 205), - validation.StringMatch(regexache.MustCompile(`(?:[a-z0-9]+(?:[._-][a-z0-9]+)*/)*[a-z0-9]+(?:[._-][a-z0-9]+)*`), "see: https://docs.aws.amazon.com/AmazonECRPublic/latest/APIReference/API_CreateRepository.html#API_CreateRepository_RequestSyntax"), + validation.StringMatch(regexache.MustCompile(`(?:[0-9a-z]+(?:[._-][0-9a-z]+)*/)*[0-9a-z]+(?:[._-][0-9a-z]+)*`), "see: https://docs.aws.amazon.com/AmazonECRPublic/latest/APIReference/API_CreateRepository.html#API_CreateRepository_RequestSyntax"), ), }, "catalog_data": { diff --git a/internal/service/ecs/validate.go b/internal/service/ecs/validate.go index d7810ea1ec04..7b0abc85fbb7 100644 --- a/internal/service/ecs/validate.go +++ b/internal/service/ecs/validate.go @@ -14,7 +14,7 @@ func validateClusterName(v interface{}, k string) (ws []string, errors []error) return validation.All( validation.StringLenBetween(1, 255), validation.StringMatch( - regexache.MustCompile("[a-zA-Z0-9_-]+"), + regexache.MustCompile("[0-9A-Za-z_-]+"), "The cluster name must consist of alphanumerics, hyphens, and underscores."), )(v, k) } diff --git a/internal/service/eks/addon.go b/internal/service/eks/addon.go index 10a170b4d920..ab089032a259 100644 --- a/internal/service/eks/addon.go +++ b/internal/service/eks/addon.go @@ -58,7 +58,7 @@ func ResourceAddon() *schema.Resource { Computed: true, ValidateFunc: validation.All( // Regular expression taken from: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string - validation.StringMatch(regexache.MustCompile(`^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`), "must follow semantic version format"), + validation.StringMatch(regexache.MustCompile(`^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$`), "must follow semantic version format"), ), }, "arn": { diff --git a/internal/service/eks/cluster_test.go b/internal/service/eks/cluster_test.go index 31350a3fe75a..f4a8e94dae87 100644 --- a/internal/service/eks/cluster_test.go +++ b/internal/service/eks/cluster_test.go @@ -640,7 +640,7 @@ func TestAccEKSCluster_Outpost_create(t *testing.T) { Config: testAccClusterConfig_outpost(rName), Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &cluster), - resource.TestMatchResourceAttr(resourceName, "cluster_id", regexache.MustCompile(`^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$`)), + resource.TestMatchResourceAttr(resourceName, "cluster_id", regexache.MustCompile(`^[0-9A-Fa-f]{8}\b-[0-9A-Fa-f]{4}\b-[0-9A-Fa-f]{4}\b-[0-9A-Fa-f]{4}\b-[0-9A-Fa-f]{12}$`)), resource.TestCheckResourceAttr(resourceName, "outpost_config.#", "1"), resource.TestCheckResourceAttr(resourceName, "outpost_config.0.control_plane_instance_type", controlPlaneInstanceType), resource.TestCheckResourceAttr(resourceName, "outpost_config.0.outpost_arns.#", "1"), @@ -672,7 +672,7 @@ func TestAccEKSCluster_Outpost_placement(t *testing.T) { Config: testAccClusterConfig_outpostPlacement(rName), Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &cluster), - resource.TestMatchResourceAttr(resourceName, "cluster_id", regexache.MustCompile(`^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$`)), + resource.TestMatchResourceAttr(resourceName, "cluster_id", regexache.MustCompile(`^[0-9A-Fa-f]{8}\b-[0-9A-Fa-f]{4}\b-[0-9A-Fa-f]{4}\b-[0-9A-Fa-f]{4}\b-[0-9A-Fa-f]{12}$`)), resource.TestCheckResourceAttr(resourceName, "outpost_config.#", "1"), resource.TestCheckResourceAttr(resourceName, "outpost_config.0.control_plane_instance_type", controlPlaneInstanceType), resource.TestCheckResourceAttr(resourceName, "outpost_config.0.outpost_arns.#", "1"), diff --git a/internal/service/eks/validate.go b/internal/service/eks/validate.go index 1d39d69a35b4..9195a044cbbe 100644 --- a/internal/service/eks/validate.go +++ b/internal/service/eks/validate.go @@ -17,7 +17,7 @@ func validClusterName(v interface{}, k string) (ws []string, errors []error) { } // https://docs.aws.amazon.com/eks/latest/APIReference/API_CreateCluster.html#API_CreateCluster_RequestSyntax - pattern := `^[0-9A-Za-z][A-Za-z0-9\-_]+$` + pattern := `^[0-9A-Za-z][0-9A-Za-z_-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q doesn't comply with restrictions (%q): %q", diff --git a/internal/service/elasticache/replication_group.go b/internal/service/elasticache/replication_group.go index e03a87ba8695..abbad7790bdb 100644 --- a/internal/service/elasticache/replication_group.go +++ b/internal/service/elasticache/replication_group.go @@ -1107,8 +1107,8 @@ func decreaseReplicationGroupNumCacheClusters(ctx context.Context, conn *elastic var validateReplicationGroupID schema.SchemaValidateFunc = validation.All( validation.StringLenBetween(1, 40), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z-]+$`), "must contain only alphanumeric characters and hyphens"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with a letter"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric characters and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with a letter"), validation.StringDoesNotMatch(regexache.MustCompile(`--`), "cannot contain two consecutive hyphens"), validation.StringDoesNotMatch(regexache.MustCompile(`-$`), "cannot end with a hyphen"), ) diff --git a/internal/service/elasticbeanstalk/environment_test.go b/internal/service/elasticbeanstalk/environment_test.go index 3b18de9f9eb9..1b0d82ce36cf 100644 --- a/internal/service/elasticbeanstalk/environment_test.go +++ b/internal/service/elasticbeanstalk/environment_test.go @@ -30,7 +30,7 @@ func TestAccElasticBeanstalkEnvironment_basic(t *testing.T) { resourceName := "aws_elastic_beanstalk_environment.test" beanstalkAsgNameRegexp := regexache.MustCompile("awseb.+?AutoScalingGroup[^,]+") beanstalkElbNameRegexp := regexache.MustCompile("awseb.+?EBLoa[^,]+") - beanstalkInstancesNameRegexp := regexache.MustCompile("i-([0-9a-fA-F]{8}|[0-9a-fA-F]{17})") + beanstalkInstancesNameRegexp := regexache.MustCompile("i-([0-9A-Fa-f]{8}|[0-9A-Fa-f]{17})") beanstalkLcNameRegexp := regexache.MustCompile("awseb.+?AutoScalingLaunch[^,]+") beanstalkEndpointURL := regexache.MustCompile("awseb.+?EBLoa[^,].+?elb.amazonaws.com") diff --git a/internal/service/elastictranscoder/pipeline.go b/internal/service/elastictranscoder/pipeline.go index 33668ebb439c..0ea2fba8bdba 100644 --- a/internal/service/elastictranscoder/pipeline.go +++ b/internal/service/elastictranscoder/pipeline.go @@ -117,7 +117,7 @@ func ResourcePipeline() *schema.Resource { Computed: true, ForceNew: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[.0-9A-Za-z-_]+$`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "only alphanumeric characters, hyphens, underscores, and periods allowed"), validation.StringLenBetween(1, 40), ), diff --git a/internal/service/elbv2/listener_rule.go b/internal/service/elbv2/listener_rule.go index c8b31953a907..8b553cc30cec 100644 --- a/internal/service/elbv2/listener_rule.go +++ b/internal/service/elbv2/listener_rule.go @@ -385,7 +385,7 @@ func ResourceListenerRule() *schema.Resource { "http_header_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile("^[A-Za-z0-9!#$%&'*+-.^_`|~]{1,40}$"), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile("^[0-9A-Za-z_!#$%&'*+.^`|~-]{1,40}$"), ""), }, "values": { Type: schema.TypeSet, diff --git a/internal/service/elbv2/load_balancer_test.go b/internal/service/elbv2/load_balancer_test.go index e9e179b309c6..b8b5a3d7ba45 100644 --- a/internal/service/elbv2/load_balancer_test.go +++ b/internal/service/elbv2/load_balancer_test.go @@ -218,7 +218,7 @@ func TestAccELBV2LoadBalancer_ipv6SubnetMapping(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckLoadBalancerExists(ctx, resourceName, &conf), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "subnet_mapping.*", map[string]*regexp.Regexp{ - "ipv6_address": regexache.MustCompile("[a-f0-6]+:[a-f0-6:]+"), + "ipv6_address": regexache.MustCompile("[0-6a-f]+:[0-6a-f:]+"), }), ), }, diff --git a/internal/service/emr/id.go b/internal/service/emr/id.go index 5208463047fa..49a78482b735 100644 --- a/internal/service/emr/id.go +++ b/internal/service/emr/id.go @@ -10,7 +10,7 @@ import ( "github.com/YakDriver/regexache" ) -const IdentityIdPattern = `([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}` +const IdentityIdPattern = `([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}` var IdentityIdPatternRegexp = regexache.MustCompile(IdentityIdPattern) diff --git a/internal/service/emr/validate.go b/internal/service/emr/validate.go index f0c46f19272f..8e0e4fd979a4 100644 --- a/internal/service/emr/validate.go +++ b/internal/service/emr/validate.go @@ -17,9 +17,9 @@ func validCustomAMIID(v interface{}, k string) (ws []string, errors []error) { errors = append(errors, fmt.Errorf("%q cannot be longer than 256 characters", k)) } - if !regexache.MustCompile(`^ami\-[a-z0-9]+$`).MatchString(value) { + if !regexache.MustCompile(`^ami\-[0-9a-z]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( - "%q must begin with 'ami-' and be comprised of only [a-z0-9]: %v", k, value)) + "%q must begin with 'ami-' and be comprised of only [0-9a-z]: %v", k, value)) } return diff --git a/internal/service/emrcontainers/job_template.go b/internal/service/emrcontainers/job_template.go index 05d842e990e5..62888b45c927 100644 --- a/internal/service/emrcontainers/job_template.go +++ b/internal/service/emrcontainers/job_template.go @@ -245,7 +245,7 @@ func ResourceJobTemplate() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`[.\-_/#A-Za-z0-9]+`), "must contain only alphanumeric, hyphen, underscore, dot and # characters"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_./#-]+`), "must contain only alphanumeric, hyphen, underscore, dot and # characters"), ), }, names.AttrTags: tftags.TagsSchemaForceNew(), diff --git a/internal/service/emrcontainers/virtual_cluster.go b/internal/service/emrcontainers/virtual_cluster.go index 061a9ffdb6f9..057c7aab5c9b 100644 --- a/internal/service/emrcontainers/virtual_cluster.go +++ b/internal/service/emrcontainers/virtual_cluster.go @@ -99,7 +99,7 @@ func ResourceVirtualCluster() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`[.\-_/#A-Za-z0-9]+`), "must contain only alphanumeric, hyphen, underscore, dot and # characters"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_./#-]+`), "must contain only alphanumeric, hyphen, underscore, dot and # characters"), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/events/api_destination.go b/internal/service/events/api_destination.go index db4d59db95bd..33f9a8ecfcb9 100644 --- a/internal/service/events/api_destination.go +++ b/internal/service/events/api_destination.go @@ -37,7 +37,7 @@ func ResourceAPIDestination() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z0-9]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), ), }, "description": { diff --git a/internal/service/events/api_destination_test.go b/internal/service/events/api_destination_test.go index 71aa28d57151..6f62772dc11a 100644 --- a/internal/service/events/api_destination_test.go +++ b/internal/service/events/api_destination_test.go @@ -19,7 +19,7 @@ import ( tfevents "github.com/hashicorp/terraform-provider-aws/internal/service/events" ) -const uuidRegex = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" +const uuidRegex = "[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$" func TestAccEventsAPIDestination_basic(t *testing.T) { ctx := acctest.Context(t) diff --git a/internal/service/events/connection.go b/internal/service/events/connection.go index 90e12d45c39b..3721f2b2214a 100644 --- a/internal/service/events/connection.go +++ b/internal/service/events/connection.go @@ -109,7 +109,7 @@ func ResourceConnection() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z0-9]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), ), }, "description": { diff --git a/internal/service/events/endpoint.go b/internal/service/events/endpoint.go index 2c65baebef9f..30573df1b7dc 100644 --- a/internal/service/events/endpoint.go +++ b/internal/service/events/endpoint.go @@ -68,7 +68,7 @@ func ResourceEndpoint() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z0-9]{1,64}$`), "Maximum of 64 characters consisting of numbers, lower/upper case letters, .,-,_."), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{1,64}$`), "Maximum of 64 characters consisting of numbers, lower/upper case letters, .,-,_."), }, "replication_config": { Type: schema.TypeList, diff --git a/internal/service/events/id.go b/internal/service/events/id.go index 8da152f26d5f..8d563b11d788 100644 --- a/internal/service/events/id.go +++ b/internal/service/events/id.go @@ -11,8 +11,8 @@ import ( ) var ( - eventBusARNPattern = regexache.MustCompile(`^arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/[\.\-_A-Za-z0-9]+$`) - partnerEventBusPattern = regexache.MustCompile(`^(?:arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?aws\.partner(/[\.\-_A-Za-z0-9]+){2,}$`) + eventBusARNPattern = regexache.MustCompile(`^arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/[0-9A-Za-z_.-]+$`) + partnerEventBusPattern = regexache.MustCompile(`^(?:arn:aws[\w-]*:events:[a-z]{2}-[a-z]+-[\w-]+:[0-9]{12}:event-bus\/)?aws\.partner(/[0-9A-Za-z_.-]+){2,}$`) ) const permissionResourceIDSeparator = "/" diff --git a/internal/service/events/permission.go b/internal/service/events/permission.go index e9464021eac2..6e338084f788 100644 --- a/internal/service/events/permission.go +++ b/internal/service/events/permission.go @@ -269,7 +269,7 @@ func validatePermissionAction(v interface{}, k string) (ws []string, es []error) es = append(es, fmt.Errorf("%q must be between 1 and 64 characters", k)) } - if !regexache.MustCompile(`^events:[a-zA-Z]+$`).MatchString(value) { + if !regexache.MustCompile(`^events:[A-Za-z]+$`).MatchString(value) { es = append(es, fmt.Errorf("%q must be: events: followed by one or more alphabetic characters", k)) } return @@ -291,7 +291,7 @@ func validatePermissionStatementID(v interface{}, k string) (ws []string, es []e es = append(es, fmt.Errorf("%q must be between 1 and 64 characters", k)) } - if !regexache.MustCompile(`^[a-zA-Z0-9-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z_-]+$`).MatchString(value) { es = append(es, fmt.Errorf("%q must be one or more alphanumeric, hyphen, or underscore characters", k)) } return diff --git a/internal/service/events/target.go b/internal/service/events/target.go index c292de2eb89c..1a90ad6e9270 100644 --- a/internal/service/events/target.go +++ b/internal/service/events/target.go @@ -247,7 +247,7 @@ func ResourceTarget() *schema.Resource { Optional: true, ValidateDiagFunc: allDiagFunc( validation.MapKeyLenBetween(0, 512), - validation.MapKeyMatch(regexache.MustCompile(`^[!#$%&'*+-.^_|~0-9a-zA-Z]+$`), ""), + validation.MapKeyMatch(regexache.MustCompile(`^[0-9A-Za-z_!#$%&'*+.^|~-]+$`), ""), validation.MapValueLenBetween(0, 512), validation.MapValueMatch(regexache.MustCompile(`^[ \t]*[\x20-\x7E]+([ \t]+[\x20-\x7E]+)*[ \t]*$`), ""), ), diff --git a/internal/service/events/validate.go b/internal/service/events/validate.go index cc36b146371f..f831bd43f80b 100644 --- a/internal/service/events/validate.go +++ b/internal/service/events/validate.go @@ -23,7 +23,7 @@ func validateRuleName(v interface{}, k string) (ws []string, errors []error) { } // http://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutRule.html - pattern := `^[\.\-_A-Za-z0-9]+$` + pattern := `^[0-9A-Za-z_.-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q doesn't comply with restrictions (%q): %q", @@ -41,7 +41,7 @@ func validateTargetID(v interface{}, k string) (ws []string, errors []error) { } // http://docs.aws.amazon.com/eventbridge/latest/APIReference/API_Target.html - pattern := `^[\.\-_A-Za-z0-9]+$` + pattern := `^[0-9A-Za-z_.-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q doesn't comply with restrictions (%q): %q", diff --git a/internal/service/evidently/feature.go b/internal/service/evidently/feature.go index 1a363cf149d5..2038dff0d934 100644 --- a/internal/service/evidently/feature.go +++ b/internal/service/evidently/feature.go @@ -61,7 +61,7 @@ func ResourceFeature() *schema.Resource { Computed: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "description": { @@ -75,7 +75,7 @@ func ResourceFeature() *schema.Resource { ValidateDiagFunc: validation.AllDiag( validation.MapKeyLenBetween(1, 512), validation.MapValueLenBetween(1, 127), - validation.MapValueMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.MapValueMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), Elem: &schema.Schema{Type: schema.TypeString}, }, @@ -111,7 +111,7 @@ func ResourceFeature() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "project": { @@ -120,7 +120,7 @@ func ResourceFeature() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 2048), - validation.StringMatch(regexache.MustCompile(`(^[a-zA-Z0-9._-]*$)|(arn:[^:]*:[^:]*:[^:]*:[^:]*:project/[a-zA-Z0-9._-]*)`), "name or arn of the project"), + validation.StringMatch(regexache.MustCompile(`(^[0-9A-Za-z_.-]*$)|(arn:[^:]*:[^:]*:[^:]*:[^:]*:project/[0-9A-Za-z._-]*)`), "name or arn of the project"), ), DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { // case 1: User-defined string (old) is a name and is the suffix of API-returned string (new). Check non-empty old in resoure creation scenario @@ -150,7 +150,7 @@ func ResourceFeature() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "value": { diff --git a/internal/service/evidently/launch.go b/internal/service/evidently/launch.go index fdc7fdcb629e..5b141fd3c355 100644 --- a/internal/service/evidently/launch.go +++ b/internal/service/evidently/launch.go @@ -92,7 +92,7 @@ func ResourceLaunch() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "name": { @@ -100,7 +100,7 @@ func ResourceLaunch() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "variation": { @@ -108,7 +108,7 @@ func ResourceLaunch() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, }, @@ -176,7 +176,7 @@ func ResourceLaunch() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "project": { @@ -185,7 +185,7 @@ func ResourceLaunch() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 2048), - validation.StringMatch(regexache.MustCompile(`(^[a-zA-Z0-9._-]*$)|(arn:[^:]*:[^:]*:[^:]*:[^:]*:project/[a-zA-Z0-9._-]*)`), "name or arn of the project"), + validation.StringMatch(regexache.MustCompile(`(^[0-9A-Za-z_.-]*$)|(arn:[^:]*:[^:]*:[^:]*:[^:]*:project/[0-9A-Za-z._-]*)`), "name or arn of the project"), ), DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { // case 1: User-defined string (old) is a name and is the suffix of API-returned string (new). Check non-empty old in resoure creation scenario @@ -220,7 +220,7 @@ func ResourceLaunch() *schema.Resource { Required: true, ValidateDiagFunc: validation.AllDiag( validation.MapKeyLenBetween(1, 127), - validation.MapKeyMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.MapKeyMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), Elem: &schema.Schema{ Type: schema.TypeInt, @@ -243,7 +243,7 @@ func ResourceLaunch() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 2048), - validation.StringMatch(regexache.MustCompile(`(^[a-zA-Z0-9._-]*$)|(arn:[^:]*:[^:]*:[^:]*:[^:]*:segment/[a-zA-Z0-9._-]*)`), "name or arn of the segment"), + validation.StringMatch(regexache.MustCompile(`(^[0-9A-Za-z_.-]*$)|(arn:[^:]*:[^:]*:[^:]*:[^:]*:segment/[0-9A-Za-z._-]*)`), "name or arn of the segment"), ), DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { // case 1: User-defined string (old) is a name and is the suffix of API-returned string (new). Check non-empty old in resoure creation scenario @@ -256,7 +256,7 @@ func ResourceLaunch() *schema.Resource { Required: true, ValidateDiagFunc: validation.AllDiag( validation.MapKeyLenBetween(1, 127), - validation.MapKeyMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.MapKeyMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), Elem: &schema.Schema{ Type: schema.TypeInt, diff --git a/internal/service/evidently/project.go b/internal/service/evidently/project.go index a9708a3dcade..d99dd1001272 100644 --- a/internal/service/evidently/project.go +++ b/internal/service/evidently/project.go @@ -78,7 +78,7 @@ func ResourceProject() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 512), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._/]+$`), "must be a valid CloudWatch Log Group name"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_./-]+$`), "must be a valid CloudWatch Log Group name"), ), }, }, @@ -98,7 +98,7 @@ func ResourceProject() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 63), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9][-a-z0-9]*[a-z0-9]$`), "must be a valid Bucket name"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z][0-9a-z-]*[0-9a-z]$`), "must be a valid Bucket name"), ), }, "prefix": { @@ -106,7 +106,7 @@ func ResourceProject() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 1024), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9!_.*'()/]*$`), "must be a valid prefix name"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_!.*'()/-]*$`), "must be a valid prefix name"), ), }, }, @@ -142,7 +142,7 @@ func ResourceProject() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 127), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "status": { diff --git a/internal/service/evidently/segment.go b/internal/service/evidently/segment.go index 1b1bb8ee4928..ed84722f264e 100644 --- a/internal/service/evidently/segment.go +++ b/internal/service/evidently/segment.go @@ -69,7 +69,7 @@ func ResourceSegment() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[-a-zA-Z0-9._]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "alphanumeric and can contain hyphens, underscores, and periods"), ), }, "pattern": { diff --git a/internal/service/fis/experiment_template.go b/internal/service/fis/experiment_template.go index 1134d29a1bda..fed343de23c3 100644 --- a/internal/service/fis/experiment_template.go +++ b/internal/service/fis/experiment_template.go @@ -62,7 +62,7 @@ func ResourceExperimentTemplate() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 128), - validation.StringMatch(regexache.MustCompile(`^aws:[a-z0-9-]+:[a-zA-Z0-9/-]+$`), "must be in the format of aws:service-name:action-name"), + validation.StringMatch(regexache.MustCompile(`^aws:[0-9a-z-]+:[0-9A-Za-z/-]+$`), "must be in the format of aws:service-name:action-name"), ), }, "description": { diff --git a/internal/service/fsx/windows_file_system.go b/internal/service/fsx/windows_file_system.go index 1f2486e97964..63a07e0e25dd 100644 --- a/internal/service/fsx/windows_file_system.go +++ b/internal/service/fsx/windows_file_system.go @@ -66,7 +66,7 @@ func ResourceWindowsFileSystem() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(4, 253), - // validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9]([.][A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])+$`), "must be in the fqdn format hostname.domain"), + // validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([.][0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z])+$`), "must be in the fqdn format hostname.domain"), ), }, }, diff --git a/internal/service/glacier/vault.go b/internal/service/glacier/vault.go index 32d968648725..e9f1ab6e9896 100644 --- a/internal/service/glacier/vault.go +++ b/internal/service/glacier/vault.go @@ -66,7 +66,7 @@ func resourceVault() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[.0-9A-Za-z-_]+$`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "only alphanumeric characters, hyphens, underscores, and periods are allowed"), ), }, diff --git a/internal/service/globalaccelerator/accelerator_test.go b/internal/service/globalaccelerator/accelerator_test.go index 4074c9bb3548..679252925b77 100644 --- a/internal/service/globalaccelerator/accelerator_test.go +++ b/internal/service/globalaccelerator/accelerator_test.go @@ -26,7 +26,7 @@ func TestAccGlobalAcceleratorAccelerator_basic(t *testing.T) { resourceName := "aws_globalaccelerator_accelerator.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) ipRegex := regexache.MustCompile(`\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}`) - dnsNameRegex := regexache.MustCompile(`^a[a-f0-9]{16}\.awsglobalaccelerator\.com$`) + dnsNameRegex := regexache.MustCompile(`^a[0-9a-f]{16}\.awsglobalaccelerator\.com$`) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, @@ -69,7 +69,7 @@ func TestAccGlobalAcceleratorAccelerator_ipAddressType_dualStack(t *testing.T) { ctx := acctest.Context(t) resourceName := "aws_globalaccelerator_accelerator.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) - dualStackDNSNameRegex := regexache.MustCompile(`^a[a-f0-9]{16}\.dualstack\.awsglobalaccelerator\.com$`) + dualStackDNSNameRegex := regexache.MustCompile(`^a[0-9a-f]{16}\.dualstack\.awsglobalaccelerator\.com$`) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, diff --git a/internal/service/globalaccelerator/custom_routing_accelerator_test.go b/internal/service/globalaccelerator/custom_routing_accelerator_test.go index 0a05e8a25462..46c9f72c10f3 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator_test.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator_test.go @@ -24,7 +24,7 @@ func TestAccGlobalAcceleratorCustomRoutingAccelerator_basic(t *testing.T) { resourceName := "aws_globalaccelerator_custom_routing_accelerator.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) ipRegex := regexache.MustCompile(`\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}`) - dnsNameRegex := regexache.MustCompile(`^a[a-f0-9]{16}\.awsglobalaccelerator\.com$`) + dnsNameRegex := regexache.MustCompile(`^a[0-9a-f]{16}\.awsglobalaccelerator\.com$`) resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, diff --git a/internal/service/glue/crawler.go b/internal/service/glue/crawler.go index 839c9bfd9303..f33409b82bbd 100644 --- a/internal/service/glue/crawler.go +++ b/internal/service/glue/crawler.go @@ -315,7 +315,7 @@ func ResourceCrawler() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9-_$#\/]+$`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_$#\/-]+$`), ""), ), }, "recrawl_policy": { diff --git a/internal/service/glue/registry.go b/internal/service/glue/registry.go index cdd0f50f3ebb..c8b21accf55c 100644 --- a/internal/service/glue/registry.go +++ b/internal/service/glue/registry.go @@ -51,7 +51,7 @@ func ResourceRegistry() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9-_$#]+$`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_$#-]+$`), ""), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/glue/schema.go b/internal/service/glue/schema.go index 3fcd3578889f..e2cc3b66b895 100644 --- a/internal/service/glue/schema.go +++ b/internal/service/glue/schema.go @@ -91,7 +91,7 @@ func ResourceSchema() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9-_$#]+$`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_$#-]+$`), ""), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/guardduty/filter_test.go b/internal/service/guardduty/filter_test.go index 7413cbbefab2..d390f5c25c1e 100644 --- a/internal/service/guardduty/filter_test.go +++ b/internal/service/guardduty/filter_test.go @@ -44,7 +44,7 @@ func testAccFilter_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action", "ARCHIVE"), resource.TestCheckResourceAttr(resourceName, "description", ""), resource.TestCheckResourceAttr(resourceName, "rank", "1"), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "guardduty", regexache.MustCompile("detector/[a-z0-9]{32}/filter/test-filter$")), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "guardduty", regexache.MustCompile("detector/[0-9a-z]{32}/filter/test-filter$")), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "finding_criteria.#", "1"), resource.TestCheckResourceAttr(resourceName, "finding_criteria.0.criterion.#", "3"), diff --git a/internal/service/iam/sweep.go b/internal/service/iam/sweep.go index 27215e3a1451..4b5a55837640 100644 --- a/internal/service/iam/sweep.go +++ b/internal/service/iam/sweep.go @@ -851,7 +851,7 @@ func roleNameFilter(name string) bool { // Some acceptance tests use sdkacctest.RandString(10) rather than sdkacctest.RandomWithPrefix() // Others use other lengths, e.g. sdkacctest.RandString(8), but this one is risky enough, so leave it as-is - randString10 := regexache.MustCompile(`^[a-zA-Z0-9]{10}$`) + randString10 := regexache.MustCompile(`^[0-9A-Za-z]{10}$`) if randString10.MatchString(name) { return true } diff --git a/internal/service/iam/validate.go b/internal/service/iam/validate.go index 7ee58587a4d9..a8fecc91487c 100644 --- a/internal/service/iam/validate.go +++ b/internal/service/iam/validate.go @@ -25,7 +25,7 @@ func validResourceName(max int) schema.SchemaValidateFunc { var validAccountAlias = validation.All( validation.StringLenBetween(3, 63), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9][a-z0-9-]+$`), "must start with an alphanumeric character and only contain lowercase alphanumeric characters and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z][0-9a-z-]+$`), "must start with an alphanumeric character and only contain lowercase alphanumeric characters and hyphens"), func(v interface{}, k string) (ws []string, es []error) { val := v.(string) if strings.Contains(val, "--") { diff --git a/internal/service/iam/virtual_mfa_device.go b/internal/service/iam/virtual_mfa_device.go index 408e4e5fe0cb..71ba9e67244e 100644 --- a/internal/service/iam/virtual_mfa_device.go +++ b/internal/service/iam/virtual_mfa_device.go @@ -270,7 +270,7 @@ func parseVirtualMFADeviceARN(s string) (path, name string, err error) { return "", "", err } - re := regexache.MustCompile(`^mfa(/|/[\x{0021}-\x{007E}]+/)([-A-Za-z0-9_+=,.@]+)$`) + re := regexache.MustCompile(`^mfa(/|/[\x{0021}-\x{007E}]+/)([0-9A-Za-z_+=,.@-]+)$`) matches := re.FindStringSubmatch(arn.Resource) if len(matches) != 3 { return "", "", fmt.Errorf("IAM Virtual MFA Device ARN: invalid resource section (%s)", arn.Resource) diff --git a/internal/service/identitystore/group_data_source.go b/internal/service/identitystore/group_data_source.go index 0dcbda80bf47..8dd1852e2a8f 100644 --- a/internal/service/identitystore/group_data_source.go +++ b/internal/service/identitystore/group_data_source.go @@ -121,7 +121,7 @@ func DataSourceGroup() *schema.Resource { Computed: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 47), - validation.StringMatch(regexache.MustCompile(`^([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$`), "must match ([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"), + validation.StringMatch(regexache.MustCompile(`^([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$`), "must match ([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"), ), AtLeastOneOf: []string{"alternate_identifier", "filter", "group_id"}, ConflictsWith: []string{"alternate_identifier"}, @@ -131,7 +131,7 @@ func DataSourceGroup() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]*$`), "must match [a-zA-Z0-9-]"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]*$`), "must match [0-9A-Za-z-]"), ), }, }, diff --git a/internal/service/identitystore/user_data_source.go b/internal/service/identitystore/user_data_source.go index 9148c109ffd6..6f998094cad5 100644 --- a/internal/service/identitystore/user_data_source.go +++ b/internal/service/identitystore/user_data_source.go @@ -177,7 +177,7 @@ func DataSourceUser() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]*$`), "must match [a-zA-Z0-9-]"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]*$`), "must match [0-9A-Za-z-]"), ), }, "locale": { @@ -262,7 +262,7 @@ func DataSourceUser() *schema.Resource { Computed: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 47), - validation.StringMatch(regexache.MustCompile(`^([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$`), "must match ([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"), + validation.StringMatch(regexache.MustCompile(`^([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$`), "must match ([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"), ), AtLeastOneOf: []string{"alternate_identifier", "filter", "user_id"}, ConflictsWith: []string{"alternate_identifier"}, diff --git a/internal/service/imagebuilder/distribution_configuration.go b/internal/service/imagebuilder/distribution_configuration.go index be547689aee3..58d1014af05d 100644 --- a/internal/service/imagebuilder/distribution_configuration.go +++ b/internal/service/imagebuilder/distribution_configuration.go @@ -121,7 +121,7 @@ func ResourceDistributionConfiguration() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 127), - validation.StringMatch(regexache.MustCompile(`^[-_A-Za-z0-9{][-_A-Za-z0-9\s:{}]+[-_A-Za-z0-9}]$`), "must contain only alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_{-][0-9A-Za-z_\s:{}-]+[0-9A-Za-z_}-]$`), "must contain only alphanumeric characters, underscores, and hyphens"), ), }, "target_account_ids": { diff --git a/internal/service/imagebuilder/image.go b/internal/service/imagebuilder/image.go index a487055b0d33..18e1e7fbd8ff 100644 --- a/internal/service/imagebuilder/image.go +++ b/internal/service/imagebuilder/image.go @@ -51,14 +51,14 @@ func ResourceImage() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):container-recipe/[a-z0-9-_]+/\d+\.\d+\.\d+$`), "valid container recipe ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):container-recipe/[0-9a-z_-]+/\d+\.\d+\.\d+$`), "valid container recipe ARN must be provided"), ExactlyOneOf: []string{"container_recipe_arn", "image_recipe_arn"}, }, "distribution_configuration_arn": { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[a-z0-9-_]+$`), "valid distribution configuration ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[0-9a-z_-]+$`), "valid distribution configuration ARN must be provided"), }, "enhanced_image_metadata_enabled": { Type: schema.TypeBool, @@ -70,7 +70,7 @@ func ResourceImage() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):image-recipe/[a-z0-9-_]+/\d+\.\d+\.\d+$`), "valid image recipe ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):image-recipe/[0-9a-z_-]+/\d+\.\d+\.\d+$`), "valid image recipe ARN must be provided"), ExactlyOneOf: []string{"container_recipe_arn", "image_recipe_arn"}, }, "image_tests_configuration": { @@ -101,7 +101,7 @@ func ResourceImage() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):infrastructure-configuration/[a-z0-9-_]+$`), "valid infrastructure configuration ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):infrastructure-configuration/[0-9a-z_-]+$`), "valid infrastructure configuration ARN must be provided"), }, "name": { Type: schema.TypeString, diff --git a/internal/service/imagebuilder/image_pipeline.go b/internal/service/imagebuilder/image_pipeline.go index 114bf7150cdd..38dc9a2383af 100644 --- a/internal/service/imagebuilder/image_pipeline.go +++ b/internal/service/imagebuilder/image_pipeline.go @@ -44,7 +44,7 @@ func ResourceImagePipeline() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):container-recipe/[a-z0-9-_]+/\d+\.\d+\.\d+$`), "valid container recipe ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):container-recipe/[0-9a-z_-]+/\d+\.\d+\.\d+$`), "valid container recipe ARN must be provided"), ExactlyOneOf: []string{"container_recipe_arn", "image_recipe_arn"}, }, "date_created": { @@ -71,7 +71,7 @@ func ResourceImagePipeline() *schema.Resource { "distribution_configuration_arn": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[a-z0-9-_]+$`), "valid distribution configuration ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[0-9a-z-_]+$`), "valid distribution configuration ARN must be provided"), }, "enhanced_image_metadata_enabled": { Type: schema.TypeBool, @@ -82,7 +82,7 @@ func ResourceImagePipeline() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):image-recipe/[a-z0-9-_]+/\d+\.\d+\.\d+$`), "valid image recipe ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):image-recipe/[0-9a-z-_]+/\d+\.\d+\.\d+$`), "valid image recipe ARN must be provided"), ExactlyOneOf: []string{"container_recipe_arn", "image_recipe_arn"}, }, "image_scanning_configuration": { @@ -145,13 +145,13 @@ func ResourceImagePipeline() *schema.Resource { "infrastructure_configuration_arn": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):infrastructure-configuration/[a-z0-9-_]+$`), "valid infrastructure configuration ARN must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):infrastructure-configuration/[0-9a-z-_]+$`), "valid infrastructure configuration ARN must be provided"), }, "name": { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile("^[-_A-Za-z-0-9][-_A-Za-z0-9 ]{1,126}[-_A-Za-z-0-9]$"), "valid name must be provided"), + ValidateFunc: validation.StringMatch(regexache.MustCompile("^[0-9A-Za-z-_-][0-9A-Za-z-_ ]{1,126}[0-9A-Za-z-_-]$"), "valid name must be provided"), }, "platform": { Type: schema.TypeString, @@ -180,7 +180,7 @@ func ResourceImagePipeline() *schema.Resource { Computed: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 100), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]{2,}(?:\/[a-zA-z0-9-_+]+)*`), "")), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]{2,}(?:\/[0-9a-zA-z-_+]+)*`), "")), }, }, }, diff --git a/internal/service/iot/authorizer.go b/internal/service/iot/authorizer.go index 9566f5021594..41fa7adbbe19 100644 --- a/internal/service/iot/authorizer.go +++ b/internal/service/iot/authorizer.go @@ -75,7 +75,7 @@ func ResourceAuthorizer() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_-]+`), "must contain only alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+`), "must contain only alphanumeric characters, underscores, and hyphens"), ), }, "token_signing_public_keys": { diff --git a/internal/service/iot/endpoint_data_source_test.go b/internal/service/iot/endpoint_data_source_test.go index f5e544197825..6f7690b41a28 100644 --- a/internal/service/iot/endpoint_data_source_test.go +++ b/internal/service/iot/endpoint_data_source_test.go @@ -25,7 +25,7 @@ func TestAccIoTEndpointDataSource_basic(t *testing.T) { { Config: testAccEndpointDataSourceConfig_basic, Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[a-z0-9]+(-ats)?.iot.%s.amazonaws.com$", acctest.Region()))), + resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[0-9a-z]+(-ats)?.iot.%s.amazonaws.com$", acctest.Region()))), ), }, }, @@ -44,7 +44,7 @@ func TestAccIoTEndpointDataSource_EndpointType_iotCredentialProvider(t *testing. { Config: testAccEndpointDataSourceConfig_type("iot:CredentialProvider"), Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[a-z0-9]+.credentials.iot.%s.amazonaws.com$", acctest.Region()))), + resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[0-9a-z]+.credentials.iot.%s.amazonaws.com$", acctest.Region()))), ), }, }, @@ -63,7 +63,7 @@ func TestAccIoTEndpointDataSource_EndpointType_iotData(t *testing.T) { { Config: testAccEndpointDataSourceConfig_type("iot:Data"), Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[a-z0-9]+.iot.%s.amazonaws.com$", acctest.Region()))), + resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[0-9a-z]+.iot.%s.amazonaws.com$", acctest.Region()))), ), }, }, @@ -82,7 +82,7 @@ func TestAccIoTEndpointDataSource_EndpointType_iotDataATS(t *testing.T) { { Config: testAccEndpointDataSourceConfig_type("iot:Data-ATS"), Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[a-z0-9]+-ats.iot.%s.amazonaws.com$", acctest.Region()))), + resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[0-9a-z]+-ats.iot.%s.amazonaws.com$", acctest.Region()))), ), }, }, @@ -101,7 +101,7 @@ func TestAccIoTEndpointDataSource_EndpointType_iotJobs(t *testing.T) { { Config: testAccEndpointDataSourceConfig_type("iot:Jobs"), Check: resource.ComposeTestCheckFunc( - resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[a-z0-9]+.jobs.iot.%s.amazonaws.com$", acctest.Region()))), + resource.TestMatchResourceAttr(dataSourceName, "endpoint_address", regexache.MustCompile(fmt.Sprintf("^[0-9a-z]+.jobs.iot.%s.amazonaws.com$", acctest.Region()))), ), }, }, diff --git a/internal/service/iot/validate.go b/internal/service/iot/validate.go index afb8c75eec36..22b77c93e906 100644 --- a/internal/service/iot/validate.go +++ b/internal/service/iot/validate.go @@ -26,7 +26,7 @@ func validThingTypeDescription(v interface{}, k string) (ws []string, errors []e func validThingTypeName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`[a-zA-Z0-9:_-]+`).MatchString(value) { + if !regexache.MustCompile(`[0-9A-Za-z_:-]+`).MatchString(value) { errors = append(errors, fmt.Errorf( "only alphanumeric characters, colons, underscores and hyphens allowed in %q", k)) } @@ -39,7 +39,7 @@ func validThingTypeSearchableAttribute(v interface{}, k string) (ws []string, er errors = append(errors, fmt.Errorf( "%q cannot be longer than 128 characters", k)) } - if !regexache.MustCompile(`[a-zA-Z0-9_.,@/:#-]+`).MatchString(value) { + if !regexache.MustCompile(`[0-9A-Za-z_.,@/:#-]+`).MatchString(value) { errors = append(errors, fmt.Errorf( "only alphanumeric characters, underscores, dots, commas, arobases, slashes, colons, hashes and hyphens allowed in %q", k)) } @@ -89,14 +89,14 @@ func validTopicRuleName(v interface{}, s string) ([]string, []error) { return nil, []error{fmt.Errorf("Name must between 1 and 128 characters long")} } - matched, err := regexp.MatchReader("^[a-zA-Z0-9_]+$", strings.NewReader(name)) + matched, err := regexp.MatchReader("^[0-9A-Za-z_]+$", strings.NewReader(name)) if err != nil { return nil, []error{err} } if !matched { - return nil, []error{fmt.Errorf("Name must match the pattern ^[a-zA-Z0-9_]+$")} + return nil, []error{fmt.Errorf("Name must match the pattern ^[0-9A-Za-z_]+$")} } return nil, nil diff --git a/internal/service/ivs/channel.go b/internal/service/ivs/channel.go index 96165a86b51d..51f36a003427 100644 --- a/internal/service/ivs/channel.go +++ b/internal/service/ivs/channel.go @@ -67,7 +67,7 @@ func ResourceChannel() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]{0,128}$`), "must contain only alphanumeric characters, hyphen, or underscore and at most 128 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]{0,128}$`), "must contain only alphanumeric characters, hyphen, or underscore and at most 128 characters"), }, "playback_url": { Type: schema.TypeString, diff --git a/internal/service/ivs/recording_configuration.go b/internal/service/ivs/recording_configuration.go index 7094b9cfbdbf..5dac41a52c1e 100644 --- a/internal/service/ivs/recording_configuration.go +++ b/internal/service/ivs/recording_configuration.go @@ -62,7 +62,7 @@ func ResourceRecordingConfiguration() *schema.Resource { "bucket_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z0-9-.]{3,63}$`), "must contain only lowercase alphanumeric characters, hyphen, or dot, and between 3 and 63 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z.-]{3,63}$`), "must contain only lowercase alphanumeric characters, hyphen, or dot, and between 3 and 63 characters"), }, }, }, @@ -75,7 +75,7 @@ func ResourceRecordingConfiguration() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]{0,128}$`), "must contain only alphanumeric characters, hyphen, or underscore, and at most 128 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]{0,128}$`), "must contain only alphanumeric characters, hyphen, or underscore, and at most 128 characters"), }, "recording_reconnect_window_seconds": { Type: schema.TypeInt, diff --git a/internal/service/ivschat/logging_configuration.go b/internal/service/ivschat/logging_configuration.go index 1eac7e05d188..ab3e98e8cf19 100644 --- a/internal/service/ivschat/logging_configuration.go +++ b/internal/service/ivschat/logging_configuration.go @@ -73,7 +73,7 @@ func ResourceLoggingConfiguration() *schema.Resource { "log_group_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[\.\-_/#A-Za-z0-9]{1,512}$`), "must contain only lowercase alphanumeric characters, hyphen, dot, underscore, forward slash, or hash sign, and between 1 and 512 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_./#-]{1,512}$`), "must contain only lowercase alphanumeric characters, hyphen, dot, underscore, forward slash, or hash sign, and between 1 and 512 characters"), }, }, }, @@ -96,7 +96,7 @@ func ResourceLoggingConfiguration() *schema.Resource { "delivery_stream_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]{1,64}$`), "must contain only lowercase alphanumeric characters, hyphen, dot, or underscore, and between 1 and 64 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{1,64}$`), "must contain only lowercase alphanumeric characters, hyphen, dot, or underscore, and between 1 and 64 characters"), }, }, }, @@ -119,7 +119,7 @@ func ResourceLoggingConfiguration() *schema.Resource { "bucket_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z0-9-.]{3,63}$`), "must contain only lowercase alphanumeric characters, hyphen, or dot, and between 3 and 63 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z.-]{3,63}$`), "must contain only lowercase alphanumeric characters, hyphen, or dot, and between 3 and 63 characters"), }, }, }, diff --git a/internal/service/ivschat/room.go b/internal/service/ivschat/room.go index ac775b53785d..6c573d66ec67 100644 --- a/internal/service/ivschat/room.go +++ b/internal/service/ivschat/room.go @@ -92,7 +92,7 @@ func ResourceRoom() *schema.Resource { "name": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]{0,128}$`), "must contain only alphanumeric, hyphen, and underscore characters, with max length of 128 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]{0,128}$`), "must contain only alphanumeric, hyphen, and underscore characters, with max length of 128 characters"), }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), diff --git a/internal/service/kendra/data_source.go b/internal/service/kendra/data_source.go index 7f0cbb171f55..70a98fad7000 100644 --- a/internal/service/kendra/data_source.go +++ b/internal/service/kendra/data_source.go @@ -109,7 +109,7 @@ func ResourceDataSource() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(3, 63), validation.StringMatch( - regexache.MustCompile(`[a-z0-9][\.\-a-z0-9]{1,61}[a-z0-9]`), + regexache.MustCompile(`[0-9a-z][0-9a-z.-]{1,61}[0-9a-z]`), "Must be a valid bucket name", ), ), @@ -366,7 +366,7 @@ func ResourceDataSource() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 200), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9_][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z_][0-9A-Za-z_-]*`), "Starts with an alphanumeric character or underscore. Subsequently, can contain alphanumeric characters, underscores and hyphens.", ), ), @@ -423,7 +423,7 @@ func ResourceDataSource() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, @@ -434,7 +434,7 @@ func ResourceDataSource() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(2, 10), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z-]*`), + regexache.MustCompile(`[A-Za-z-]*`), "Must have alphanumeric characters or hyphens.", ), ), @@ -445,7 +445,7 @@ func ResourceDataSource() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 1000), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), "Starts with an alphanumeric character. Subsequently, the name must consist of alphanumerics, hyphens or underscores.", ), ), @@ -502,7 +502,7 @@ func hookConfigurationSchema() *schema.Schema { ValidateFunc: validation.All( validation.StringLenBetween(3, 63), validation.StringMatch( - regexache.MustCompile(`[a-z0-9][\.\-a-z0-9]{1,61}[a-z0-9]`), + regexache.MustCompile(`[0-9a-z][0-9a-z.-]{1,61}[0-9a-z]`), "Must be a valid bucket name", ), ), @@ -525,7 +525,7 @@ func documentAttributeConditionSchema() *schema.Schema { ValidateFunc: validation.All( validation.StringLenBetween(1, 200), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9_][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z_][0-9A-Za-z_-]*`), "Starts with an alphanumeric character or underscore. Subsequently, can contain alphanumeric characters, underscores and hyphens.", ), ), diff --git a/internal/service/kendra/experience.go b/internal/service/kendra/experience.go index 7271c7c3296d..9cd770866861 100644 --- a/internal/service/kendra/experience.go +++ b/internal/service/kendra/experience.go @@ -75,7 +75,7 @@ func ResourceExperience() *schema.Resource { MaxItems: 100, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_\-]*`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), ""), }, }, "direct_put_content": { @@ -90,7 +90,7 @@ func ResourceExperience() *schema.Resource { MaxItems: 100, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_\-]*`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), ""), }, }, }, @@ -109,7 +109,7 @@ func ResourceExperience() *schema.Resource { "identity_attribute_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_\-]*`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), ""), }, }, }, @@ -146,14 +146,14 @@ func ResourceExperience() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]*`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]*`), ""), }, "name": { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 1000), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_\-]*`), ""), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), ""), ), }, "role_arn": { diff --git a/internal/service/kendra/experience_data_source.go b/internal/service/kendra/experience_data_source.go index 36ce6db83610..31e6db877a6c 100644 --- a/internal/service/kendra/experience_data_source.go +++ b/internal/service/kendra/experience_data_source.go @@ -106,7 +106,7 @@ func DataSourceExperience() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 36), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens.", ), ), @@ -115,7 +115,7 @@ func DataSourceExperience() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, diff --git a/internal/service/kendra/faq.go b/internal/service/kendra/faq.go index cd0f60bca8ea..1166ad3e20da 100644 --- a/internal/service/kendra/faq.go +++ b/internal/service/kendra/faq.go @@ -79,7 +79,7 @@ func ResourceFaq() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, @@ -91,7 +91,7 @@ func ResourceFaq() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(2, 10), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z-]*`), + regexache.MustCompile(`[A-Za-z-]*`), "Must have alphanumeric characters or hyphens.", ), ), @@ -103,7 +103,7 @@ func ResourceFaq() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 100), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), "Starts with an alphanumeric character. Subsequently, the name must consist of alphanumerics, hyphens or underscores.", ), ), diff --git a/internal/service/kendra/faq_data_source.go b/internal/service/kendra/faq_data_source.go index c45efe722134..e59882e1ce6e 100644 --- a/internal/service/kendra/faq_data_source.go +++ b/internal/service/kendra/faq_data_source.go @@ -45,7 +45,7 @@ func DataSourceFaq() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 100), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens.", ), ), @@ -58,7 +58,7 @@ func DataSourceFaq() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, diff --git a/internal/service/kendra/index.go b/internal/service/kendra/index.go index da1e4c310a62..b00a93da708b 100644 --- a/internal/service/kendra/index.go +++ b/internal/service/kendra/index.go @@ -240,7 +240,7 @@ func ResourceIndex() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 1000), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), "The name must consist of alphanumerics, hyphens or underscores.", ), ), diff --git a/internal/service/kendra/index_data_source.go b/internal/service/kendra/index_data_source.go index c7cce272ebc3..0f352da15a0b 100644 --- a/internal/service/kendra/index_data_source.go +++ b/internal/service/kendra/index_data_source.go @@ -132,7 +132,7 @@ func DataSourceIndex() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, diff --git a/internal/service/kendra/query_suggestions_block_list_data_source.go b/internal/service/kendra/query_suggestions_block_list_data_source.go index 4d928ba4bd81..0ab26d3cba90 100644 --- a/internal/service/kendra/query_suggestions_block_list_data_source.go +++ b/internal/service/kendra/query_suggestions_block_list_data_source.go @@ -47,7 +47,7 @@ func DataSourceQuerySuggestionsBlockList() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, @@ -63,7 +63,7 @@ func DataSourceQuerySuggestionsBlockList() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, diff --git a/internal/service/kendra/thesaurus_data_source.go b/internal/service/kendra/thesaurus_data_source.go index dd6156d9fda4..430b4fab6851 100644 --- a/internal/service/kendra/thesaurus_data_source.go +++ b/internal/service/kendra/thesaurus_data_source.go @@ -47,7 +47,7 @@ func DataSourceThesaurus() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9-]{35}`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z-]{35}`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, @@ -94,7 +94,7 @@ func DataSourceThesaurus() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 100), validation.StringMatch( - regexache.MustCompile(`[a-zA-Z0-9][a-zA-Z0-9_-]*`), + regexache.MustCompile(`[0-9A-Za-z][0-9A-Za-z_-]*`), "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens.", ), ), diff --git a/internal/service/keyspaces/keyspace.go b/internal/service/keyspaces/keyspace.go index 3c151bac81ca..22fb0adb07b7 100644 --- a/internal/service/keyspaces/keyspace.go +++ b/internal/service/keyspaces/keyspace.go @@ -54,7 +54,7 @@ func resourceKeyspace() *schema.Resource { ForceNew: true, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_]{0,47}$`), + regexache.MustCompile(`^[0-9A-Za-z][0-9A-Za-z_]{0,47}$`), "The name can have up to 48 characters. It must begin with an alpha-numeric character and can only contain alpha-numeric characters and underscores.", ), }, diff --git a/internal/service/keyspaces/table.go b/internal/service/keyspaces/table.go index e809d714d24d..3c67d639f8ae 100644 --- a/internal/service/keyspaces/table.go +++ b/internal/service/keyspaces/table.go @@ -160,7 +160,7 @@ func resourceTable() *schema.Resource { ForceNew: true, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_]{0,47}$`), + regexache.MustCompile(`^[0-9A-Za-z][0-9A-Za-z_]{0,47}$`), "The keyspace name can have up to 48 characters. It must begin with an alpha-numeric character and can only contain alpha-numeric characters and underscores.", ), }, @@ -197,7 +197,7 @@ func resourceTable() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-z0-9_]{1,48}$`), + regexache.MustCompile(`^[0-9a-z_]{1,48}$`), "The column name can have up to 48 characters. It can only contain lowercase alpha-numeric characters and underscores.", ), }, @@ -219,7 +219,7 @@ func resourceTable() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-z0-9_]{1,48}$`), + regexache.MustCompile(`^[0-9a-z_]{1,48}$`), "The column name can have up to 48 characters. It can only contain lowercase alpha-numeric characters and underscores.", ), }, @@ -227,7 +227,7 @@ func resourceTable() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-z0-9]+(\<[a-z0-9]+(, *[a-z0-9]+){0,1}\>)?$`), + regexache.MustCompile(`^[0-9a-z]+(\<[0-9a-z]+(, *[0-9a-z]+){0,1}\>)?$`), "The type must consist of lower case alphanumerics and an optional list of upto two lower case alphanumerics enclosed in angle brackets '<>'.", ), }, @@ -245,7 +245,7 @@ func resourceTable() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-z0-9_]{1,48}$`), + regexache.MustCompile(`^[0-9a-z_]{1,48}$`), "The column name can have up to 48 characters. It can only contain lowercase alpha-numeric characters and underscores.", ), }, @@ -263,7 +263,7 @@ func resourceTable() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-z0-9_]{1,48}$`), + regexache.MustCompile(`^[0-9a-z_]{1,48}$`), "The column name can have up to 48 characters. It can only contain lowercase alpha-numeric characters and underscores.", ), }, @@ -278,7 +278,7 @@ func resourceTable() *schema.Resource { ForceNew: true, Required: true, ValidateFunc: validation.StringMatch( - regexache.MustCompile(`^[a-zA-Z0-9_]{1,48}$`), + regexache.MustCompile(`^[0-9A-Za-z_]{1,48}$`), "The table name can have up to 48 characters. It can only contain alpha-numeric characters and underscores.", ), }, diff --git a/internal/service/kinesisanalytics/application.go b/internal/service/kinesisanalytics/application.go index acae063d62bf..2a831942c2d0 100644 --- a/internal/service/kinesisanalytics/application.go +++ b/internal/service/kinesisanalytics/application.go @@ -110,7 +110,7 @@ func ResourceApplication() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, diff --git a/internal/service/kinesisanalyticsv2/application.go b/internal/service/kinesisanalyticsv2/application.go index 1192c11d9ed5..9a3e1d2872eb 100644 --- a/internal/service/kinesisanalyticsv2/application.go +++ b/internal/service/kinesisanalyticsv2/application.go @@ -154,7 +154,7 @@ func ResourceApplication() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 50), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, @@ -896,7 +896,7 @@ func ResourceApplication() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, diff --git a/internal/service/kinesisanalyticsv2/application_snapshot.go b/internal/service/kinesisanalyticsv2/application_snapshot.go index ac9575e4a7c8..8975b862feec 100644 --- a/internal/service/kinesisanalyticsv2/application_snapshot.go +++ b/internal/service/kinesisanalyticsv2/application_snapshot.go @@ -43,7 +43,7 @@ func ResourceApplicationSnapshot() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, @@ -63,7 +63,7 @@ func ResourceApplicationSnapshot() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, }, diff --git a/internal/service/kinesisvideo/stream.go b/internal/service/kinesisvideo/stream.go index 2e87943cceeb..60b560cb1d58 100644 --- a/internal/service/kinesisvideo/stream.go +++ b/internal/service/kinesisvideo/stream.go @@ -67,7 +67,7 @@ func ResourceStream() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, diff --git a/internal/service/kms/alias_data_source_test.go b/internal/service/kms/alias_data_source_test.go index dddfa25e8432..e914f0fc0ef5 100644 --- a/internal/service/kms/alias_data_source_test.go +++ b/internal/service/kms/alias_data_source_test.go @@ -29,8 +29,8 @@ func TestAccKMSAliasDataSource_service(t *testing.T) { Check: resource.ComposeTestCheckFunc( acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "kms", rName), resource.TestCheckResourceAttr(resourceName, "name", rName), - acctest.MatchResourceAttrRegionalARN(resourceName, "target_key_arn", "kms", regexache.MustCompile(`key/[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}`)), - resource.TestMatchResourceAttr(resourceName, "target_key_id", regexache.MustCompile("^[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}$")), + acctest.MatchResourceAttrRegionalARN(resourceName, "target_key_arn", "kms", regexache.MustCompile(`key/[0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12}`)), + resource.TestMatchResourceAttr(resourceName, "target_key_id", regexache.MustCompile("^[0-9a-z]{8}-([0-9a-z]{4}-){3}[0-9a-z]{12}$")), ), }, }, diff --git a/internal/service/kms/validate.go b/internal/service/kms/validate.go index df7d4dbab6a0..bc4a6e583801 100644 --- a/internal/service/kms/validate.go +++ b/internal/service/kms/validate.go @@ -13,8 +13,8 @@ import ( ) const ( - aliasNameRegexPattern = `alias/[a-zA-Z0-9/_-]+` - multiRegionKeyIdPattern = `mrk-[a-f0-9]{32}` + aliasNameRegexPattern = `alias/[0-9A-Za-z_/-]+` + multiRegionKeyIdPattern = `mrk-[0-9a-f]{32}` ) var ( @@ -30,8 +30,8 @@ func validGrantName(v interface{}, k string) (ws []string, es []error) { es = append(es, fmt.Errorf("%s can not be greater than 256 characters", k)) } - if !regexache.MustCompile(`^[a-zA-Z0-9:/_-]+$`).MatchString(value) { - es = append(es, fmt.Errorf("%s must only contain [a-zA-Z0-9:/_-]", k)) + if !regexache.MustCompile(`^[0-9A-Za-z_:/-]+$`).MatchString(value) { + es = append(es, fmt.Errorf("%s must only contain [0-9A-Za-z_:/-]", k)) } return @@ -42,7 +42,7 @@ func validNameForDataSource(v interface{}, k string) (ws []string, es []error) { if !aliasNameRegex.MatchString(value) { es = append(es, fmt.Errorf( - "%q must begin with 'alias/' and be comprised of only [a-zA-Z0-9/_-]", k)) + "%q must begin with 'alias/' and be comprised of only [0-9A-Za-z_/-]", k)) } return } @@ -56,7 +56,7 @@ func validNameForResource(v interface{}, k string) (ws []string, es []error) { if !aliasNameRegex.MatchString(value) { es = append(es, fmt.Errorf( - "%q must begin with 'alias/' and be comprised of only [a-zA-Z0-9/_-]", k)) + "%q must begin with 'alias/' and be comprised of only [0-9A-Za-z_/-]", k)) } return } diff --git a/internal/service/lambda/function.go b/internal/service/lambda/function.go index 2202e1781148..4443b7b09ac5 100644 --- a/internal/service/lambda/function.go +++ b/internal/service/lambda/function.go @@ -161,7 +161,7 @@ func ResourceFunction() *schema.Resource { "local_mount_path": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^/mnt/[a-zA-Z0-9-_.]+$`), "must start with '/mnt/'"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^/mnt/[0-9A-Za-z_.-]+$`), "must start with '/mnt/'"), }, }, }, diff --git a/internal/service/lambda/layer_version_permission.go b/internal/service/lambda/layer_version_permission.go index 095f25fc6a56..9489e31b39d0 100644 --- a/internal/service/lambda/layer_version_permission.go +++ b/internal/service/lambda/layer_version_permission.go @@ -40,7 +40,7 @@ func ResourceLayerVersionPermission() *schema.Resource { "layer_name": { Type: schema.TypeString, ValidateFunc: validation.Any( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), ""), verify.ValidARN, ), Required: true, diff --git a/internal/service/lambda/permission.go b/internal/service/lambda/permission.go index 477aec3ea92b..d3383355adc4 100644 --- a/internal/service/lambda/permission.go +++ b/internal/service/lambda/permission.go @@ -25,7 +25,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/verify" ) -var functionRegexp = `^(arn:[\w-]+:lambda:)?([a-z]{2}-(?:[a-z]+-){1,2}\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?$` +var functionRegexp = `^(arn:[\w-]+:lambda:)?([a-z]{2}-(?:[a-z]+-){1,2}\d{1}:)?(\d{12}:)?(function:)?([0-9A-Za-z_-]+)(:(\$LATEST|[0-9A-Za-z_-]+))?$` // @SDKResource("aws_lambda_permission") func ResourcePermission() *schema.Resource { diff --git a/internal/service/lambda/validate.go b/internal/service/lambda/validate.go index 1ac496828827..2c0a0edaca34 100644 --- a/internal/service/lambda/validate.go +++ b/internal/service/lambda/validate.go @@ -11,7 +11,7 @@ import ( func validFunctionName() schema.SchemaValidateFunc { // http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html - pattern := `^(arn:[\w-]+:lambda:)?([a-z]{2}-(?:[a-z]+-){1,2}\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?$` + pattern := `^(arn:[\w-]+:lambda:)?([a-z]{2}-(?:[a-z]+-){1,2}\d{1}:)?(\d{12}:)?(function:)?([0-9A-Za-z_-]+)(:(\$LATEST|[0-9A-Za-z_-]+))?$` return validation.All( validation.StringMatch(regexache.MustCompile(pattern), "must be valid function name or function ARN"), @@ -20,14 +20,14 @@ func validFunctionName() schema.SchemaValidateFunc { } func validPermissionAction() schema.SchemaValidateFunc { - pattern := `^(lambda:[*]|lambda:[a-zA-Z]+|[*])$` + pattern := `^(lambda:[*]|lambda:[A-Za-z]+|[*])$` return validation.StringMatch(regexache.MustCompile(pattern), "must be a valid action (usually starts with lambda:)") } func validPermissionEventSourceToken() schema.SchemaValidateFunc { // https://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html return validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._\-]+$`), "must contain alphanumeric, periods, underscores or dashes only"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain alphanumeric, periods, underscores or dashes only"), validation.StringLenBetween(1, 256), ) } @@ -35,7 +35,7 @@ func validPermissionEventSourceToken() schema.SchemaValidateFunc { func validQualifier() schema.SchemaValidateFunc { // http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html return validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9$_-]+$`), "must contain alphanumeric, dollar signs, underscores or dashes only"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_$-]+$`), "must contain alphanumeric, dollar signs, underscores or dashes only"), validation.StringLenBetween(1, 128), ) } @@ -43,7 +43,7 @@ func validQualifier() schema.SchemaValidateFunc { func validPolicyStatementID() schema.SchemaValidateFunc { // http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html return validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_-]+$`), "must contain alphanumeric, underscores or dashes only"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain alphanumeric, underscores or dashes only"), validation.StringLenBetween(1, 100), ) } diff --git a/internal/service/lightsail/bucket_access_key.go b/internal/service/lightsail/bucket_access_key.go index 254f701b905d..e7e35852f8bc 100644 --- a/internal/service/lightsail/bucket_access_key.go +++ b/internal/service/lightsail/bucket_access_key.go @@ -46,7 +46,7 @@ func ResourceBucketAccessKey() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z0-9][a-z0-9-]{1,52}[a-z0-9]$`), "Invalid Bucket name. Must match regex: ^[a-z0-9][a-z0-9-]{1,52}[a-z0-9]$"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z][0-9a-z-]{1,52}[0-9a-z]$`), "Invalid Bucket name. Must match regex: ^[0-9a-z][0-9a-z-]{1,52}[0-9a-z]$"), }, "created_at": { Type: schema.TypeString, diff --git a/internal/service/lightsail/bucket_access_key_test.go b/internal/service/lightsail/bucket_access_key_test.go index ab33eda978f3..b02198b706f4 100644 --- a/internal/service/lightsail/bucket_access_key_test.go +++ b/internal/service/lightsail/bucket_access_key_test.go @@ -42,9 +42,9 @@ func TestAccLightsailBucketAccessKey_basic(t *testing.T) { Config: testAccBucketAccessKeyConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckBucketAccessKeyExists(ctx, resourceName), - resource.TestMatchResourceAttr(resourceName, "access_key_id", regexache.MustCompile(`((?:ASIA|AKIA|AROA|AIDA)([A-Z0-7]{16}))`)), + resource.TestMatchResourceAttr(resourceName, "access_key_id", regexache.MustCompile(`((?:ASIA|AKIA|AROA|AIDA)([0-7A-Z]{16}))`)), resource.TestCheckResourceAttrSet(resourceName, "created_at"), - resource.TestMatchResourceAttr(resourceName, "secret_access_key", regexache.MustCompile(`([a-zA-Z0-9+/]{40})`)), + resource.TestMatchResourceAttr(resourceName, "secret_access_key", regexache.MustCompile(`([0-9A-Za-z+/]{40})`)), resource.TestCheckResourceAttrSet(resourceName, "status"), ), }, diff --git a/internal/service/lightsail/bucket_resource_access.go b/internal/service/lightsail/bucket_resource_access.go index 22136ef08312..2e4e3fa56929 100644 --- a/internal/service/lightsail/bucket_resource_access.go +++ b/internal/service/lightsail/bucket_resource_access.go @@ -41,7 +41,7 @@ func ResourceBucketResourceAccess() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z0-9][a-z0-9-]{1,52}[a-z0-9]$`), "Invalid Bucket name. Must match regex: ^[a-z0-9][a-z0-9-]{1,52}[a-z0-9]$"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z][0-9a-z-]{1,52}[0-9a-z]$`), "Invalid Bucket name. Must match regex: ^[0-9a-z][0-9a-z-]{1,52}[0-9a-z]$"), }, "resource_name": { Type: schema.TypeString, diff --git a/internal/service/lightsail/certificate.go b/internal/service/lightsail/certificate.go index e7693d0a4259..981d28f4a895 100644 --- a/internal/service/lightsail/certificate.go +++ b/internal/service/lightsail/certificate.go @@ -89,8 +89,8 @@ func ResourceCertificate() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "subject_alternative_names": { diff --git a/internal/service/lightsail/container_service.go b/internal/service/lightsail/container_service.go index 768e440c6679..7911619c3ada 100644 --- a/internal/service/lightsail/container_service.go +++ b/internal/service/lightsail/container_service.go @@ -68,7 +68,7 @@ func ResourceContainerService() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9]{1,2}|[a-z0-9][a-z0-9-]+[a-z0-9]$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z]{1,2}|[0-9a-z][0-9a-z-]+[0-9a-z]$`), ""), ), }, "power": { diff --git a/internal/service/lightsail/database.go b/internal/service/lightsail/database.go index 80e968893b80..31d65955cc8e 100644 --- a/internal/service/lightsail/database.go +++ b/internal/service/lightsail/database.go @@ -98,7 +98,7 @@ func ResourceDatabase() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$`), "Must contain from 2 to 255 alphanumeric characters, or hyphens. The first and last character must be a letter or number"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z][0-9A-Za-z-]+[0-9A-Za-z]$`), "Must contain from 2 to 255 alphanumeric characters, or hyphens. The first and last character must be a letter or number"), ), }, "master_database_name": { @@ -165,7 +165,7 @@ func ResourceDatabase() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[^._\-]+[0-9A-Za-z-]+[^._\-]$`), "Must contain from 2 to 255 alphanumeric characters, or hyphens. The first and last character must be a letter or number"), + validation.StringMatch(regexache.MustCompile(`^[_.^-]+[0-9A-Za-z-]+[_.^-]$`), "Must contain from 2 to 255 alphanumeric characters, or hyphens. The first and last character must be a letter or number"), ), }, "secondary_availability_zone": { diff --git a/internal/service/lightsail/disk.go b/internal/service/lightsail/disk.go index 9590914274d4..7a365737c2ed 100644 --- a/internal/service/lightsail/disk.go +++ b/internal/service/lightsail/disk.go @@ -56,8 +56,8 @@ func ResourceDisk() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "size_in_gb": { diff --git a/internal/service/lightsail/instance.go b/internal/service/lightsail/instance.go index 63f6bb284f5e..2d0c68d7cf24 100644 --- a/internal/service/lightsail/instance.go +++ b/internal/service/lightsail/instance.go @@ -70,8 +70,8 @@ func ResourceInstance() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]`), "must begin with an alphanumeric character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]`), "must begin with an alphanumeric character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "availability_zone": { diff --git a/internal/service/lightsail/instance_test.go b/internal/service/lightsail/instance_test.go index 6fb3d0446874..7b947a91b464 100644 --- a/internal/service/lightsail/instance_test.go +++ b/internal/service/lightsail/instance_test.go @@ -55,7 +55,7 @@ func TestAccLightsailInstance_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "blueprint_id"), resource.TestCheckResourceAttrSet(resourceName, "bundle_id"), resource.TestCheckResourceAttr(resourceName, "ipv6_addresses.#", "1"), - resource.TestMatchResourceAttr(resourceName, "ipv6_addresses.0", regexache.MustCompile(`([a-f0-9]{1,4}:){7}[a-f0-9]{1,4}`)), + resource.TestMatchResourceAttr(resourceName, "ipv6_addresses.0", regexache.MustCompile(`([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}`)), resource.TestCheckResourceAttrSet(resourceName, "key_pair_name"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestMatchResourceAttr(resourceName, "ram_size", regexache.MustCompile(`\d+(.\d+)?`)), diff --git a/internal/service/lightsail/lb.go b/internal/service/lightsail/lb.go index 84fe801b4797..744a99b702ff 100644 --- a/internal/service/lightsail/lb.go +++ b/internal/service/lightsail/lb.go @@ -84,8 +84,8 @@ func ResourceLoadBalancer() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "support_code": { diff --git a/internal/service/lightsail/lb_attachment.go b/internal/service/lightsail/lb_attachment.go index 947f943f8f01..f960c3ee5c09 100644 --- a/internal/service/lightsail/lb_attachment.go +++ b/internal/service/lightsail/lb_attachment.go @@ -40,8 +40,8 @@ func ResourceLoadBalancerAttachment() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "instance_name": { diff --git a/internal/service/lightsail/lb_certificate.go b/internal/service/lightsail/lb_certificate.go index a3685a535a46..402391919f00 100644 --- a/internal/service/lightsail/lb_certificate.go +++ b/internal/service/lightsail/lb_certificate.go @@ -86,8 +86,8 @@ func ResourceLoadBalancerCertificate() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "name": { @@ -96,8 +96,8 @@ func ResourceLoadBalancerCertificate() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "subject_alternative_names": { diff --git a/internal/service/lightsail/lb_certificate_attachment.go b/internal/service/lightsail/lb_certificate_attachment.go index 36766cb12f0b..10853ca22088 100644 --- a/internal/service/lightsail/lb_certificate_attachment.go +++ b/internal/service/lightsail/lb_certificate_attachment.go @@ -41,8 +41,8 @@ func ResourceLoadBalancerCertificateAttachment() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, "certificate_name": { diff --git a/internal/service/lightsail/lb_https_redirection_policy.go b/internal/service/lightsail/lb_https_redirection_policy.go index 6568355dfee1..b76f8c7039e9 100644 --- a/internal/service/lightsail/lb_https_redirection_policy.go +++ b/internal/service/lightsail/lb_https_redirection_policy.go @@ -44,8 +44,8 @@ func ResourceLoadBalancerHTTPSRedirectionPolicy() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, }, diff --git a/internal/service/lightsail/lb_stickiness_policy.go b/internal/service/lightsail/lb_stickiness_policy.go index 93cc4cbfa2e5..d60931f82113 100644 --- a/internal/service/lightsail/lb_stickiness_policy.go +++ b/internal/service/lightsail/lb_stickiness_policy.go @@ -49,8 +49,8 @@ func ResourceLoadBalancerStickinessPolicy() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(2, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with an alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+[^._\-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with an alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+[_.^-]$`), "must contain only alphanumeric characters, underscores, hyphens, and dots"), ), }, }, diff --git a/internal/service/logs/validate.go b/internal/service/logs/validate.go index 4a36692100cc..1cf142c0d3c5 100644 --- a/internal/service/logs/validate.go +++ b/internal/service/logs/validate.go @@ -31,7 +31,7 @@ func validLogGroupName(v interface{}, k string) (ws []string, errors []error) { } // http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateLogGroup.html - pattern := `^[\.\-_/#A-Za-z0-9]+$` + pattern := `^[0-9A-Za-z_./#-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q isn't a valid log group name (alphanumeric characters, underscores,"+ @@ -51,7 +51,7 @@ func validLogGroupNamePrefix(v interface{}, k string) (ws []string, errors []err } // http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateLogGroup.html - pattern := `^[\.\-_/#A-Za-z0-9]+$` + pattern := `^[0-9A-Za-z_./#-]+$` if !regexache.MustCompile(pattern).MatchString(value) { errors = append(errors, fmt.Errorf( "%q isn't a valid log group name (alphanumeric characters, underscores,"+ diff --git a/internal/service/memorydb/validate.go b/internal/service/memorydb/validate.go index f461e9e7951e..df34dc62cf9a 100644 --- a/internal/service/memorydb/validate.go +++ b/internal/service/memorydb/validate.go @@ -41,7 +41,7 @@ func validateResourceNamePrefix(maxLength int) schema.SchemaValidateFunc { regexache.MustCompile(`[-][-]`), "The name may not contain two consecutive hyphens."), validation.StringMatch( - regexache.MustCompile(`^[a-z0-9-]+$`), + regexache.MustCompile(`^[0-9a-z-]+$`), "Only lowercase alphanumeric characters and hyphens are allowed."), ) } diff --git a/internal/service/mq/broker_test.go b/internal/service/mq/broker_test.go index 8a0160cf9b14..f0ef6560eb84 100644 --- a/internal/service/mq/broker_test.go +++ b/internal/service/mq/broker_test.go @@ -273,7 +273,7 @@ func TestAccMQBroker_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "authentication_strategy", "simple"), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestMatchResourceAttr(resourceName, "configuration.0.revision", regexache.MustCompile(`^[0-9]+$`)), resource.TestCheckResourceAttr(resourceName, "deployment_mode", "SINGLE_INSTANCE"), resource.TestCheckResourceAttr(resourceName, "encryption_options.#", "1"), @@ -283,13 +283,13 @@ func TestAccMQBroker_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "host_instance_type", "mq.t2.micro"), resource.TestCheckResourceAttr(resourceName, "instances.#", "1"), resource.TestMatchResourceAttr(resourceName, "instances.0.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com:8162$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com:8162$`)), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "5"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[a-z0-9-\.]+:61617$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[a-z0-9-\.]+:5671$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[a-z0-9-\.]+:61614$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[a-z0-9-\.]+:8883$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[a-z0-9-\.]+:61619$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[0-9a-z.-]+:61617$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[0-9a-z.-]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[0-9a-z.-]+:61614$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[0-9a-z.-]+:8883$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[0-9a-z.-]+:61619$`)), resource.TestMatchResourceAttr(resourceName, "instances.0.ip_address", regexache.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)), resource.TestCheckResourceAttr(resourceName, "maintenance_window_start_time.#", "1"), @@ -437,7 +437,7 @@ func TestAccMQBroker_throughputOptimized(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "auto_minor_version_upgrade", "false"), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestMatchResourceAttr(resourceName, "configuration.0.revision", regexache.MustCompile(`^[0-9]+$`)), resource.TestCheckResourceAttr(resourceName, "deployment_mode", "SINGLE_INSTANCE"), resource.TestCheckResourceAttr(resourceName, "encryption_options.#", "1"), @@ -466,15 +466,15 @@ func TestAccMQBroker_throughputOptimized(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexache.MustCompile(`broker:+.`)), resource.TestCheckResourceAttr(resourceName, "instances.#", "1"), resource.TestMatchResourceAttr(resourceName, "instances.0.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com:8162$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com:8162$`)), resource.TestMatchResourceAttr(resourceName, "instances.0.ip_address", regexache.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "5"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[a-z0-9-\.]+:61617$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[a-z0-9-\.]+:5671$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[a-z0-9-\.]+:61614$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[a-z0-9-\.]+:8883$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[a-z0-9-\.]+:61619$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[0-9a-z.-]+:61617$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[0-9a-z.-]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[0-9a-z.-]+:61614$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[0-9a-z.-]+:8883$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[0-9a-z.-]+:61619$`)), ), }, }, @@ -521,7 +521,7 @@ func TestAccMQBroker_AllFields_defaultVPC(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "auto_minor_version_upgrade", "true"), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestCheckResourceAttr(resourceName, "configuration.0.revision", "2"), resource.TestCheckResourceAttr(resourceName, "deployment_mode", "ACTIVE_STANDBY_MULTI_AZ"), resource.TestCheckResourceAttr(resourceName, "engine_type", "ActiveMQ"), @@ -557,25 +557,25 @@ func TestAccMQBroker_AllFields_defaultVPC(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexache.MustCompile(`broker:+.`)), resource.TestCheckResourceAttr(resourceName, "instances.#", "2"), resource.TestMatchResourceAttr(resourceName, "instances.0.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com:8162$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com:8162$`)), resource.TestMatchResourceAttr(resourceName, "instances.0.ip_address", regexache.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "5"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[a-z0-9-\.]+:61617$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[a-z0-9-\.]+:5671$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[a-z0-9-\.]+:61614$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[a-z0-9-\.]+:8883$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[a-z0-9-\.]+:61619$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[0-9a-z.-]+:61617$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[0-9a-z.-]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[0-9a-z.-]+:61614$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[0-9a-z.-]+:8883$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[0-9a-z.-]+:61619$`)), resource.TestMatchResourceAttr(resourceName, "instances.1.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com:8162$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com:8162$`)), resource.TestMatchResourceAttr(resourceName, "instances.1.ip_address", regexache.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)), resource.TestCheckResourceAttr(resourceName, "instances.1.endpoints.#", "5"), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.0", regexache.MustCompile(`^ssl://[a-z0-9-\.]+:61617$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[a-z0-9-\.]+:5671$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[a-z0-9-\.]+:61614$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[a-z0-9-\.]+:8883$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.4", regexache.MustCompile(`^wss://[a-z0-9-\.]+:61619$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.0", regexache.MustCompile(`^ssl://[0-9a-z.-]+:61617$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[0-9a-z.-]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[0-9a-z.-]+:61614$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[0-9a-z.-]+:8883$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.4", regexache.MustCompile(`^wss://[0-9a-z.-]+:61619$`)), ), }, { @@ -591,7 +591,7 @@ func TestAccMQBroker_AllFields_defaultVPC(t *testing.T) { testAccCheckBrokerExists(ctx, resourceName, &broker), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestCheckResourceAttr(resourceName, "configuration.0.revision", "3"), ), }, @@ -602,7 +602,7 @@ func TestAccMQBroker_AllFields_defaultVPC(t *testing.T) { testAccCheckBrokerExists(ctx, resourceName, &broker), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestCheckResourceAttr(resourceName, "configuration.0.revision", "2"), ), }, @@ -650,7 +650,7 @@ func TestAccMQBroker_AllFields_customVPC(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "auto_minor_version_upgrade", "true"), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestCheckResourceAttr(resourceName, "configuration.0.revision", "2"), resource.TestCheckResourceAttr(resourceName, "deployment_mode", "ACTIVE_STANDBY_MULTI_AZ"), resource.TestCheckResourceAttr(resourceName, "engine_type", "ActiveMQ"), @@ -686,25 +686,25 @@ func TestAccMQBroker_AllFields_customVPC(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexache.MustCompile(`broker:+.`)), resource.TestCheckResourceAttr(resourceName, "instances.#", "2"), resource.TestMatchResourceAttr(resourceName, "instances.0.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com:8162$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com:8162$`)), resource.TestMatchResourceAttr(resourceName, "instances.0.ip_address", regexache.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "5"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[a-z0-9-\.]+:61617$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[a-z0-9-\.]+:5671$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[a-z0-9-\.]+:61614$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[a-z0-9-\.]+:8883$`)), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[a-z0-9-\.]+:61619$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^ssl://[0-9a-z.-]+:61617$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[0-9a-z.-]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[0-9a-z.-]+:61614$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[0-9a-z.-]+:8883$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.4", regexache.MustCompile(`^wss://[0-9a-z.-]+:61619$`)), resource.TestMatchResourceAttr(resourceName, "instances.1.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com:8162$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com:8162$`)), resource.TestMatchResourceAttr(resourceName, "instances.1.ip_address", regexache.MustCompile(`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$`)), resource.TestCheckResourceAttr(resourceName, "instances.1.endpoints.#", "5"), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.0", regexache.MustCompile(`^ssl://[a-z0-9-\.]+:61617$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[a-z0-9-\.]+:5671$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[a-z0-9-\.]+:61614$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[a-z0-9-\.]+:8883$`)), - resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.4", regexache.MustCompile(`^wss://[a-z0-9-\.]+:61619$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.0", regexache.MustCompile(`^ssl://[0-9a-z.-]+:61617$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.1", regexache.MustCompile(`^amqp\+ssl://[0-9a-z.-]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.2", regexache.MustCompile(`^stomp\+ssl://[0-9a-z.-]+:61614$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.3", regexache.MustCompile(`^mqtt\+ssl://[0-9a-z.-]+:8883$`)), + resource.TestMatchResourceAttr(resourceName, "instances.1.endpoints.4", regexache.MustCompile(`^wss://[0-9a-z.-]+:61619$`)), ), }, { @@ -720,7 +720,7 @@ func TestAccMQBroker_AllFields_customVPC(t *testing.T) { testAccCheckBrokerExists(ctx, resourceName, &broker), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestCheckResourceAttr(resourceName, "configuration.0.revision", "3"), resource.TestCheckResourceAttr(resourceName, "maintenance_window_start_time.#", "1"), resource.TestCheckResourceAttr(resourceName, "maintenance_window_start_time.0.day_of_week", "TUESDAY"), @@ -735,7 +735,7 @@ func TestAccMQBroker_AllFields_customVPC(t *testing.T) { testAccCheckBrokerExists(ctx, resourceName, &broker), resource.TestCheckResourceAttr(resourceName, "broker_name", rName), resource.TestCheckResourceAttr(resourceName, "configuration.#", "1"), - resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[a-z0-9-]+$`)), + resource.TestMatchResourceAttr(resourceName, "configuration.0.id", regexache.MustCompile(`^c-[0-9a-z-]+$`)), resource.TestCheckResourceAttr(resourceName, "configuration.0.revision", "2"), ), }, @@ -1108,7 +1108,7 @@ func TestAccMQBroker_RabbitMQ_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "host_instance_type", "mq.t3.micro"), resource.TestCheckResourceAttr(resourceName, "instances.#", "1"), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "1"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^amqps://[a-z0-9-\.]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^amqps://[0-9a-z.-]+:5671$`)), resource.TestCheckResourceAttr(resourceName, "logs.#", "1"), resource.TestCheckResourceAttr(resourceName, "logs.0.general", "false"), resource.TestCheckResourceAttr(resourceName, "logs.0.audit", ""), @@ -1154,7 +1154,7 @@ func TestAccMQBroker_RabbitMQ_logs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "host_instance_type", "mq.t3.micro"), resource.TestCheckResourceAttr(resourceName, "instances.#", "1"), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "1"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^amqps://[a-z0-9-\.]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^amqps://[0-9a-z.-]+:5671$`)), resource.TestCheckResourceAttr(resourceName, "logs.#", "1"), resource.TestCheckResourceAttr(resourceName, "logs.0.general", "true"), resource.TestCheckResourceAttr(resourceName, "logs.0.audit", ""), @@ -1261,9 +1261,9 @@ func TestAccMQBroker_RabbitMQ_cluster(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "mq", regexache.MustCompile(`broker:+.`)), resource.TestCheckResourceAttr(resourceName, "instances.#", "1"), resource.TestMatchResourceAttr(resourceName, "instances.0.console_url", - regexache.MustCompile(`^https://[a-f0-9-]+\.mq.[a-z0-9-]+.amazonaws.com$`)), + regexache.MustCompile(`^https://[0-9a-f-]+\.mq.[0-9a-z-]+.amazonaws.com$`)), resource.TestCheckResourceAttr(resourceName, "instances.0.endpoints.#", "1"), - resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^amqps://[a-z0-9-\.]+:5671$`)), + resource.TestMatchResourceAttr(resourceName, "instances.0.endpoints.0", regexache.MustCompile(`^amqps://[0-9a-z.-]+:5671$`)), ), }, { diff --git a/internal/service/neptune/validate.go b/internal/service/neptune/validate.go index cac5ed85ec5d..567757c405ac 100644 --- a/internal/service/neptune/validate.go +++ b/internal/service/neptune/validate.go @@ -153,7 +153,7 @@ func validParamGroupNamePrefix(v interface{}, k string) (ws []string, errors []e func validSubnetGroupName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[ .0-9a-z-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9a-z_ .-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } @@ -170,7 +170,7 @@ func validSubnetGroupName(v interface{}, k string) (ws []string, errors []error) func validSubnetGroupNamePrefix(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[ .0-9a-z-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9a-z_ .-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } diff --git a/internal/service/networkfirewall/firewall_data_source.go b/internal/service/networkfirewall/firewall_data_source.go index 09db8213d144..6acdbd62a2b2 100644 --- a/internal/service/networkfirewall/firewall_data_source.go +++ b/internal/service/networkfirewall/firewall_data_source.go @@ -152,7 +152,7 @@ func DataSourceFirewall() *schema.Resource { Optional: true, Computed: true, AtLeastOneOf: []string{"arn", "name"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]{1,128}$`), "Must have 1-128 valid characters: a-z, A-Z, 0-9 and -(hyphen)"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]{1,128}$`), "Must have 1-128 valid characters: a-z, A-Z, 0-9 and -(hyphen)"), }, "subnet_change_protection": { Type: schema.TypeBool, diff --git a/internal/service/networkfirewall/firewall_policy.go b/internal/service/networkfirewall/firewall_policy.go index 6db3f5cbdcad..4305b6782cfe 100644 --- a/internal/service/networkfirewall/firewall_policy.go +++ b/internal/service/networkfirewall/firewall_policy.go @@ -71,7 +71,7 @@ func ResourceFirewallPolicy() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 32), validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_]+$`), "must contain only alphanumeric and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]+$`), "must contain only alphanumeric and underscore characters"), ), }, "ip_set": { diff --git a/internal/service/networkfirewall/firewall_policy_data_source.go b/internal/service/networkfirewall/firewall_policy_data_source.go index 8c156cf7dc62..1d7e87557151 100644 --- a/internal/service/networkfirewall/firewall_policy_data_source.go +++ b/internal/service/networkfirewall/firewall_policy_data_source.go @@ -120,7 +120,7 @@ func DataSourceFirewallPolicy() *schema.Resource { Type: schema.TypeString, Optional: true, AtLeastOneOf: []string{"arn", "name"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]{1,128}$`), "Must have 1-128 valid characters: a-z, A-Z, 0-9 and -(hyphen)"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]{1,128}$`), "Must have 1-128 valid characters: a-z, A-Z, 0-9 and -(hyphen)"), }, "tags": tftags.TagsSchemaComputed(), "update_token": { diff --git a/internal/service/networkfirewall/helpers.go b/internal/service/networkfirewall/helpers.go index 3807193f2094..386271d6ef38 100644 --- a/internal/service/networkfirewall/helpers.go +++ b/internal/service/networkfirewall/helpers.go @@ -103,7 +103,7 @@ func customActionSchema() *schema.Schema { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), "must contain only alphanumeric characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), "must contain only alphanumeric characters"), }, }, }, diff --git a/internal/service/networkfirewall/rule_group.go b/internal/service/networkfirewall/rule_group.go index 4420954c6012..c8c6169d7eb3 100644 --- a/internal/service/networkfirewall/rule_group.go +++ b/internal/service/networkfirewall/rule_group.go @@ -96,7 +96,7 @@ func ResourceRuleGroup() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 32), validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_]+$`), "must contain only alphanumeric and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]+$`), "must contain only alphanumeric and underscore characters"), ), }, }, @@ -359,7 +359,7 @@ func ResourceRuleGroup() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 32), validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_]+$`), "must contain only alphanumeric and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]+$`), "must contain only alphanumeric and underscore characters"), ), }, "ip_set": { @@ -390,7 +390,7 @@ func ResourceRuleGroup() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 32), validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_]+$`), "must contain only alphanumeric and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]+$`), "must contain only alphanumeric and underscore characters"), ), }, "port_set": { diff --git a/internal/service/networkmanager/core_network_policy_document_data_source.go b/internal/service/networkmanager/core_network_policy_document_data_source.go index 5c0d8b0992d2..091e60950574 100644 --- a/internal/service/networkmanager/core_network_policy_document_data_source.go +++ b/internal/service/networkmanager/core_network_policy_document_data_source.go @@ -111,7 +111,7 @@ func DataSourceCoreNetworkPolicyDocument() *schema.Resource { "segment": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z][A-Za-z0-9]{0,63}$`), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[A-Za-z][0-9A-Za-z]{0,63}$`), "must begin with a letter and contain only alphanumeric characters"), }, "tag_value_of_key": { @@ -197,7 +197,7 @@ func DataSourceCoreNetworkPolicyDocument() *schema.Resource { Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z][A-Za-z0-9]{0,63}$`), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[A-Za-z][0-9A-Za-z]{0,63}$`), "must begin with a letter and contain only alphanumeric characters"), }, }, @@ -206,14 +206,14 @@ func DataSourceCoreNetworkPolicyDocument() *schema.Resource { Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z][A-Za-z0-9]{0,63}$`), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[A-Za-z][0-9A-Za-z]{0,63}$`), "must begin with a letter and contain only alphanumeric characters"), }, }, "name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z][A-Za-z0-9]{0,63}$`), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[A-Za-z][0-9A-Za-z]{0,63}$`), "must begin with a letter and contain only alphanumeric characters"), }, "description": { @@ -294,7 +294,7 @@ func DataSourceCoreNetworkPolicyDocument() *schema.Resource { "segment": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z][A-Za-z0-9]{0,63}$`), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[A-Za-z][0-9A-Za-z]{0,63}$`), "must begin with a letter and contain only alphanumeric characters"), }, "share_with": setOfString, diff --git a/internal/service/networkmanager/transit_gateway_peering_test.go b/internal/service/networkmanager/transit_gateway_peering_test.go index 03b8ae343623..ea202e8e8683 100644 --- a/internal/service/networkmanager/transit_gateway_peering_test.go +++ b/internal/service/networkmanager/transit_gateway_peering_test.go @@ -25,7 +25,7 @@ func init() { func testAccErrorCheckSkip(t *testing.T) resource.ErrorCheckFunc { return acctest.ErrorCheckSkipMessagesMatches(t, - regexache.MustCompile(`Core Network edge location \([a-z0-9-]+\) not available`), + regexache.MustCompile(`Core Network edge location \([0-9a-z-]+\) not available`), ) } diff --git a/internal/service/opensearchserverless/collection.go b/internal/service/opensearchserverless/collection.go index e8f581a3545b..ea38cc69e651 100644 --- a/internal/service/opensearchserverless/collection.go +++ b/internal/service/opensearchserverless/collection.go @@ -106,7 +106,7 @@ func (r *resourceCollection) Schema(ctx context.Context, req resource.SchemaRequ }, Validators: []validator.String{ stringvalidator.LengthBetween(3, 32), - stringvalidator.RegexMatches(regexache.MustCompile(`^[a-z][a-z0-9-]+$`), + stringvalidator.RegexMatches(regexache.MustCompile(`^[a-z][0-9a-z-]+$`), `must start with any lower case letter and can can include any lower case letter, number, or "-"`), }, }, diff --git a/internal/service/opensearchserverless/security_policy_data_source.go b/internal/service/opensearchserverless/security_policy_data_source.go index e04da3765599..77eeda42d97f 100644 --- a/internal/service/opensearchserverless/security_policy_data_source.go +++ b/internal/service/opensearchserverless/security_policy_data_source.go @@ -41,7 +41,7 @@ func DataSourceSecurityPolicy() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 32), - validation.StringMatch(regexache.MustCompile(`^[a-z][a-z0-9-]+$`), `must start with any lower case letter and can include any lower case letter, number, or "-"`), + validation.StringMatch(regexache.MustCompile(`^[a-z][0-9a-z-]+$`), `must start with any lower case letter and can include any lower case letter, number, or "-"`), ), }, "policy": { diff --git a/internal/service/organizations/account.go b/internal/service/organizations/account.go index d446556d835f..1765b83d139d 100644 --- a/internal/service/organizations/account.go +++ b/internal/service/organizations/account.go @@ -89,7 +89,7 @@ func ResourceAccount() *schema.Resource { Type: schema.TypeString, Computed: true, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile("^(r-[0-9a-z]{4,32})|(ou-[0-9a-z]{4,32}-[a-z0-9]{8,32})$"), "see https://docs.aws.amazon.com/organizations/latest/APIReference/API_MoveAccount.html#organizations-MoveAccount-request-DestinationParentId"), + ValidateFunc: validation.StringMatch(regexache.MustCompile("^(r-[0-9a-z]{4,32})|(ou-[0-9a-z]{4,32}-[0-9a-z]{8,32})$"), "see https://docs.aws.amazon.com/organizations/latest/APIReference/API_MoveAccount.html#organizations-MoveAccount-request-DestinationParentId"), }, "role_name": { ForceNew: true, diff --git a/internal/service/organizations/organization_test.go b/internal/service/organizations/organization_test.go index 4338d07b6fb4..3fcf1146ebd6 100644 --- a/internal/service/organizations/organization_test.go +++ b/internal/service/organizations/organization_test.go @@ -47,7 +47,7 @@ func testAccOrganization_basic(t *testing.T) { acctest.CheckResourceAttrAccountID(resourceName, "master_account_id"), resource.TestCheckResourceAttr(resourceName, "non_master_accounts.#", "0"), resource.TestCheckResourceAttr(resourceName, "roots.#", "1"), - resource.TestMatchResourceAttr(resourceName, "roots.0.id", regexache.MustCompile(`r-[a-z0-9]{4,32}`)), + resource.TestMatchResourceAttr(resourceName, "roots.0.id", regexache.MustCompile(`r-[0-9a-z]{4,32}`)), resource.TestCheckResourceAttrSet(resourceName, "roots.0.name"), resource.TestCheckResourceAttrSet(resourceName, "roots.0.arn"), resource.TestCheckResourceAttr(resourceName, "roots.0.policy_types.#", "0"), diff --git a/internal/service/organizations/organizational_unit.go b/internal/service/organizations/organizational_unit.go index f9a17efc0c21..6030b63a5cdb 100644 --- a/internal/service/organizations/organizational_unit.go +++ b/internal/service/organizations/organizational_unit.go @@ -75,7 +75,7 @@ func ResourceOrganizationalUnit() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile("^(r-[0-9a-z]{4,32})|(ou-[0-9a-z]{4,32}-[a-z0-9]{8,32})$"), "see https://docs.aws.amazon.com/organizations/latest/APIReference/API_CreateOrganizationalUnit.html#organizations-CreateOrganizationalUnit-request-ParentId"), + ValidateFunc: validation.StringMatch(regexache.MustCompile("^(r-[0-9a-z]{4,32})|(ou-[0-9a-z]{4,32}-[0-9a-z]{8,32})$"), "see https://docs.aws.amazon.com/organizations/latest/APIReference/API_CreateOrganizationalUnit.html#organizations-CreateOrganizationalUnit-request-ParentId"), }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), diff --git a/internal/service/outposts/outpost_assets_data_source.go b/internal/service/outposts/outpost_assets_data_source.go index 60f92bf28876..c11c83f68d75 100644 --- a/internal/service/outposts/outpost_assets_data_source.go +++ b/internal/service/outposts/outpost_assets_data_source.go @@ -41,7 +41,7 @@ func DataSourceOutpostAssets() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(1, 50), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9-]*$`), "must match [a-zA-Z0-9-]"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]*$`), "must match [0-9A-Za-z-]"), ), }, }, diff --git a/internal/service/outposts/outpost_data_source_test.go b/internal/service/outposts/outpost_data_source_test.go index 3b4f2ae521b1..2012b726208a 100644 --- a/internal/service/outposts/outpost_data_source_test.go +++ b/internal/service/outposts/outpost_data_source_test.go @@ -29,7 +29,7 @@ func TestAccOutpostsOutpostDataSource_id(t *testing.T) { resource.TestMatchResourceAttr(dataSourceName, "availability_zone", regexache.MustCompile(`^.+$`)), resource.TestMatchResourceAttr(dataSourceName, "availability_zone_id", regexache.MustCompile(`^.+$`)), resource.TestCheckResourceAttrSet(dataSourceName, "description"), - resource.TestMatchResourceAttr(dataSourceName, "lifecycle_status", regexache.MustCompile(`^[ A-Za-z]+$`)), + resource.TestMatchResourceAttr(dataSourceName, "lifecycle_status", regexache.MustCompile(`^[A-Za-z ]+$`)), resource.TestMatchResourceAttr(dataSourceName, "id", regexache.MustCompile(`^op-.+$`)), resource.TestMatchResourceAttr(dataSourceName, "name", regexache.MustCompile(`^.+$`)), resource.TestMatchResourceAttr(dataSourceName, "owner_id", regexache.MustCompile(`\d{12}`)), diff --git a/internal/service/pipes/pipe.go b/internal/service/pipes/pipe.go index a1f2fc72a5a0..2562143fe3ed 100644 --- a/internal/service/pipes/pipe.go +++ b/internal/service/pipes/pipe.go @@ -80,7 +80,7 @@ func resourcePipe() *schema.Resource { ConflictsWith: []string{"name_prefix"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z0-9]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), ), }, "name_prefix": { @@ -91,7 +91,7 @@ func resourcePipe() *schema.Resource { ConflictsWith: []string{"name"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 64-id.UniqueIDSuffixLength), - validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z0-9]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), ), }, "role_arn": { @@ -105,7 +105,7 @@ func resourcePipe() *schema.Resource { ForceNew: true, ValidateFunc: validation.Any( verify.ValidARN, - validation.StringMatch(regexache.MustCompile(`^smk://(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]):[0-9]{1,5}|arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\-]+):([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.+)$`), ""), + validation.StringMatch(regexache.MustCompile(`^smk://(([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z])\.)*([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]):[0-9]{1,5}|arn:(aws[0-9A-Za-z-]*):([0-9A-Za-z-]+):([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.+)$`), ""), ), }, "source_parameters": sourceParametersSchema(), diff --git a/internal/service/pipes/source_parameters.go b/internal/service/pipes/source_parameters.go index fe7e122370cd..b20c0ec540c1 100644 --- a/internal/service/pipes/source_parameters.go +++ b/internal/service/pipes/source_parameters.go @@ -285,7 +285,7 @@ func sourceParametersSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 200), - validation.StringMatch(regexache.MustCompile(`^[^.]([a-zA-Z0-9\-_.]+)$`), ""), + validation.StringMatch(regexache.MustCompile(`^[^.]([0-9A-Za-z_.-]+)$`), ""), ), }, "credentials": { @@ -325,7 +325,7 @@ func sourceParametersSchema() *schema.Schema { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 249), - validation.StringMatch(regexache.MustCompile(`^[^.]([a-zA-Z0-9\-_.]+)$`), ""), + validation.StringMatch(regexache.MustCompile(`^[^.]([0-9A-Za-z_.-]+)$`), ""), ), }, }, @@ -387,7 +387,7 @@ func sourceParametersSchema() *schema.Schema { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 200), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-\/*:_+=.@-]*$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_\/*:+=.@-]*$`), ""), ), }, }, @@ -417,7 +417,7 @@ func sourceParametersSchema() *schema.Schema { Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(1, 300), - validation.StringMatch(regexache.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]):[0-9]{1,5}$`), ""), + validation.StringMatch(regexache.MustCompile(`^(([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z])\.)*([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]):[0-9]{1,5}$`), ""), ), }, }, @@ -433,7 +433,7 @@ func sourceParametersSchema() *schema.Schema { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 200), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-\/*:_+=.@-]*$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_\/*:+=.@-]*$`), ""), ), }, "credentials": { @@ -488,7 +488,7 @@ func sourceParametersSchema() *schema.Schema { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 249), - validation.StringMatch(regexache.MustCompile(`^[^.]([a-zA-Z0-9\-_.]+)$`), ""), + validation.StringMatch(regexache.MustCompile(`^[^.]([0-9A-Za-z_.-]+)$`), ""), ), }, "vpc": { @@ -505,7 +505,7 @@ func sourceParametersSchema() *schema.Schema { Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(1, 1024), - validation.StringMatch(regexache.MustCompile(`^sg-[0-9a-zA-Z]*$`), ""), + validation.StringMatch(regexache.MustCompile(`^sg-[0-9A-Za-z]*$`), ""), ), }, }, diff --git a/internal/service/pipes/target_parameters.go b/internal/service/pipes/target_parameters.go index b68f7c326925..302b6dc92b23 100644 --- a/internal/service/pipes/target_parameters.go +++ b/internal/service/pipes/target_parameters.go @@ -275,7 +275,7 @@ func targetParametersSchema() *schema.Schema { Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(1, 1024), - validation.StringMatch(regexache.MustCompile(`^sg-[0-9a-zA-Z]*|(\$(\.[\w/_-]+(\[(\d+|\*)\])*)*)$`), ""), + validation.StringMatch(regexache.MustCompile(`^sg-[0-9A-Za-z]*|(\$(\.[\w/_-]+(\[(\d+|\*)\])*)*)$`), ""), ), }, }, @@ -529,7 +529,7 @@ func targetParametersSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 50), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9\-]+[\.][A-Za-z0-9\-]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+[\.][0-9A-Za-z-]+$`), ""), ), }, "resources": { @@ -737,7 +737,7 @@ func targetParametersSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*|(\$(\.[\w/_-]+(\[(\d+|\*)\])*)*)$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*|(\$(\.[\w/_-]+(\[(\d+|\*)\])*)*)$`), ""), ), }, "value": { diff --git a/internal/service/qldb/ledger.go b/internal/service/qldb/ledger.go index a70c2350be09..a52bb31dae89 100644 --- a/internal/service/qldb/ledger.go +++ b/internal/service/qldb/ledger.go @@ -70,7 +70,7 @@ func resourceLedger() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 32), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_-]+`), "must contain only alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+`), "must contain only alphanumeric characters, underscores, and hyphens"), ), }, "permissions_mode": { diff --git a/internal/service/qldb/ledger_data_source.go b/internal/service/qldb/ledger_data_source.go index 588fc7cde883..ffce497a5075 100644 --- a/internal/service/qldb/ledger_data_source.go +++ b/internal/service/qldb/ledger_data_source.go @@ -38,7 +38,7 @@ func dataSourceLedger() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 32), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9_-]+`), "must contain only alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+`), "must contain only alphanumeric characters, underscores, and hyphens"), ), }, "permissions_mode": { diff --git a/internal/service/quicksight/group.go b/internal/service/quicksight/group.go index e83960f3508f..9b711d94f6ea 100644 --- a/internal/service/quicksight/group.go +++ b/internal/service/quicksight/group.go @@ -68,7 +68,7 @@ func ResourceGroup() *schema.Resource { Default: DefaultGroupNamespace, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, } diff --git a/internal/service/quicksight/group_data_source.go b/internal/service/quicksight/group_data_source.go index e15ec789359f..49fe46b0a4b4 100644 --- a/internal/service/quicksight/group_data_source.go +++ b/internal/service/quicksight/group_data_source.go @@ -48,7 +48,7 @@ func DataSourceGroup() *schema.Resource { Default: DefaultGroupNamespace, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, "principal_id": { diff --git a/internal/service/quicksight/group_membership.go b/internal/service/quicksight/group_membership.go index 82866cec61e0..22c3a2d9744f 100644 --- a/internal/service/quicksight/group_membership.go +++ b/internal/service/quicksight/group_membership.go @@ -59,7 +59,7 @@ func ResourceGroupMembership() *schema.Resource { Default: "default", ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, } diff --git a/internal/service/quicksight/schema/template_filter.go b/internal/service/quicksight/schema/template_filter.go index 93dad825a052..cc4bfdcc7a34 100644 --- a/internal/service/quicksight/schema/template_filter.go +++ b/internal/service/quicksight/schema/template_filter.go @@ -70,7 +70,7 @@ func categoryFilterSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+`), ""), ), }, "select_all_options": stringSchema(false, validation.StringInSlice(quicksight.CategoryFilterSelectAllOptions_Values(), false)), @@ -336,7 +336,7 @@ func numericRangeFilterValueSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), }, "static_value": { @@ -361,7 +361,7 @@ func timeRangeFilterValueSchema() *schema.Schema { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), }, "rolling_date": rollingDateConfigurationSchema(), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_RollingDateConfiguration.html, diff --git a/internal/service/quicksight/schema/template_format.go b/internal/service/quicksight/schema/template_format.go index 0dafa585ac5c..5c126bc2d575 100644 --- a/internal/service/quicksight/schema/template_format.go +++ b/internal/service/quicksight/schema/template_format.go @@ -227,7 +227,7 @@ func fontConfigurationSchema() *schema.Schema { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "font_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "font_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "font_decoration": stringSchema(false, validation.StringInSlice(quicksight.FontDecoration_Values(), false)), "font_size": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_FontSize.html Type: schema.TypeList, diff --git a/internal/service/quicksight/schema/template_parameter.go b/internal/service/quicksight/schema/template_parameter.go index 09bb5ff614bb..f26b13251c44 100644 --- a/internal/service/quicksight/schema/template_parameter.go +++ b/internal/service/quicksight/schema/template_parameter.go @@ -28,7 +28,7 @@ func dateTimeParameterDeclarationSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), }, "default_values": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DateTimeDefaultValues.html @@ -88,7 +88,7 @@ func decimalParameterDeclarationSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), }, "parameter_value_type": stringSchema(true, validation.StringInSlice(quicksight.ParameterValueType_Values(), false)), @@ -145,7 +145,7 @@ func integerParameterDeclarationSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), }, "parameter_value_type": stringSchema(true, validation.StringInSlice(quicksight.ParameterValueType_Values(), false)), @@ -202,7 +202,7 @@ func stringParameterDeclarationSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), }, "parameter_value_type": stringSchema(true, validation.StringInSlice(quicksight.ParameterValueType_Values(), false)), @@ -408,7 +408,7 @@ func parameterNameSchema(required bool) *schema.Schema { Optional: !required, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), ""), ), } } diff --git a/internal/service/quicksight/schema/template_sheet.go b/internal/service/quicksight/schema/template_sheet.go index bcd2d867ccf5..cfedc66a6ca6 100644 --- a/internal/service/quicksight/schema/template_sheet.go +++ b/internal/service/quicksight/schema/template_sheet.go @@ -458,7 +458,7 @@ func freeFormLayoutElementsSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}(?:[A-F0-9]{2})?$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}(?:[0-9A-F]{2})?$`), "")), "visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), }, }, @@ -470,7 +470,7 @@ func freeFormLayoutElementsSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}(?:[A-F0-9]{2})?$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}(?:[0-9A-F]{2})?$`), "")), "visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), }, }, @@ -515,7 +515,7 @@ func freeFormLayoutElementsSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}(?:[A-F0-9]{2})?$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}(?:[0-9A-F]{2})?$`), "")), "visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), }, }, diff --git a/internal/service/quicksight/schema/visual.go b/internal/service/quicksight/schema/visual.go index f25494b09ead..cdae4d34e945 100644 --- a/internal/service/quicksight/schema/visual.go +++ b/internal/service/quicksight/schema/visual.go @@ -156,7 +156,7 @@ func visualPaletteSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "chart_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "chart_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "color_map": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataPathColor.html Type: schema.TypeList, Optional: true, @@ -164,7 +164,7 @@ func visualPaletteSchema() *schema.Schema { MaxItems: 5000, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(true, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(true, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "element": dataPathValueSchema(1), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataPathValue.html "time_granularity": stringSchema(false, validation.StringInSlice(quicksight.TimeGranularity_Values(), false)), }, @@ -383,7 +383,7 @@ func colorScaleSchema() *schema.Schema { MaxItems: 3, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "data_value": { Type: schema.TypeFloat, Optional: true, @@ -398,7 +398,7 @@ func colorScaleSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "data_value": { Type: schema.TypeFloat, Optional: true, @@ -488,7 +488,7 @@ func dataLabelOptionsSchema() *schema.Schema { }, }, }, - "label_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "label_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "label_content": stringSchema(false, validation.StringInSlice(quicksight.DataLabelContent_Values(), false)), "label_font_configuration": fontConfigurationSchema(), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_FontConfiguration.html "measure_label_visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), diff --git a/internal/service/quicksight/schema/visual_chart_configuration.go b/internal/service/quicksight/schema/visual_chart_configuration.go index e29a089dba11..6335e3c0f0e8 100644 --- a/internal/service/quicksight/schema/visual_chart_configuration.go +++ b/internal/service/quicksight/schema/visual_chart_configuration.go @@ -338,7 +338,7 @@ func referenceLineSchema(maxItems int) *schema.Schema { }, }, }, - "font_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "font_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "font_configuration": fontConfigurationSchema(), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_FontConfiguration.html "horizontal_position": stringSchema(false, validation.StringInSlice(quicksight.ReferenceLineLabelHorizontalPosition_Values(), false)), "value_label_configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ReferenceLineValueLabelConfiguration.html @@ -365,7 +365,7 @@ func referenceLineSchema(maxItems int) *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "pattern": stringSchema(false, validation.StringInSlice(quicksight.ReferenceLinePatternType_Values(), false)), }, }, @@ -400,9 +400,9 @@ func smallMultiplesOptionsSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "background_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}(?:[A-F0-9]{2})?$`), "")), + "background_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}(?:[0-9A-F]{2})?$`), "")), "background_visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), - "border_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}(?:[A-F0-9]{2})?$`), "")), + "border_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}(?:[0-9A-F]{2})?$`), "")), "border_style": stringSchema(false, validation.StringInSlice(quicksight.PanelBorderStyle_Values(), false)), "border_thickness": { Type: schema.TypeString, diff --git a/internal/service/quicksight/schema/visual_conditional_formatting.go b/internal/service/quicksight/schema/visual_conditional_formatting.go index 01550deaeae5..f788bb186ed0 100644 --- a/internal/service/quicksight/schema/visual_conditional_formatting.go +++ b/internal/service/quicksight/schema/visual_conditional_formatting.go @@ -44,7 +44,7 @@ func conditionalFormattingColorSchema() *schema.Schema { Type: schema.TypeFloat, Required: true, }, - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "data_value": { Type: schema.TypeFloat, Optional: true, @@ -66,7 +66,7 @@ func conditionalFormattingColorSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), }, }, @@ -91,7 +91,7 @@ func conditionalFormattingIconSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), "icon_options": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ConditionalFormattingCustomIconOptions.html Type: schema.TypeList, diff --git a/internal/service/quicksight/schema/visual_funnel_chart.go b/internal/service/quicksight/schema/visual_funnel_chart.go index 368c685619ad..4f1520fab595 100644 --- a/internal/service/quicksight/schema/visual_funnel_chart.go +++ b/internal/service/quicksight/schema/visual_funnel_chart.go @@ -38,7 +38,7 @@ func funnelChartVisualSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "category_label_visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), - "label_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "label_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "label_font_configuration": fontConfigurationSchema(), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_FontConfiguration.html "measure_data_label_style": stringSchema(false, validation.StringInSlice(quicksight.FunnelChartMeasureDataLabelStyle_Values(), false)), "measure_label_visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), diff --git a/internal/service/quicksight/schema/visual_geospatial_map.go b/internal/service/quicksight/schema/visual_geospatial_map.go index 978fbc001db7..60e0e749cb9a 100644 --- a/internal/service/quicksight/schema/visual_geospatial_map.go +++ b/internal/service/quicksight/schema/visual_geospatial_map.go @@ -81,7 +81,7 @@ func geospatialMapVisualSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), }, }, }, diff --git a/internal/service/quicksight/schema/visual_line_chart.go b/internal/service/quicksight/schema/visual_line_chart.go index 9f14f5c09b77..793c46a94b25 100644 --- a/internal/service/quicksight/schema/visual_line_chart.go +++ b/internal/service/quicksight/schema/visual_line_chart.go @@ -314,7 +314,7 @@ func lineChartMarkerStyleSettingsSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "marker_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "marker_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "marker_shape": stringSchema(false, validation.StringInSlice(quicksight.LineChartMarkerShape_Values(), false)), "marker_size": { Type: schema.TypeString, diff --git a/internal/service/quicksight/schema/visual_pivot_table.go b/internal/service/quicksight/schema/visual_pivot_table.go index 5ca76a818f96..cbe7c9f5b913 100644 --- a/internal/service/quicksight/schema/visual_pivot_table.go +++ b/internal/service/quicksight/schema/visual_pivot_table.go @@ -255,7 +255,7 @@ func tableBorderOptionsSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "style": stringSchema(false, validation.StringInSlice(quicksight.TableBorderStyle_Values(), false)), "thickness": intSchema(false, validation.IntBetween(1, 4)), }, @@ -271,7 +271,7 @@ func tableCellStyleSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "background_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "background_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GlobalTableBorderOptions.html Type: schema.TypeList, Optional: true, @@ -379,7 +379,7 @@ func rowAlternateColorOptionsSchema() *schema.Schema { Optional: true, MinItems: 1, MaxItems: 1, - Elem: &schema.Schema{Type: schema.TypeString, ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")}, + Elem: &schema.Schema{Type: schema.TypeString, ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")}, }, "status": stringSchema(false, validation.StringInSlice(quicksight.Status_Values(), false)), }, diff --git a/internal/service/quicksight/schema/visual_radar_chart.go b/internal/service/quicksight/schema/visual_radar_chart.go index 002cc61bf43f..8047290f9aa2 100644 --- a/internal/service/quicksight/schema/visual_radar_chart.go +++ b/internal/service/quicksight/schema/visual_radar_chart.go @@ -30,8 +30,8 @@ func radarChartVisualSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "alternate_band_colors_visibility": stringSchema(false, validation.StringInSlice(quicksight.Visibility_Values(), false)), - "alternate_band_even_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), - "alternate_band_odd_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "alternate_band_even_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), + "alternate_band_odd_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), "base_series_settings": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_RadarChartSeriesSettings.html Type: schema.TypeList, Optional: true, diff --git a/internal/service/quicksight/schema/visual_table.go b/internal/service/quicksight/schema/visual_table.go index d06f3bb8eafe..58281f2256b2 100644 --- a/internal/service/quicksight/schema/visual_table.go +++ b/internal/service/quicksight/schema/visual_table.go @@ -241,8 +241,8 @@ func tableVisualSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "field_id": stringSchema(true, validation.StringLenBetween(1, 512)), - "negative_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), - "positive_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), "")), + "negative_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), + "positive_color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), }, }, }, diff --git a/internal/service/quicksight/theme.go b/internal/service/quicksight/theme.go index b3b07ce31539..a1364d1bc0b2 100644 --- a/internal/service/quicksight/theme.go +++ b/internal/service/quicksight/theme.go @@ -82,13 +82,13 @@ func ResourceTheme() *schema.Resource { MaxItems: 20, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, }, "empty_fill_color": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "min_max_gradient": { Type: schema.TypeList, @@ -97,7 +97,7 @@ func ResourceTheme() *schema.Resource { MaxItems: 2, Elem: &schema.Schema{ Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, }, }, @@ -200,82 +200,82 @@ func ResourceTheme() *schema.Resource { "accent": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "accent_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "danger": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "danger_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "dimension": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "dimension_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "measure": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "measure_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "primary_background": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "primary_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "secondary_background": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "secondary_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "success": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "success_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "warning": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, "warning_foreground": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[A-F0-9]{6}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), ""), }, }, }, diff --git a/internal/service/quicksight/user.go b/internal/service/quicksight/user.go index 92dbe320fc29..4b62682f14d7 100644 --- a/internal/service/quicksight/user.go +++ b/internal/service/quicksight/user.go @@ -75,7 +75,7 @@ func ResourceUser() *schema.Resource { Default: DefaultUserNamespace, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, diff --git a/internal/service/quicksight/user_data_source.go b/internal/service/quicksight/user_data_source.go index 13b5fae994a6..f5e0fe98e57b 100644 --- a/internal/service/quicksight/user_data_source.go +++ b/internal/service/quicksight/user_data_source.go @@ -52,7 +52,7 @@ func DataSourceUser() *schema.Resource { Default: DefaultUserNamespace, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, "principal_id": { diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index eb7c8e550901..d5be7444a1a2 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -2368,7 +2368,7 @@ func parseDBInstanceARN(s string) (dbInstanceARN, error) { // "db-BE6UI2KLPQP3OVDYD74ZEV6NUM" rather than a DB identifier. However, in some cases only // the identifier is available, and can be used. func findDBInstanceByIDSDKv1(ctx context.Context, conn *rds.RDS, id string) (*rds.DBInstance, error) { - idLooksLikeDbiResourceId := regexache.MustCompile(`^db-[a-zA-Z0-9]{2,255}$`).MatchString(id) + idLooksLikeDbiResourceId := regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) input := &rds.DescribeDBInstancesInput{} if idLooksLikeDbiResourceId { @@ -2447,7 +2447,7 @@ func findDBInstancesSDKv1(ctx context.Context, conn *rds.RDS, input *rds.Describ func findDBInstanceByIDSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id string) (*types.DBInstance, error) { input := &rds_sdkv2.DescribeDBInstancesInput{} - if regexache.MustCompile(`^db-[a-zA-Z0-9]{2,255}$`).MatchString(id) { + if regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) { input.Filters = []types.Filter{ { Name: aws.String("dbi-resource-id"), @@ -2461,7 +2461,7 @@ func findDBInstanceByIDSDKv2(ctx context.Context, conn *rds_sdkv2.Client, id str output, err := conn.DescribeDBInstances(ctx, input) // in case a DB has an *identifier* starting with "db-"" - if regexache.MustCompile(`^db-[a-zA-Z0-9]{2,255}$`).MatchString(id) && (output == nil || len(output.DBInstances) == 0) { + if regexache.MustCompile(`^db-[0-9A-Za-z]{2,255}$`).MatchString(id) && (output == nil || len(output.DBInstances) == 0) { input = &rds_sdkv2.DescribeDBInstancesInput{ DBInstanceIdentifier: aws.String(id), } diff --git a/internal/service/rds/snapshot_copy.go b/internal/service/rds/snapshot_copy.go index a65b5616a701..0d5c055b7c27 100644 --- a/internal/service/rds/snapshot_copy.go +++ b/internal/service/rds/snapshot_copy.go @@ -133,7 +133,7 @@ func ResourceSnapshotCopy() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9][\w-]+`), "must contain only alphanumeric, and hyphen (-) characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z][\w-]+`), "must contain only alphanumeric, and hyphen (-) characters"), ), }, "vpc_id": { diff --git a/internal/service/rds/validate.go b/internal/service/rds/validate.go index f31cd8a09778..6a627922034a 100644 --- a/internal/service/rds/validate.go +++ b/internal/service/rds/validate.go @@ -116,7 +116,7 @@ func validParamGroupNamePrefix(v interface{}, k string) (ws []string, errors []e func validSubnetGroupName(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[ .0-9a-z-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9a-z_ .-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } @@ -133,7 +133,7 @@ func validSubnetGroupName(v interface{}, k string) (ws []string, errors []error) func validSubnetGroupNamePrefix(v interface{}, k string) (ws []string, errors []error) { value := v.(string) - if !regexache.MustCompile(`^[ .0-9a-z-_]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9a-z_ .-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only lowercase alphanumeric characters, hyphens, underscores, periods, and spaces allowed in %q", k)) } diff --git a/internal/service/redshift/scheduled_action.go b/internal/service/redshift/scheduled_action.go index 0d366fbecbac..4da32b7ce16f 100644 --- a/internal/service/redshift/scheduled_action.go +++ b/internal/service/redshift/scheduled_action.go @@ -55,7 +55,7 @@ func ResourceScheduledAction() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-z0-9-]{1,63}$`), ""), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z-]{1,63}$`), ""), }, "schedule": { Type: schema.TypeString, diff --git a/internal/service/redshift/scheduled_action_test.go b/internal/service/redshift/scheduled_action_test.go index 5de8cbf524f6..9d231730c860 100644 --- a/internal/service/redshift/scheduled_action_test.go +++ b/internal/service/redshift/scheduled_action_test.go @@ -488,7 +488,7 @@ resource "aws_redshift_scheduled_action" "test" { func TestAccRedshiftScheduledAction_validScheduleName(t *testing.T) { t.Parallel() - var f = validation.StringMatch(regexache.MustCompile(`^[a-z0-9-]{1,63}$`), "") + var f = validation.StringMatch(regexache.MustCompile(`^[0-9a-z-]{1,63}$`), "") validIds := []string{ "tf-test-schedule-action-1", diff --git a/internal/service/resourceexplorer2/view.go b/internal/service/resourceexplorer2/view.go index 3cef19d62679..55b4d8f072e5 100644 --- a/internal/service/resourceexplorer2/view.go +++ b/internal/service/resourceexplorer2/view.go @@ -73,7 +73,7 @@ func (r *resourceView) Schema(ctx context.Context, request resource.SchemaReques }, Validators: []validator.String{ stringvalidator.LengthAtMost(64), - stringvalidator.RegexMatches(regexache.MustCompile(`^[a-zA-Z0-9\-]+$`), `can include letters, digits, and the dash (-) character`), + stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9A-Za-z-]+$`), `can include letters, digits, and the dash (-) character`), }, }, names.AttrTags: tftags.TagsAttribute(), diff --git a/internal/service/route53/cidr_collection.go b/internal/service/route53/cidr_collection.go index 7d5d6309d497..367658ec004b 100644 --- a/internal/service/route53/cidr_collection.go +++ b/internal/service/route53/cidr_collection.go @@ -55,7 +55,7 @@ func (r *resourceCIDRCollection) Schema(ctx context.Context, req resource.Schema }, Validators: []validator.String{ stringvalidator.LengthAtMost(64), - stringvalidator.RegexMatches(regexache.MustCompile(`^[a-zA-Z0-9_\-]+$`), `can include letters, digits, underscore (_) and the dash (-) character`), + stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), `can include letters, digits, underscore (_) and the dash (-) character`), }, }, "version": schema.Int64Attribute{ diff --git a/internal/service/route53/cidr_location.go b/internal/service/route53/cidr_location.go index 00df54da378a..15f6c257eb34 100644 --- a/internal/service/route53/cidr_location.go +++ b/internal/service/route53/cidr_location.go @@ -66,7 +66,7 @@ func (r *resourceCIDRLocation) Schema(ctx context.Context, req resource.SchemaRe }, Validators: []validator.String{ stringvalidator.LengthAtMost(16), - stringvalidator.RegexMatches(regexache.MustCompile(`^[a-zA-Z0-9_\-]+$`), `can include letters, digits, underscore (_) and the dash (-) character`), + stringvalidator.RegexMatches(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), `can include letters, digits, underscore (_) and the dash (-) character`), }, }, }, diff --git a/internal/service/route53/key_signing_key.go b/internal/service/route53/key_signing_key.go index 1d73505b5850..c557393fc750 100644 --- a/internal/service/route53/key_signing_key.go +++ b/internal/service/route53/key_signing_key.go @@ -77,7 +77,7 @@ func ResourceKeySigningKey() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 128), - validation.StringMatch(regexache.MustCompile("^[a-zA-Z0-9._-]"), "must contain only alphanumeric characters, periods, underscores, or hyphens"), + validation.StringMatch(regexache.MustCompile("^[0-9A-Za-z_.-]"), "must contain only alphanumeric characters, periods, underscores, or hyphens"), ), }, "public_key": { diff --git a/internal/service/route53/key_signing_key_test.go b/internal/service/route53/key_signing_key_test.go index 565a432e18cb..6cffcff2675d 100644 --- a/internal/service/route53/key_signing_key_test.go +++ b/internal/service/route53/key_signing_key_test.go @@ -43,14 +43,14 @@ func TestAccRoute53KeySigningKey_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "digest_algorithm_mnemonic", "SHA-256"), resource.TestCheckResourceAttr(resourceName, "digest_algorithm_type", "2"), resource.TestMatchResourceAttr(resourceName, "digest_value", regexache.MustCompile(`^[0-9A-F]+$`)), - resource.TestMatchResourceAttr(resourceName, "dnskey_record", regexache.MustCompile(`^257 [0-9]+ [0-9]+ [a-zA-Z0-9+/]+={0,3}$`)), + resource.TestMatchResourceAttr(resourceName, "dnskey_record", regexache.MustCompile(`^257 [0-9]+ [0-9]+ [0-9A-Za-z+/]+={0,3}$`)), resource.TestMatchResourceAttr(resourceName, "ds_record", regexache.MustCompile(`^[0-9]+ [0-9]+ [0-9]+ [0-9A-F]+$`)), resource.TestCheckResourceAttr(resourceName, "flag", "257"), resource.TestCheckResourceAttrPair(resourceName, "hosted_zone_id", route53ZoneResourceName, "id"), resource.TestCheckResourceAttrPair(resourceName, "key_management_service_arn", kmsKeyResourceName, "arn"), resource.TestMatchResourceAttr(resourceName, "key_tag", regexache.MustCompile(`^[0-9]+$`)), resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestMatchResourceAttr(resourceName, "public_key", regexache.MustCompile(`^[a-zA-Z0-9+/]+={0,3}$`)), + resource.TestMatchResourceAttr(resourceName, "public_key", regexache.MustCompile(`^[0-9A-Za-z+/]+={0,3}$`)), resource.TestCheckResourceAttr(resourceName, "signing_algorithm_mnemonic", "ECDSAP256SHA256"), resource.TestCheckResourceAttr(resourceName, "signing_algorithm_type", "13"), resource.TestCheckResourceAttr(resourceName, "status", tfroute53.KeySigningKeyStatusActive), diff --git a/internal/service/route53domains/registered_domain.go b/internal/service/route53domains/registered_domain.go index c203c6723045..cfa6c07f5fa9 100644 --- a/internal/service/route53domains/registered_domain.go +++ b/internal/service/route53domains/registered_domain.go @@ -191,7 +191,7 @@ func ResourceRegisteredDomain() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9_\-.]*`), "can contain only alphabetical characters (A-Z or a-z), numeric characters (0-9), underscore (_), the minus sign (-), and the period (.)"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z_.-]*`), "can contain only alphabetical characters (A-Z or a-z), numeric characters (0-9), underscore (_), the minus sign (-), and the period (.)"), ), }, }, diff --git a/internal/service/route53resolver/validate.go b/internal/service/route53resolver/validate.go index e84cc5983cb4..e78fa895c527 100644 --- a/internal/service/route53resolver/validate.go +++ b/internal/service/route53resolver/validate.go @@ -12,7 +12,7 @@ import ( func validResolverName(v interface{}, k string) (ws []string, errors []error) { // Type: String // Length Constraints: Maximum length of 64. - // Pattern: (?!^[0-9]+$)([a-zA-Z0-9-_' ']+) + // Pattern: (?!^[0-9]+$)([0-9A-Za-z-_' ']+) value := v.(string) // re2 doesn't support negative lookaheads so check for single numeric character explicitly. @@ -20,7 +20,7 @@ func validResolverName(v interface{}, k string) (ws []string, errors []error) { errors = append(errors, fmt.Errorf( "%q cannot be a single digit", k)) } - if !regexache.MustCompile(`^[a-zA-Z0-9-_' ']+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z_' '-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "only alphanumeric characters, '-', '_' and ' ' are allowed in %q", k)) } diff --git a/internal/service/s3/bucket_acl.go b/internal/service/s3/bucket_acl.go index 537adc97d3f0..20083b1f5a24 100644 --- a/internal/service/s3/bucket_acl.go +++ b/internal/service/s3/bucket_acl.go @@ -468,15 +468,15 @@ func BucketACLParseResourceID(id string) (string, string, string, error) { // ~> On or after 3/1/2018: Bucket names can consist of only lowercase letters, numbers, dots, and hyphens; Max 63 characters // ~> Before 3/1/2018: Bucket names could consist of uppercase letters and underscores if in us-east-1; Max 255 characters // Reference: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html - bucketRegex := regexache.MustCompile(`^([a-z0-9.-]{1,63}|[a-zA-Z0-9.\-_]{1,255})$`) + bucketRegex := regexache.MustCompile(`^([0-9a-z.-]{1,63}|[0-9A-Za-z_.-]{1,255})$`) // For bucket and accountID in the ID e.g. bucket,123456789101 // ~> Account IDs must consist of 12 digits - bucketAndOwnerRegex := regexache.MustCompile(`^([a-z0-9.-]{1,63}|[a-zA-Z0-9.\-_]{1,255}),\d{12}$`) + bucketAndOwnerRegex := regexache.MustCompile(`^([0-9a-z.-]{1,63}|[0-9A-Za-z_.-]{1,255}),\d{12}$`) // For bucket and ACL in the ID e.g. bucket,public-read // ~> (Canned) ACL values include: private, public-read, public-read-write, authenticated-read, aws-exec-read, and log-delivery-write - bucketAndAclRegex := regexache.MustCompile(`^([a-z0-9.-]{1,63}|[a-zA-Z0-9.\-_]{1,255}),[a-z-]+$`) + bucketAndAclRegex := regexache.MustCompile(`^([0-9a-z.-]{1,63}|[0-9A-Za-z_.-]{1,255}),[a-z-]+$`) // For bucket, accountID, and ACL in the ID e.g. bucket,123456789101,public-read - bucketOwnerAclRegex := regexache.MustCompile(`^([a-z0-9.-]{1,63}|[a-zA-Z0-9.\-_]{1,255}),\d{12},[a-z-]+$`) + bucketOwnerAclRegex := regexache.MustCompile(`^([0-9a-z.-]{1,63}|[0-9A-Za-z_.-]{1,255}),\d{12},[a-z-]+$`) // Bucket name ONLY if bucketRegex.MatchString(id) { diff --git a/internal/service/s3/object_data_source_test.go b/internal/service/s3/object_data_source_test.go index 68b5a4f957ee..4b1266739c90 100644 --- a/internal/service/s3/object_data_source_test.go +++ b/internal/service/s3/object_data_source_test.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" ) -const rfc1123RegexPattern = `^[a-zA-Z]{3}, [0-9]+ [a-zA-Z]+ [0-9]{4} [0-9:]+ [A-Z]+$` +const rfc1123RegexPattern = `^[A-Za-z]{3}, [0-9]+ [A-Za-z]+ [0-9]{4} [0-9:]+ [A-Z]+$` func TestAccS3ObjectDataSource_basic(t *testing.T) { ctx := acctest.Context(t) diff --git a/internal/service/s3/validate.go b/internal/service/s3/validate.go index 7e45a7f0dba0..f659d03f77d6 100644 --- a/internal/service/s3/validate.go +++ b/internal/service/s3/validate.go @@ -39,7 +39,7 @@ func ValidBucketName(value string, region string) error { if len(value) > 255 { return fmt.Errorf("%q must contain less than 256 characters", value) } - if !regexache.MustCompile(`^[0-9a-zA-Z-._]+$`).MatchString(value) { + if !regexache.MustCompile(`^[0-9A-Za-z_.-]+$`).MatchString(value) { return fmt.Errorf("only alphanumeric characters, hyphens, periods, and underscores allowed in %q", value) } } diff --git a/internal/service/s3control/bucket.go b/internal/service/s3control/bucket.go index d68e213d6f17..40db6f4178bb 100644 --- a/internal/service/s3control/bucket.go +++ b/internal/service/s3control/bucket.go @@ -55,9 +55,9 @@ func resourceBucket() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 63), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9.-]+$`), "must contain only lowercase letters, numbers, periods, and hyphens"), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9]`), "must begin with lowercase letter or number"), - validation.StringMatch(regexache.MustCompile(`[a-z0-9]$`), "must end with lowercase letter or number"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z.-]+$`), "must contain only lowercase letters, numbers, periods, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z]`), "must begin with lowercase letter or number"), + validation.StringMatch(regexache.MustCompile(`[0-9a-z]$`), "must end with lowercase letter or number"), ), }, "creation_date": { diff --git a/internal/service/s3control/multi_region_access_point_test.go b/internal/service/s3control/multi_region_access_point_test.go index f2cd92fea577..4ad1bb78b5c5 100644 --- a/internal/service/s3control/multi_region_access_point_test.go +++ b/internal/service/s3control/multi_region_access_point_test.go @@ -39,9 +39,9 @@ func TestAccS3ControlMultiRegionAccessPoint_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMultiRegionAccessPointExists(ctx, resourceName, &v), acctest.CheckResourceAttrAccountID(resourceName, "account_id"), - resource.TestMatchResourceAttr(resourceName, "alias", regexache.MustCompile(`^[a-z][a-z0-9]*[.]mrap$`)), - acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "s3", regexache.MustCompile(`accesspoint\/[a-z][a-z0-9]*[.]mrap$`)), - acctest.MatchResourceAttrGlobalHostname(resourceName, "domain_name", "accesspoint.s3-global", regexache.MustCompile(`^[a-z][a-z0-9]*[.]mrap`)), + resource.TestMatchResourceAttr(resourceName, "alias", regexache.MustCompile(`^[a-z][0-9a-z]*[.]mrap$`)), + acctest.MatchResourceAttrGlobalARN(resourceName, "arn", "s3", regexache.MustCompile(`accesspoint\/[a-z][0-9a-z]*[.]mrap$`)), + acctest.MatchResourceAttrGlobalHostname(resourceName, "domain_name", "accesspoint.s3-global", regexache.MustCompile(`^[a-z][0-9a-z]*[.]mrap`)), resource.TestCheckResourceAttr(resourceName, "details.#", "1"), resource.TestCheckResourceAttr(resourceName, "details.0.name", rName), resource.TestCheckResourceAttr(resourceName, "details.0.public_access_block.#", "1"), diff --git a/internal/service/s3outposts/endpoint_test.go b/internal/service/s3outposts/endpoint_test.go index 49e41ab203f6..4a17603c8203 100644 --- a/internal/service/s3outposts/endpoint_test.go +++ b/internal/service/s3outposts/endpoint_test.go @@ -35,7 +35,7 @@ func TestAccS3OutpostsEndpoint_basic(t *testing.T) { Config: testAccEndpointConfig_basic(rName, rInt), Check: resource.ComposeTestCheckFunc( testAccCheckEndpointExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "s3-outposts", regexache.MustCompile(`outpost/[^/]+/endpoint/[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "s3-outposts", regexache.MustCompile(`outpost/[^/]+/endpoint/[0-9a-z]+`)), resource.TestCheckResourceAttrSet(resourceName, "creation_time"), resource.TestCheckResourceAttrPair(resourceName, "cidr_block", "aws_vpc.test", "cidr_block"), resource.TestCheckResourceAttr(resourceName, "network_interfaces.#", "4"), @@ -71,7 +71,7 @@ func TestAccS3OutpostsEndpoint_private(t *testing.T) { Config: testAccEndpointConfig_private(rName, rInt), Check: resource.ComposeTestCheckFunc( testAccCheckEndpointExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "s3-outposts", regexache.MustCompile(`outpost/[^/]+/endpoint/[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "s3-outposts", regexache.MustCompile(`outpost/[^/]+/endpoint/[0-9a-z]+`)), resource.TestCheckResourceAttrSet(resourceName, "creation_time"), resource.TestCheckResourceAttrPair(resourceName, "cidr_block", "aws_vpc.test", "cidr_block"), resource.TestCheckResourceAttr(resourceName, "network_interfaces.#", "4"), @@ -107,7 +107,7 @@ func TestAccS3OutpostsEndpoint_customerOwnedIPv4Pool(t *testing.T) { Config: testAccEndpointConfig_customerOwnedIPv4Pool(rName, rInt), Check: resource.ComposeTestCheckFunc( testAccCheckEndpointExists(ctx, resourceName), - acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "s3-outposts", regexache.MustCompile(`outpost/[^/]+/endpoint/[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "s3-outposts", regexache.MustCompile(`outpost/[^/]+/endpoint/[0-9a-z]+`)), resource.TestCheckResourceAttrSet(resourceName, "creation_time"), resource.TestCheckResourceAttrPair(resourceName, "cidr_block", "aws_vpc.test", "cidr_block"), resource.TestCheckResourceAttr(resourceName, "network_interfaces.#", "4"), diff --git a/internal/service/sagemaker/app.go b/internal/service/sagemaker/app.go index 4eab50e73aba..f21b31673c63 100644 --- a/internal/service/sagemaker/app.go +++ b/internal/service/sagemaker/app.go @@ -48,7 +48,7 @@ func ResourceApp() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,62}`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "app_type": { diff --git a/internal/service/sagemaker/app_image_config.go b/internal/service/sagemaker/app_image_config.go index 1d778e43b10b..4673e7557f72 100644 --- a/internal/service/sagemaker/app_image_config.go +++ b/internal/service/sagemaker/app_image_config.go @@ -44,7 +44,7 @@ func ResourceAppImageConfig() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "kernel_gateway_image_config": { diff --git a/internal/service/sagemaker/code_repository.go b/internal/service/sagemaker/code_repository.go index c059caf8d67c..6ca66c66a2e6 100644 --- a/internal/service/sagemaker/code_repository.go +++ b/internal/service/sagemaker/code_repository.go @@ -45,7 +45,7 @@ func ResourceCodeRepository() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "git_config": { diff --git a/internal/service/sagemaker/device.go b/internal/service/sagemaker/device.go index 5ac990c7841d..81b4f2f0e757 100644 --- a/internal/service/sagemaker/device.go +++ b/internal/service/sagemaker/device.go @@ -47,7 +47,7 @@ func ResourceDevice() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,62}$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "device": { diff --git a/internal/service/sagemaker/device_fleet.go b/internal/service/sagemaker/device_fleet.go index 0bce9a60f899..2225f48e24b2 100644 --- a/internal/service/sagemaker/device_fleet.go +++ b/internal/service/sagemaker/device_fleet.go @@ -51,7 +51,7 @@ func ResourceDeviceFleet() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,62}$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "enable_iot_role_alias": { diff --git a/internal/service/sagemaker/domain.go b/internal/service/sagemaker/domain.go index deb85bb1813c..d0f780cdfc2f 100644 --- a/internal/service/sagemaker/domain.go +++ b/internal/service/sagemaker/domain.go @@ -569,7 +569,7 @@ func ResourceDomain() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "domain_settings": { diff --git a/internal/service/sagemaker/endpoint_configuration.go b/internal/service/sagemaker/endpoint_configuration.go index bdbf29f8756e..aaadb9512a2f 100644 --- a/internal/service/sagemaker/endpoint_configuration.go +++ b/internal/service/sagemaker/endpoint_configuration.go @@ -154,7 +154,7 @@ func ResourceEndpointConfiguration() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*\/[a-zA-Z0-9](-*[a-zA-Z0-9.])*`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*\/[0-9A-Za-z](-*[0-9A-Za-z.])*`), ""), validation.StringLenBetween(1, 256), ), }, @@ -168,7 +168,7 @@ func ResourceEndpointConfiguration() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*\/[a-zA-Z0-9](-*[a-zA-Z0-9.])*`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*\/[0-9A-Za-z](-*[0-9A-Za-z.])*`), ""), validation.StringLenBetween(1, 256), ), }, diff --git a/internal/service/sagemaker/feature_group.go b/internal/service/sagemaker/feature_group.go index b98f530bf005..c74d84cdc11b 100644 --- a/internal/service/sagemaker/feature_group.go +++ b/internal/service/sagemaker/feature_group.go @@ -52,7 +52,7 @@ func ResourceFeatureGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]([-_]*[a-zA-Z0-9]){0,63}`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([-_]*[0-9A-Za-z]){0,63}`), "Must start and end with an alphanumeric character and Can only contains alphanumeric characters, hyphens, underscores. Spaces are not allowed."), ), }, @@ -70,7 +70,7 @@ func ResourceFeatureGroup() *schema.Resource { ValidateFunc: validation.All( validation.StringLenBetween(1, 64), validation.StringNotInSlice([]string{"is_deleted", "write_time", "api_invocation_time"}, false), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]([-_]*[a-zA-Z0-9]){0,63}`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([-_]*[0-9A-Za-z]){0,63}`), "Must start and end with an alphanumeric character and Can only contains alphanumeric characters, hyphens, underscores. Spaces are not allowed."), ), }, @@ -88,7 +88,7 @@ func ResourceFeatureGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,63}`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,63}`), "Must start and end with an alphanumeric character and Can only contain alphanumeric character and hyphens. Spaces are not allowed."), ), }, @@ -192,7 +192,7 @@ func ResourceFeatureGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]([-_]*[a-zA-Z0-9]){0,63}`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([-_]*[0-9A-Za-z]){0,63}`), "Must start and end with an alphanumeric character and Can only contains alphanumeric characters, hyphens, underscores. Spaces are not allowed."), ), }, diff --git a/internal/service/sagemaker/flow_definition.go b/internal/service/sagemaker/flow_definition.go index 399bf724b020..6c8eac1712a1 100644 --- a/internal/service/sagemaker/flow_definition.go +++ b/internal/service/sagemaker/flow_definition.go @@ -49,7 +49,7 @@ func ResourceFlowDefinition() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9](-*[a-z0-9])*$`), "Valid characters are a-z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z](-*[0-9a-z])*$`), "Valid characters are a-z, 0-9, and - (hyphen)."), ), }, "human_loop_activation_config": { @@ -165,7 +165,7 @@ func ResourceFlowDefinition() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.All( validation.StringLenBetween(1, 30), - validation.StringMatch(regexache.MustCompile(`^[A-Za-z0-9]+( [A-Za-z0-9]+)*$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+( [0-9A-Za-z]+)*$`), ""), ), }, }, diff --git a/internal/service/sagemaker/human_task_ui.go b/internal/service/sagemaker/human_task_ui.go index a4ee61a127e7..535cb4d609de 100644 --- a/internal/service/sagemaker/human_task_ui.go +++ b/internal/service/sagemaker/human_task_ui.go @@ -69,7 +69,7 @@ func ResourceHumanTaskUI() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-z0-9](-*[a-z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z](-*[0-9a-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/sagemaker/image.go b/internal/service/sagemaker/image.go index a2bce6363055..a0d5bfacbeea 100644 --- a/internal/service/sagemaker/image.go +++ b/internal/service/sagemaker/image.go @@ -46,7 +46,7 @@ func ResourceImage() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "role_arn": { diff --git a/internal/service/sagemaker/model_package_group.go b/internal/service/sagemaker/model_package_group.go index ec19026d0791..6d721f805452 100644 --- a/internal/service/sagemaker/model_package_group.go +++ b/internal/service/sagemaker/model_package_group.go @@ -44,7 +44,7 @@ func ResourceModelPackageGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}$`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,62}$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, diff --git a/internal/service/sagemaker/pipeline.go b/internal/service/sagemaker/pipeline.go index 5fdde3003eaa..25328eb40bcc 100644 --- a/internal/service/sagemaker/pipeline.go +++ b/internal/service/sagemaker/pipeline.go @@ -96,7 +96,7 @@ func ResourcePipeline() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]([a-zA-Z0-9\-])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([0-9A-Za-z-])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "pipeline_name": { @@ -105,7 +105,7 @@ func ResourcePipeline() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]([a-zA-Z0-9\-])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([0-9A-Za-z-])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "role_arn": { diff --git a/internal/service/sagemaker/project.go b/internal/service/sagemaker/project.go index dc9bee982fb9..c10764a3da6c 100644 --- a/internal/service/sagemaker/project.go +++ b/internal/service/sagemaker/project.go @@ -50,7 +50,7 @@ func ResourceProject() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 32), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,31}$`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,31}$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, diff --git a/internal/service/sagemaker/space.go b/internal/service/sagemaker/space.go index 717401e01e87..0e92f559e750 100644 --- a/internal/service/sagemaker/space.go +++ b/internal/service/sagemaker/space.go @@ -47,7 +47,7 @@ func ResourceSpace() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,62}`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "domain_id": { diff --git a/internal/service/sagemaker/studio_lifecycle_config.go b/internal/service/sagemaker/studio_lifecycle_config.go index c79070d20eab..86c3f04c9201 100644 --- a/internal/service/sagemaker/studio_lifecycle_config.go +++ b/internal/service/sagemaker/studio_lifecycle_config.go @@ -57,7 +57,7 @@ func ResourceStudioLifecycleConfig() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/sagemaker/user_profile.go b/internal/service/sagemaker/user_profile.go index 74fd22b36ecf..efe72024ffb2 100644 --- a/internal/service/sagemaker/user_profile.go +++ b/internal/service/sagemaker/user_profile.go @@ -48,7 +48,7 @@ func ResourceUserProfile() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z]){0,62}`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "domain_id": { diff --git a/internal/service/sagemaker/workforce.go b/internal/service/sagemaker/workforce.go index 9b9242f27e83..2af1497a7425 100644 --- a/internal/service/sagemaker/workforce.go +++ b/internal/service/sagemaker/workforce.go @@ -149,7 +149,7 @@ func ResourceWorkforce() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]([a-zA-Z0-9\-])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]([0-9A-Za-z-])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, "workforce_vpc_config": { diff --git a/internal/service/sagemaker/workteam.go b/internal/service/sagemaker/workteam.go index 5f7bedc22dd0..bed21814b03d 100644 --- a/internal/service/sagemaker/workteam.go +++ b/internal/service/sagemaker/workteam.go @@ -128,7 +128,7 @@ func ResourceWorkteam() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9](-*[a-zA-Z0-9])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z](-*[0-9A-Za-z])*$`), "Valid characters are a-z, A-Z, 0-9, and - (hyphen)."), ), }, }, diff --git a/internal/service/scheduler/schedule.go b/internal/service/scheduler/schedule.go index 6b45556526b4..664fbbcd3f52 100644 --- a/internal/service/scheduler/schedule.go +++ b/internal/service/scheduler/schedule.go @@ -100,7 +100,7 @@ func resourceSchedule() *schema.Resource { ConflictsWith: []string{"name_prefix"}, ValidateDiagFunc: validation.ToDiagFunc(validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z-_.]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), )), }, "name_prefix": { @@ -111,7 +111,7 @@ func resourceSchedule() *schema.Resource { ConflictsWith: []string{"name"}, ValidateDiagFunc: validation.ToDiagFunc(validation.All( validation.StringLenBetween(1, 64-id.UniqueIDSuffixLength), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z-_.]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), )), }, "schedule_expression": { diff --git a/internal/service/scheduler/schedule_group.go b/internal/service/scheduler/schedule_group.go index 8cb9eb8a8af7..3a2d2d581192 100644 --- a/internal/service/scheduler/schedule_group.go +++ b/internal/service/scheduler/schedule_group.go @@ -66,7 +66,7 @@ func ResourceScheduleGroup() *schema.Resource { ConflictsWith: []string{"name_prefix"}, ValidateDiagFunc: validation.ToDiagFunc(validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z-_.]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), )), }, "name_prefix": { @@ -77,7 +77,7 @@ func ResourceScheduleGroup() *schema.Resource { ConflictsWith: []string{"name"}, ValidateDiagFunc: validation.ToDiagFunc(validation.All( validation.StringLenBetween(1, 64-id.UniqueIDSuffixLength), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z-_.]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), `The name must consist of alphanumerics, hyphens, and underscores.`), )), }, "state": { diff --git a/internal/service/schemas/registry.go b/internal/service/schemas/registry.go index f0a5b53d4f34..ad81c64c1c30 100644 --- a/internal/service/schemas/registry.go +++ b/internal/service/schemas/registry.go @@ -52,7 +52,7 @@ func ResourceRegistry() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z0-9]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/schemas/schema.go b/internal/service/schemas/schema.go index 0aac69c36bc2..fd99232fbff4 100644 --- a/internal/service/schemas/schema.go +++ b/internal/service/schemas/schema.go @@ -64,7 +64,7 @@ func ResourceSchema() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 385), - validation.StringMatch(regexache.MustCompile(`^[\.\-_A-Za-z@]+`), ""), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z_.@-]+`), ""), ), }, diff --git a/internal/service/securityhub/action_target.go b/internal/service/securityhub/action_target.go index f351877a86d1..ee602f5b2104 100644 --- a/internal/service/securityhub/action_target.go +++ b/internal/service/securityhub/action_target.go @@ -45,7 +45,7 @@ func ResourceActionTarget() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 20), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]+$`), "must contain only alphanumeric characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), "must contain only alphanumeric characters"), ), }, "name": { diff --git a/internal/service/servicediscovery/instance.go b/internal/service/servicediscovery/instance.go index 6ab42a94f16e..c15efd98084b 100644 --- a/internal/service/servicediscovery/instance.go +++ b/internal/service/servicediscovery/instance.go @@ -40,9 +40,9 @@ func ResourceInstance() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, ValidateDiagFunc: validation.AllDiag( validation.MapKeyLenBetween(1, 255), - validation.MapKeyMatch(regexache.MustCompile(`^[a-zA-Z0-9!-~]+$`), ""), + validation.MapKeyMatch(regexache.MustCompile(`^[0-9A-Za-z!~-]+$`), ""), validation.MapValueLenBetween(0, 1024), - validation.MapValueMatch(regexache.MustCompile(`^([a-zA-Z0-9!-~][ \ta-zA-Z0-9!-~]*){0,1}[a-zA-Z0-9!-~]{0,1}$`), ""), + validation.MapValueMatch(regexache.MustCompile(`^([0-9A-Za-z!~-][0-9A-Za-z \t!~-]*){0,1}[0-9A-Za-z!~-]{0,1}$`), ""), ), }, "instance_id": { @@ -51,7 +51,7 @@ func ResourceInstance() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z_/:.@-]+$`), ""), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_/:.@-]+$`), ""), ), }, "service_id": { diff --git a/internal/service/servicequotas/service_quota.go b/internal/service/servicequotas/service_quota.go index 579d8dcc5c6a..f7a016dcde99 100644 --- a/internal/service/servicequotas/service_quota.go +++ b/internal/service/servicequotas/service_quota.go @@ -50,8 +50,8 @@ func ResourceServiceQuota() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]+$`), "must contain only alphanumeric and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and hyphen characters"), ), }, "quota_name": { @@ -72,8 +72,8 @@ func ResourceServiceQuota() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 63), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z]`), "must begin with alphabetic character"), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]+$`), "must contain only alphanumeric and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[A-Za-z]`), "must begin with alphabetic character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and hyphen characters"), ), }, "service_name": { diff --git a/internal/service/ses/domain_dkim_test.go b/internal/service/ses/domain_dkim_test.go index 550ea52c6cef..39298ebcddee 100644 --- a/internal/service/ses/domain_dkim_test.go +++ b/internal/service/ses/domain_dkim_test.go @@ -112,7 +112,7 @@ func testAccCheckDomainDKIMTokens(n string) resource.TestCheckFunc { rs := s.RootModule().Resources[n] expectedNum := 3 - expectedFormat := regexache.MustCompile("[a-z0-9]{32}") + expectedFormat := regexache.MustCompile("[0-9a-z]{32}") tokenNum, _ := strconv.Atoi(rs.Primary.Attributes["dkim_tokens.#"]) if expectedNum != tokenNum { diff --git a/internal/service/ses/event_destination.go b/internal/service/ses/event_destination.go index 01f40c4f7d94..3172c0efb20b 100644 --- a/internal/service/ses/event_destination.go +++ b/internal/service/ses/event_destination.go @@ -50,7 +50,7 @@ func ResourceEventDestination() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z_\-\.@]+$`), "must contain only alphanumeric, underscore, hyphen, period, and at signs characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.@-]+$`), "must contain only alphanumeric, underscore, hyphen, period, and at signs characters"), ), }, "dimension_name": { @@ -58,7 +58,7 @@ func ResourceEventDestination() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 256), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z_:-]+$`), "must contain only alphanumeric, underscore, and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_:-]+$`), "must contain only alphanumeric, underscore, and hyphen characters"), ), }, "value_source": { @@ -117,7 +117,7 @@ func ResourceEventDestination() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z_-]+$`), "must contain only alphanumeric, underscore, and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric, underscore, and hyphen characters"), ), }, "sns_destination": { diff --git a/internal/service/ses/identity_policy.go b/internal/service/ses/identity_policy.go index 33c3395ee931..825dd9080020 100644 --- a/internal/service/ses/identity_policy.go +++ b/internal/service/ses/identity_policy.go @@ -44,7 +44,7 @@ func ResourceIdentityPolicy() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9\-\_]+$`), "must contain only alphanumeric characters, dashes, and underscores"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric characters, dashes, and underscores"), ), }, "policy": { diff --git a/internal/service/ses/receipt_filter.go b/internal/service/ses/receipt_filter.go index e577c4711114..a1a6455cd646 100644 --- a/internal/service/ses/receipt_filter.go +++ b/internal/service/ses/receipt_filter.go @@ -40,9 +40,9 @@ func ResourceReceiptFilter() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+$`), "must contain only alphanumeric, period, underscore, and hyphen characters"), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z]`), "must begin with a alphanumeric character"), - validation.StringMatch(regexache.MustCompile(`[0-9a-zA-Z]$`), "must end with a alphanumeric character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric, period, underscore, and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]`), "must begin with a alphanumeric character"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z]$`), "must end with a alphanumeric character"), ), }, diff --git a/internal/service/ses/receipt_rule.go b/internal/service/ses/receipt_rule.go index 12dbe9d96bdd..62ede192e348 100644 --- a/internal/service/ses/receipt_rule.go +++ b/internal/service/ses/receipt_rule.go @@ -49,7 +49,7 @@ func ResourceReceiptRule() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 50), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z-]+$`), "must contain only alphanumeric and dash characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and dash characters"), ), }, "header_value": { @@ -144,9 +144,9 @@ func ResourceReceiptRule() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z._-]+$`), "must contain only alphanumeric, period, underscore, and hyphen characters"), - validation.StringMatch(regexache.MustCompile(`^[0-9a-zA-Z]`), "must begin with a alphanumeric character"), - validation.StringMatch(regexache.MustCompile(`[0-9a-zA-Z]$`), "must end with a alphanumeric character"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric, period, underscore, and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]`), "must begin with a alphanumeric character"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z]$`), "must end with a alphanumeric character"), ), }, "recipients": { diff --git a/internal/service/sfn/state_machine.go b/internal/service/sfn/state_machine.go index e66cfbc6b6fe..16354d231d9e 100644 --- a/internal/service/sfn/state_machine.go +++ b/internal/service/sfn/state_machine.go @@ -95,7 +95,7 @@ func ResourceStateMachine() *schema.Resource { ConflictsWith: []string{"name_prefix"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 80), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), "the name should only contain 0-9, A-Z, a-z, - and _"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "the name should only contain 0-9, A-Z, a-z, - and _"), ), }, "name_prefix": { @@ -106,7 +106,7 @@ func ResourceStateMachine() *schema.Resource { ConflictsWith: []string{"name"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 80-id.UniqueIDSuffixLength), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), "the name should only contain 0-9, A-Z, a-z, - and _"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "the name should only contain 0-9, A-Z, a-z, - and _"), ), }, "publish": { diff --git a/internal/service/shield/drt_access_role_arn_association.go b/internal/service/shield/drt_access_role_arn_association.go index 8b7aa76d859e..e9c4f039878b 100644 --- a/internal/service/shield/drt_access_role_arn_association.go +++ b/internal/service/shield/drt_access_role_arn_association.go @@ -68,7 +68,7 @@ func (r *resourceDRTAccessRoleARNAssociation) Schema(ctx context.Context, req re Validators: []validator.String{ stringvalidator.LengthBetween(1, 2048), stringvalidator.RegexMatches( - regexache.MustCompile(`^arn:?[a-zA-Z\-]+:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+`), + regexache.MustCompile(`^arn:?[A-Za-z-]+:iam::\d{12}:role/?[0-9A-Za-z_+=,.@_/-]+`), "must match arn pattern", ), }, diff --git a/internal/service/signer/signing_profile.go b/internal/service/signer/signing_profile.go index 26b66ac5f83e..df9656fd826d 100644 --- a/internal/service/signer/signing_profile.go +++ b/internal/service/signer/signing_profile.go @@ -54,14 +54,14 @@ func ResourceSigningProfile() *schema.Resource { Computed: true, ForceNew: true, ConflictsWith: []string{"name_prefix"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_]{0,64}$`), "must be alphanumeric with max length of 64 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]{0,64}$`), "must be alphanumeric with max length of 64 characters"), }, "name_prefix": { Type: schema.TypeString, Optional: true, ForceNew: true, ConflictsWith: []string{"name"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_]{0,38}$`), "must be alphanumeric with max length of 38 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_]{0,38}$`), "must be alphanumeric with max length of 38 characters"), }, "signature_validity_period": { Type: schema.TypeList, diff --git a/internal/service/signer/signing_profile_permission.go b/internal/service/signer/signing_profile_permission.go index 0bed7b83b57a..36aabb63cf4e 100644 --- a/internal/service/signer/signing_profile_permission.go +++ b/internal/service/signer/signing_profile_permission.go @@ -70,14 +70,14 @@ func ResourceSigningProfilePermission() *schema.Resource { Computed: true, ForceNew: true, ConflictsWith: []string{"statement_id_prefix"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]{0,64}$`), "must be alphanumeric with max length of 64 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]{0,64}$`), "must be alphanumeric with max length of 64 characters"), }, "statement_id_prefix": { Type: schema.TypeString, Optional: true, ForceNew: true, ConflictsWith: []string{"statement_id"}, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]{0,38}$`), "must be alphanumeric with max length of 38 characters"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]{0,38}$`), "must be alphanumeric with max length of 38 characters"), }, }, } diff --git a/internal/service/signer/signing_profile_test.go b/internal/service/signer/signing_profile_test.go index c70012684008..2950430b4862 100644 --- a/internal/service/signer/signing_profile_test.go +++ b/internal/service/signer/signing_profile_test.go @@ -43,7 +43,7 @@ func TestAccSignerSigningProfile_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckSigningProfileExists(ctx, resourceName, &conf), resource.TestMatchResourceAttr(resourceName, "name", - regexache.MustCompile("^[a-zA-Z0-9_]{0,64}$")), + regexache.MustCompile("^[0-9A-Za-z_]{0,64}$")), resource.TestCheckResourceAttr(resourceName, "platform_id", "AWSLambda-SHA384-ECDSA"), ), }, diff --git a/internal/service/sns/topic.go b/internal/service/sns/topic.go index 953eb73405c2..5ed7ad6c4cfc 100644 --- a/internal/service/sns/topic.go +++ b/internal/service/sns/topic.go @@ -408,9 +408,9 @@ func resourceTopicCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, me var re *regexp.Regexp if fifoTopic { - re = regexache.MustCompile(`^[a-zA-Z0-9_-]{1,251}\.fifo$`) + re = regexache.MustCompile(`^[0-9A-Za-z_-]{1,251}\.fifo$`) } else { - re = regexache.MustCompile(`^[a-zA-Z0-9_-]{1,256}$`) + re = regexache.MustCompile(`^[0-9A-Za-z_-]{1,256}$`) } if !re.MatchString(name) { diff --git a/internal/service/sqs/queue.go b/internal/service/sqs/queue.go index 8d07be40e1c3..dfbaa80dfbdc 100644 --- a/internal/service/sqs/queue.go +++ b/internal/service/sqs/queue.go @@ -385,9 +385,9 @@ func resourceQueueCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, me var re *regexp.Regexp if fifoQueue { - re = regexache.MustCompile(`^[a-zA-Z0-9_-]{1,75}\.fifo$`) + re = regexache.MustCompile(`^[0-9A-Za-z_-]{1,75}\.fifo$`) } else { - re = regexache.MustCompile(`^[a-zA-Z0-9_-]{1,80}$`) + re = regexache.MustCompile(`^[0-9A-Za-z_-]{1,80}$`) } if !re.MatchString(name) { diff --git a/internal/service/ssm/association.go b/internal/service/ssm/association.go index dc2d8d89b6bb..f6d3f2406900 100644 --- a/internal/service/ssm/association.go +++ b/internal/service/ssm/association.go @@ -52,7 +52,7 @@ func ResourceAssociation() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]{3,128}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{3,128}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), ), }, "association_id": { diff --git a/internal/service/ssm/default_patch_baseline.go b/internal/service/ssm/default_patch_baseline.go index 0874ba821272..7e0be3ec1ce4 100644 --- a/internal/service/ssm/default_patch_baseline.go +++ b/internal/service/ssm/default_patch_baseline.go @@ -335,7 +335,7 @@ func FindDefaultDefaultPatchBaselineIDForOS(ctx context.Context, conn *ssm.Clien operatingSystemFilter(os), ownerIsAWSFilter(), ) - re := regexache.MustCompile(`^AWS-[A-Za-z0-9]+PatchBaseline$`) + re := regexache.MustCompile(`^AWS-[0-9A-Za-z]+PatchBaseline$`) var baselineIdentityIDs []string for paginator.HasMorePages() { page, err := paginator.NextPage(ctx) diff --git a/internal/service/ssm/document.go b/internal/service/ssm/document.go index fc716f928c46..425a0bfa4cb6 100644 --- a/internal/service/ssm/document.go +++ b/internal/service/ssm/document.go @@ -68,7 +68,7 @@ func ResourceDocument() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), validation.StringLenBetween(3, 128), ), }, @@ -132,7 +132,7 @@ func ResourceDocument() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]+$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), validation.StringLenBetween(3, 128), ), }, @@ -198,7 +198,7 @@ func ResourceDocument() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]{3,128}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{3,128}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), validation.StringLenBetween(3, 128), ), }, diff --git a/internal/service/ssm/maintenance_window_target.go b/internal/service/ssm/maintenance_window_target.go index 0c2cea86af12..f659b099d382 100644 --- a/internal/service/ssm/maintenance_window_target.go +++ b/internal/service/ssm/maintenance_window_target.go @@ -81,7 +81,7 @@ func ResourceMaintenanceWindowTarget() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]{3,128}$`), "Only alphanumeric characters, hyphens, dots & underscores allowed"), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{3,128}$`), "Only alphanumeric characters, hyphens, dots & underscores allowed"), }, "description": { diff --git a/internal/service/ssm/maintenance_window_task.go b/internal/service/ssm/maintenance_window_task.go index 31b9e7dd30fc..e632db4a8a6e 100644 --- a/internal/service/ssm/maintenance_window_task.go +++ b/internal/service/ssm/maintenance_window_task.go @@ -112,7 +112,7 @@ func ResourceMaintenanceWindowTask() *schema.Resource { "name": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]{3,128}$`), + ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{3,128}$`), "Only alphanumeric characters, hyphens, dots & underscores allowed."), }, diff --git a/internal/service/ssm/parameter_test.go b/internal/service/ssm/parameter_test.go index 3f88d1bd9fe2..f0b57e5350a8 100644 --- a/internal/service/ssm/parameter_test.go +++ b/internal/service/ssm/parameter_test.go @@ -56,6 +56,37 @@ func TestAccSSMParameter_basic(t *testing.T) { }) } +// TestAccSSMParameter_multiple is mostly a performance benchmark +func TestAccSSMParameter_multiple(t *testing.T) { + ctx := acctest.Context(t) + var param ssm.Parameter + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_ssm_parameter.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, ssm.EndpointsID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckParameterDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccParameterConfig_multiple(rName, "String", "test2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckParameterExists(ctx, resourceName, ¶m), + acctest.CheckResourceAttrRegionalARN(resourceName, "arn", "ssm", fmt.Sprintf("parameter/%s-1", rName)), + resource.TestCheckResourceAttr(resourceName, "value", "test2"), + resource.TestCheckResourceAttr(resourceName, "type", "String"), + resource.TestCheckResourceAttr(resourceName, "tier", ssm.ParameterTierStandard), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "version"), + resource.TestCheckResourceAttr(resourceName, "data_type", "text"), + resource.TestCheckNoResourceAttr(resourceName, "overwrite"), + ), + }, + }, + }) +} + func TestAccSSMParameter_updateValue(t *testing.T) { ctx := acctest.Context(t) var param ssm.Parameter @@ -1116,6 +1147,130 @@ resource "aws_ssm_parameter" "test" { `, rName, pType, value) } +func testAccParameterConfig_multiple(rName, pType, value string) string { + return fmt.Sprintf(` +resource "aws_ssm_parameter" "test" { + name = "%[1]s-1" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test2" { + name = "%[1]s-2" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test3" { + name = "%[1]s-3" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test4" { + name = "%[1]s-4" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test5" { + name = "%[1]s-5" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test6" { + name = "%[1]s-6" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test7" { + name = "%[1]s-7" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test8" { + name = "%[1]s-8" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test9" { + name = "%[1]s-9" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test10" { + name = "%[1]s-10" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test11" { + name = "%[1]s-11" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test12" { + name = "%[1]s-12" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test13" { + name = "%[1]s-13" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test14" { + name = "%[1]s-14" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test15" { + name = "%[1]s-15" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test16" { + name = "%[1]s-16" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test17" { + name = "%[1]s-17" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test18" { + name = "%[1]s-18" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test19" { + name = "%[1]s-19" + type = %[2]q + value = %[3]q +} + +resource "aws_ssm_parameter" "test20" { + name = "%[1]s-20" + type = %[2]q + value = %[3]q +} +`, rName, pType, value) +} + func testAccParameterConfig_description(rName, description, pType, value string) string { return fmt.Sprintf(` resource "aws_ssm_parameter" "test" { diff --git a/internal/service/ssm/patch_baseline.go b/internal/service/ssm/patch_baseline.go index c52d10ebc837..0cd41f900a64 100644 --- a/internal/service/ssm/patch_baseline.go +++ b/internal/service/ssm/patch_baseline.go @@ -49,7 +49,7 @@ func ResourcePatchBaseline() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]{3,128}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{3,128}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), ), }, @@ -198,7 +198,7 @@ func ResourcePatchBaseline() *schema.Resource { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 50), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_\-.]{3,50}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]{3,50}$`), "must contain only alphanumeric, underscore, hyphen, or period characters"), ), }, diff --git a/internal/service/ssoadmin/account_assignment.go b/internal/service/ssoadmin/account_assignment.go index 41316eb95a14..5360669f3444 100644 --- a/internal/service/ssoadmin/account_assignment.go +++ b/internal/service/ssoadmin/account_assignment.go @@ -61,7 +61,7 @@ func ResourceAccountAssignment() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 47), - validation.StringMatch(regexache.MustCompile(`^([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$`), "must match ([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"), + validation.StringMatch(regexache.MustCompile(`^([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$`), "must match ([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"), ), }, "principal_type": { diff --git a/internal/service/ssoadmin/account_assignment_test.go b/internal/service/ssoadmin/account_assignment_test.go index c0769293cd93..94a6fbad6214 100644 --- a/internal/service/ssoadmin/account_assignment_test.go +++ b/internal/service/ssoadmin/account_assignment_test.go @@ -42,7 +42,7 @@ func TestAccSSOAdminAccountAssignment_Basic_group(t *testing.T) { testAccCheckAccountAssignmentExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "target_type", "AWS_ACCOUNT"), resource.TestCheckResourceAttr(resourceName, "principal_type", "GROUP"), - resource.TestMatchResourceAttr(resourceName, "principal_id", regexache.MustCompile("^([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}")), + resource.TestMatchResourceAttr(resourceName, "principal_id", regexache.MustCompile("^([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}")), ), }, { @@ -76,7 +76,7 @@ func TestAccSSOAdminAccountAssignment_Basic_user(t *testing.T) { testAccCheckAccountAssignmentExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "target_type", "AWS_ACCOUNT"), resource.TestCheckResourceAttr(resourceName, "principal_type", "USER"), - resource.TestMatchResourceAttr(resourceName, "principal_id", regexache.MustCompile("^([0-9a-f]{10}-|)[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}")), + resource.TestMatchResourceAttr(resourceName, "principal_id", regexache.MustCompile("^([0-9a-f]{10}-|)[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}")), ), }, { diff --git a/internal/service/ssoadmin/instances_data_source_test.go b/internal/service/ssoadmin/instances_data_source_test.go index 8f0768a1a504..bb91a53c6a1f 100644 --- a/internal/service/ssoadmin/instances_data_source_test.go +++ b/internal/service/ssoadmin/instances_data_source_test.go @@ -55,8 +55,8 @@ func TestAccSSOAdminInstancesDataSource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "arns.#", "1"), resource.TestCheckResourceAttr(dataSourceName, "identity_store_ids.#", "1"), - acctest.MatchResourceAttrGlobalARNNoAccount(dataSourceName, "arns.0", "sso", regexache.MustCompile("instance/(sso)?ins-[a-zA-Z0-9-.]{16}")), - resource.TestMatchResourceAttr(dataSourceName, "identity_store_ids.0", regexache.MustCompile("^[a-zA-Z0-9-]*")), + acctest.MatchResourceAttrGlobalARNNoAccount(dataSourceName, "arns.0", "sso", regexache.MustCompile("instance/(sso)?ins-[0-9A-Za-z.-]{16}")), + resource.TestMatchResourceAttr(dataSourceName, "identity_store_ids.0", regexache.MustCompile("^[0-9A-Za-z-]*")), ), }, }, diff --git a/internal/service/ssoadmin/permission_set.go b/internal/service/ssoadmin/permission_set.go index 2d9d4e97c262..f12a576bce06 100644 --- a/internal/service/ssoadmin/permission_set.go +++ b/internal/service/ssoadmin/permission_set.go @@ -81,7 +81,7 @@ func ResourcePermissionSet() *schema.Resource { Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 240), - validation.StringMatch(regexache.MustCompile(`[a-zA-Z0-9&$@#\\\/%?=~\-_'"|!:,.;*+\[\]\ \(\)\{\}]+`), "must match [a-zA-Z0-9&$@#\\\\\\/%?=~\\-_'\"|!:,.;*+\\[\\]\\(\\)\\{\\}]"), + validation.StringMatch(regexache.MustCompile(`[0-9A-Za-z&$@#\\\/%?=~\-_'"|!:,.;*+\[\]\ \(\)\{\}]+`), "must match [0-9A-Za-z&$@#\\\\\\/%?=~\\-_'\"|!:,.;*+\\[\\]\\(\\)\\{\\}]"), ), }, "session_duration": { diff --git a/internal/service/storagegateway/gateway.go b/internal/service/storagegateway/gateway.go index 9c105c940961..be390ff8bfab 100644 --- a/internal/service/storagegateway/gateway.go +++ b/internal/service/storagegateway/gateway.go @@ -192,7 +192,7 @@ func ResourceGateway() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^(([a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9\-]*[A-Za-z0-9])(:(\d+))?$`), ""), + validation.StringMatch(regexache.MustCompile(`^(([0-9A-Za-z-]*[0-9A-Za-z])\.)*([0-9A-Za-z-]*[0-9A-Za-z])(:(\d+))?$`), ""), validation.StringLenBetween(6, 1024), ), }, @@ -201,7 +201,7 @@ func ResourceGateway() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$`), ""), + validation.StringMatch(regexache.MustCompile(`^([0-9a-z]+(-[0-9a-z]+)*\.)+[a-z]{2,}$`), ""), validation.StringLenBetween(1, 1024), ), }, diff --git a/internal/service/timestreamwrite/database.go b/internal/service/timestreamwrite/database.go index 768f677ad2fa..d5285305454c 100644 --- a/internal/service/timestreamwrite/database.go +++ b/internal/service/timestreamwrite/database.go @@ -47,7 +47,7 @@ func resourceDatabase() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, "kms_key_id": { diff --git a/internal/service/timestreamwrite/table.go b/internal/service/timestreamwrite/table.go index 58bf70574758..7f83c5909ff6 100644 --- a/internal/service/timestreamwrite/table.go +++ b/internal/service/timestreamwrite/table.go @@ -50,7 +50,7 @@ func resourceTable() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, "magnetic_store_write_properties": { @@ -168,7 +168,7 @@ func resourceTable() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(3, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must only include alphanumeric, underscore, period, or hyphen characters"), ), }, names.AttrTags: tftags.TagsSchema(), diff --git a/internal/service/transfer/server_test.go b/internal/service/transfer/server_test.go index cf7c564ef424..158baf35bebb 100644 --- a/internal/service/transfer/server_test.go +++ b/internal/service/transfer/server_test.go @@ -52,7 +52,7 @@ func testAccServer_basic(t *testing.T) { testAccCheckServerExists(ctx, resourceName, &conf), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "transfer", regexache.MustCompile(`server/.+`)), resource.TestCheckResourceAttr(resourceName, "certificate", ""), - acctest.MatchResourceAttrRegionalHostname(resourceName, "endpoint", "server.transfer", regexache.MustCompile(`s-[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, "endpoint", "server.transfer", regexache.MustCompile(`s-[0-9a-z]+`)), resource.TestCheckResourceAttr(resourceName, "endpoint_details.#", "0"), resource.TestCheckResourceAttr(resourceName, "endpoint_type", "PUBLIC"), resource.TestCheckResourceAttr(resourceName, "force_destroy", "false"), @@ -91,7 +91,7 @@ func testAccServer_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "transfer", regexache.MustCompile(`server/.+`)), resource.TestCheckResourceAttr(resourceName, "certificate", ""), resource.TestCheckResourceAttr(resourceName, "domain", "S3"), - acctest.MatchResourceAttrRegionalHostname(resourceName, "endpoint", "server.transfer", regexache.MustCompile(`s-[a-z0-9]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, "endpoint", "server.transfer", regexache.MustCompile(`s-[0-9a-z]+`)), resource.TestCheckResourceAttr(resourceName, "endpoint_details.#", "0"), resource.TestCheckResourceAttr(resourceName, "endpoint_type", "PUBLIC"), resource.TestCheckResourceAttr(resourceName, "force_destroy", "false"), diff --git a/internal/service/wafv2/rule_group.go b/internal/service/wafv2/rule_group.go index f789d26a9af8..bf0a0440eddd 100644 --- a/internal/service/wafv2/rule_group.go +++ b/internal/service/wafv2/rule_group.go @@ -88,7 +88,7 @@ func ResourceRuleGroup() *schema.Resource { ConflictsWith: []string{"name_prefix"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric hyphen and underscore characters"), ), }, "name_prefix": { @@ -99,7 +99,7 @@ func ResourceRuleGroup() *schema.Resource { ConflictsWith: []string{"name"}, ValidateFunc: validation.All( validation.StringLenBetween(1, 128-id.UniqueIDSuffixLength), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric hyphen and underscore characters"), ), }, "rule": { diff --git a/internal/service/wafv2/schemas.go b/internal/service/wafv2/schemas.go index e05ccc14a9dc..fdb18d188d67 100644 --- a/internal/service/wafv2/schemas.go +++ b/internal/service/wafv2/schemas.go @@ -202,7 +202,7 @@ func ipSetReferenceStatementSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 255), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-]+$`), "must contain only alphanumeric and hyphen characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z-]+$`), "must contain only alphanumeric and hyphen characters"), ), }, "position": { @@ -359,7 +359,7 @@ func fieldToMatchBaseSchema() *schema.Resource { validation.StringLenBetween(1, 40), // The value is returned in lower case by the API. // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. - validation.StringMatch(regexache.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z_-]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), ), }, }, @@ -378,7 +378,7 @@ func fieldToMatchBaseSchema() *schema.Resource { validation.StringLenBetween(1, 30), // The value is returned in lower case by the API. // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. - validation.StringMatch(regexache.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z_-]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), ), }, }, @@ -504,7 +504,7 @@ func visibilityConfigSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric hyphen and underscore characters"), ), }, "sampled_requests_enabled": { @@ -661,7 +661,7 @@ func customRequestHandlingSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._$-]+$`), "must contain only alphanumeric, hyphen, underscore, dot and $ characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_$.-]+$`), "must contain only alphanumeric, hyphen, underscore, dot and $ characters"), ), }, "value": { @@ -707,7 +707,7 @@ func customResponseSchema() *schema.Schema { Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9._$-]+$`), "must contain only alphanumeric, hyphen, underscore, dot and $ characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_$.-]+$`), "must contain only alphanumeric, hyphen, underscore, dot and $ characters"), ), }, "value": { diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index c1b88a3aa5b6..5ae44bb3ccd0 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -96,7 +96,7 @@ func ResourceWebACL() *schema.Resource { ForceNew: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 128), - validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_-]+$`), "must contain only alphanumeric hyphen and underscore characters"), ), }, "rule": { diff --git a/internal/service/wafv2/web_acl_logging_configuration.go b/internal/service/wafv2/web_acl_logging_configuration.go index d9f08c38a1da..368b7b8a7f69 100644 --- a/internal/service/wafv2/web_acl_logging_configuration.go +++ b/internal/service/wafv2/web_acl_logging_configuration.go @@ -148,7 +148,7 @@ func ResourceWebACLLoggingConfiguration() *schema.Resource { validation.StringLenBetween(1, 40), // The value is returned in lower case by the API. // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. - validation.StringMatch(regexache.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z_-]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), ), }, }, diff --git a/internal/service/worklink/fleet.go b/internal/service/worklink/fleet.go index 91512baaa598..5ef424e683ad 100644 --- a/internal/service/worklink/fleet.go +++ b/internal/service/worklink/fleet.go @@ -45,7 +45,7 @@ func ResourceFleet() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validation.All( - validation.StringMatch(regexache.MustCompile(`^[a-z0-9](?:[a-z0-9\-]{0,46}[a-z0-9])?$`), "must contain only alphanumeric characters"), + validation.StringMatch(regexache.MustCompile(`^[0-9a-z](?:[0-9a-z\-]{0,46}[0-9a-z])?$`), "must contain only alphanumeric characters"), validation.StringLenBetween(1, 48), ), }, diff --git a/internal/tags/key_value_tags.go b/internal/tags/key_value_tags.go index b6326654635a..f07839f7fe3b 100644 --- a/internal/tags/key_value_tags.go +++ b/internal/tags/key_value_tags.go @@ -875,7 +875,7 @@ func (tags KeyValueTags) ResolveDuplicatesFramework(ctx context.Context, default // while Terraform schema attribute names are in snake_case. func ToSnakeCase(str string) string { result := regexache.MustCompile("(.)([A-Z][a-z]+)").ReplaceAllString(str, "${1}_${2}") - result = regexache.MustCompile("([a-z0-9])([A-Z])").ReplaceAllString(result, "${1}_${2}") + result = regexache.MustCompile("([0-9a-z])([A-Z])").ReplaceAllString(result, "${1}_${2}") return strings.ToLower(result) } diff --git a/internal/verify/validate.go b/internal/verify/validate.go index b25427f84a03..65d3c573f457 100644 --- a/internal/verify/validate.go +++ b/internal/verify/validate.go @@ -26,7 +26,7 @@ var partitionRegexp = regexache.MustCompile(`^aws(-[a-z]+)*$`) var regionRegexp = regexache.MustCompile(`^[a-z]{2}(-[a-z]+)+-\d$`) // validates all listed in https://gist.github.com/shortjared/4c1e3fe52bdfa47522cfe5b41e5d6f22 -var servicePrincipalRegexp = regexache.MustCompile(`^([a-z0-9-]+\.){1,4}(amazonaws|amazon)\.com$`) +var servicePrincipalRegexp = regexache.MustCompile(`^([0-9a-z-]+\.){1,4}(amazonaws|amazon)\.com$`) func Valid4ByteASN(v interface{}, k string) (ws []string, errors []error) { value := v.(string) @@ -288,7 +288,7 @@ func ValidLaunchTemplateID(v interface{}, k string) (ws []string, errors []error errors = append(errors, fmt.Errorf("%q cannot be shorter than 1 character", k)) } else if len(value) > 255 { errors = append(errors, fmt.Errorf("%q cannot be longer than 255 characters", k)) - } else if !regexache.MustCompile(`^lt\-[a-z0-9]+$`).MatchString(value) { + } else if !regexache.MustCompile(`^lt\-[0-9a-z]+$`).MatchString(value) { errors = append(errors, fmt.Errorf( "%q must begin with 'lt-' and be comprised of only alphanumeric characters: %v", k, value)) } @@ -303,7 +303,7 @@ func ValidLaunchTemplateName(v interface{}, k string) (ws []string, errors []err errors = append(errors, fmt.Errorf("%q cannot be longer than 99 characters, name is limited to 125", k)) } else if !strings.HasSuffix(k, "prefix") && len(value) > 125 { errors = append(errors, fmt.Errorf("%q cannot be longer than 125 characters", k)) - } else if !regexache.MustCompile(`^[0-9a-zA-Z()./_\-]+$`).MatchString(value) { + } else if !regexache.MustCompile(`^[0-9A-Za-z()./_\-]+$`).MatchString(value) { errors = append(errors, fmt.Errorf("%q can only alphanumeric characters and ()./_- symbols", k)) } return diff --git a/internal/verify/verify.go b/internal/verify/verify.go index a47f76d96b46..f0bc95de42a1 100644 --- a/internal/verify/verify.go +++ b/internal/verify/verify.go @@ -9,7 +9,7 @@ import ( "gopkg.in/yaml.v2" ) -const UUIDRegexPattern = `[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[ab89][a-f0-9]{3}-[a-f0-9]{12}` +const UUIDRegexPattern = `[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[ab89][0-9a-f]{3}-[0-9a-f]{12}` func SliceContainsString(slice []interface{}, s string) (int, bool) { for idx, value := range slice { diff --git a/mkdocs.yml b/mkdocs.yml index 4b64cbd52b8d..f88f04a03ae5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -40,6 +40,7 @@ nav: - Provider Scaffolding (skaff): skaff.md - Naming Standards: naming.md - Retries and Waiters: retries-and-waiters.md + - Regular Expressions: regular-expressions.md - Submit an Issue: issue-reporting-and-lifecycle.md - FAQ: faq.md