Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Created December 9, 2015 02:22
Show Gist options
  • Save res0nat0r/6ab9d5b701f9ec7e3016 to your computer and use it in GitHub Desktop.
Save res0nat0r/6ab9d5b701f9ec7e3016 to your computer and use it in GitHub Desktop.
List EC2 regions in Go
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