Function scratchstack_arn::utils::validate_region
source · Expand description
Verify that a region name meets the naming requirements.
AWS does not publish a formal specification for region names. In this validator, we require:
- The region must be composed of Unicode alphabetic non-uppercase characters or
-
(codepoint 45/0x002d), followed by a-
and one or more ASCII digits, or the namelocal
. - The region can have a local region appended to it: after the region, a ‘-’, one or more Unicode alphabetic
non-uppercase characters or
-
, followed by a-
and one or more ASCII digits. - A
-
cannot appear in the first or last position, nor can it appear in two consecutive characters.
“Non-uppercase” is the same as “lowercase” for most Western scripts, but other scripts do not have a concept of uppercase and lowercase.
Examples of valid region names:
test-1
prod-west-1
prod-east-1-dca-2
sverige-söder-1
ap-southeast-7-hòa-hiệp-bắc-3
- `日本-東京-1`
If region
meets the requirements, Ok is returned. Otherwise, a ArnError::InvalidRegion error is returned.