Currently if the user specifices "all" regions (or don't specify any), we use all the regions in VALID_REGIONS. However, not all of these regions are enabled or valid in the current account.
Something like the snippet below will get us all the valid regions for the account, however it needs to take place in the right order and it will probably affect tests.
func getEnabledRegions(baseCfg aws.Config) []string {
client := ec2.NewFromConfig(baseCfg)
res, err := client.DescribeRegions(context.TODO(), &ec2.DescribeRegionsInput{
AllRegions: aws.Bool(false), // false = only enabled regions
})
if err != nil {
log.Fatal(err)
}
var regions []string
for _, r := range res.Regions {
regions = append(regions, *r.RegionName)
}
return regions
}
Currently if the user specifices "all" regions (or don't specify any), we use all the regions in
VALID_REGIONS. However, not all of these regions are enabled or valid in the current account.Something like the snippet below will get us all the valid regions for the account, however it needs to take place in the right order and it will probably affect tests.