@@ -13,8 +13,11 @@ import (
1313func GetRegionPattern () * regexp.Regexp {
1414 regionList , err := regions .ListAllRegions ()
1515 if err != nil {
16- // Fallback to empty pattern if we can't load regions
17- return regexp .MustCompile (`^$` )
16+ panic (fmt .Sprintf ("failed to load AWS regions: %v" , err ))
17+ }
18+
19+ if len (regionList ) == 0 {
20+ panic ("AWS region list is empty" )
1821 }
1922
2023 regionNames := make ([]string , 0 , len (regionList ))
@@ -30,8 +33,11 @@ func GetRegionPattern() *regexp.Regexp {
3033func GetRegionInStringPattern () * regexp.Regexp {
3134 regionList , err := regions .ListAllRegions ()
3235 if err != nil {
33- // Fallback to empty pattern if we can't load regions
34- return regexp .MustCompile (`^$` )
36+ panic (fmt .Sprintf ("failed to load AWS regions: %v" , err ))
37+ }
38+
39+ if len (regionList ) == 0 {
40+ panic ("AWS region list is empty" )
3541 }
3642
3743 regionNames := make ([]string , 0 , len (regionList ))
@@ -47,16 +53,18 @@ func GetRegionInStringPattern() *regexp.Regexp {
4753func GetAvailabilityZonePattern () * regexp.Regexp {
4854 regionList , err := regions .ListAllRegions ()
4955 if err != nil {
50- // Fallback to empty pattern if we can't load regions
51- return regexp .MustCompile (`^$` )
56+ panic (fmt .Sprintf ("failed to load AWS regions: %v" , err ))
57+ }
58+
59+ if len (regionList ) == 0 {
60+ panic ("AWS region list is empty" )
5261 }
5362
5463 regionNames := make ([]string , 0 , len (regionList ))
5564 for _ , region := range regionList {
5665 regionNames = append (regionNames , regexp .QuoteMeta (region .RegionId ))
5766 }
5867
59- // AZ pattern: region code + letter (a-z)
6068 pattern := fmt .Sprintf ("^(%s)[a-z]$" , strings .Join (regionNames , "|" ))
6169 return regexp .MustCompile (pattern )
6270}
@@ -65,8 +73,11 @@ func GetAvailabilityZonePattern() *regexp.Regexp {
6573func GetARNRegionPattern () * regexp.Regexp {
6674 regionList , err := regions .ListAllRegions ()
6775 if err != nil {
68- // Fallback to empty pattern if we can't load regions
69- return regexp .MustCompile (`^$` )
76+ panic (fmt .Sprintf ("failed to load AWS regions: %v" , err ))
77+ }
78+
79+ if len (regionList ) == 0 {
80+ panic ("AWS region list is empty" )
7081 }
7182
7283 regionNames := make ([]string , 0 , len (regionList ))
@@ -82,8 +93,11 @@ func GetARNRegionPattern() *regexp.Regexp {
8293func GetPartitionPattern () * regexp.Regexp {
8394 partitionList , err := partitions .List ()
8495 if err != nil {
85- // Fallback to empty pattern if we can't load partitions
86- return regexp .MustCompile (`^$` )
96+ panic (fmt .Sprintf ("failed to load AWS partitions: %v" , err ))
97+ }
98+
99+ if len (partitionList ) == 0 {
100+ panic ("AWS partition list is empty" )
87101 }
88102
89103 partitionNames := make ([]string , 0 , len (partitionList ))
0 commit comments