Esempio n. 1
0
func create(e *ec2.EC2, args ...string) {
	if len(args) == 0 {
		fmt.Fprintf(os.Stderr, "create: need image id\n")
		os.Exit(1)
	}

	options := ec2.RunInstances{
		ImageId:      args[0],
		InstanceType: "t1.micro",
	}

	if len(args) == 2 {
		options.InstanceType = args[1]
	}

	resp, err := e.RunInstances(&options)
	if err != nil {
		fmt.Fprintf(os.Stderr, "create: %s\n", err)
		os.Exit(1)
	}

	for _, instance := range resp.Instances {
		fmt.Println(instance.InstanceId)
	}
}