Skip to content

Instantly share code, notes, and snippets.

@futoase
Created June 24, 2014 03:21
Show Gist options
  • Select an option

  • Save futoase/1d00e7cd6d056bb7a635 to your computer and use it in GitHub Desktop.

Select an option

Save futoase/1d00e7cd6d056bb7a635 to your computer and use it in GitHub Desktop.
example for crowdmob/goamz
package main
import (
"github.com/crowdmob/goamz/aws"
"github.com/crowdmob/goamz/ec2"
"fmt"
)
func main() {
auth, err := aws.EnvAuth()
if err != nil {
panic(err)
}
e := ec2.New(auth, aws.APNortheast)
result, _ := e.DescribeInstances(nil, nil)
for _, reservation := range result.Reservations {
for _, instance := range reservation.Instances {
fmt.Printf("Instance id is: %s\n", instance.InstanceId)
fmt.Printf("Instance type is: %s\n", instance.InstanceType)
fmt.Printf("Availability Zone is: %s\n", instance.AvailabilityZone)
fmt.Printf("State is %s\n", instance.State.Name)
fmt.Printf("IP Address is %s\n", instance.IPAddress)
fmt.Printf("DNSName is %s\n", instance.DNSName)
fmt.Printf("LaunchTime is %s\n", instance.LaunchTime)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment