Created
December 9, 2015 02:22
-
-
Save res0nat0r/6ab9d5b701f9ec7e3016 to your computer and use it in GitHub Desktop.
List EC2 regions in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/ec2" | |
) | |
func main() { | |
svc := ec2.New(session.New(), &aws.Config{Region: aws.String("us-east-1")}) | |
resp, err := svc.DescribeRegions(nil) | |
if err != nil { | |
panic(err) | |
} | |
for _, region := range resp.Regions { | |
fmt.Println(*region.RegionName) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment