Skip to content

Fix issue with non-enabled regions #2

Description

@sakisv

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions