Example #1
0
func main() {
	flag.Parse()
	ep, err := elb.GetEndpoint(*region, nil)
	if err != nil {
		log.Exitf("ERROR: %v", err)
	}
	zones := strings.Split(*zonestr, ",", -1)
	listners := []elb.ELBListener{}
	if *listnersstr != "" {
		listnerstrs := strings.Split(*listnersstr, ",", -1)
		for i := range listnerstrs {
			l := elb.ELBListener{}
			_, err = fmt.Sscanf(listnerstrs[i], "%d:%d:%s", &l.LoadBalancerPort, &l.InstancePort, &l.Protocol)
			if err == nil {
				listners = append(listners, l)
			} else {
				log.Exitf("Invalid listener: %v", err)
			}
		}
	}
	ch := aws.NewConnection(ep, "tcp", "", true)
	auth, err := aws.NewIdentity("sha256", *accessKey, *secretKey)
	if err != nil {
		log.Exitf("ERROR: %v", err)
	}

	elbh := elb.NewHandler(ch, auth)
	if *doCreate {
		out, err := elbh.CreateLoadBalancer(zones, listners, *lbName)
		if err != nil {
			log.Exitf("ERROR: %v", err)
		}
		log.Printf("DNSName: %s", out)
	}
	if *doDelete {
		err := elbh.DeleteLoadBalancer(*lbName)
		if err != nil {
			log.Exitf("ERROR: %v", err)
		}
	}
}
Example #2
0
func GetAWSIdentity() (s cryptools.NamedSigner, err os.Error) {
	if accessKeyId == nil || secretKeyId == nil || *accessKeyId == "" || *secretKeyId == "" {
		return nil, os.NewError("-access-key and -secret-key are both required")
	}
	return aws.NewIdentity("sha256", *accessKeyId, *secretKeyId)
}