Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

amazon web services - How to get a list of AWS regions programmatically in Go SDK V2

AWS removed endpoints package from Go SDK V2. Is there a way to get a list of AWS regions using Go SDK V2?

In V1 you could write something like this:

    import "github.com/aws/aws-sdk-go/aws/endpoints"
    ...
    ...
    
        partitions := endpoints.DefaultPartitions()
        for _, p := range partitions {
            for region := range p.Regions() {
                validRegions[region] = struct{}{}
            }
        }
    
    ...
    ...

However, this seems no longer possible. I did notice an autogenerated json which seems to contain all the partitions, however I can't seem to figure out how to get the list of available regions in the code.

Is there a way to do this in Go SDK V2?

question from:https://stackoverflow.com/questions/65843812/how-to-get-a-list-of-aws-regions-programmatically-in-go-sdk-v2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...