Ejemplo n.º 1
0
func (ecs *ECS) CreateInstance(_params map[string]string) (resp CreateInstance, _ error) {
	params := map[string]string{
		"Action": "CreateInstance",
	}
	for k, v := range _params {
		params[k] = v
	}
	var errs errors.Errors
	for k, v := range map[string]string{
		"Password":        "******",
		"ImageId":         "image",
		"InstanceType":    "type",
		"SecurityGroupId": "group",
		"InstanceName":    "name",
		"RegionId":        "region",
	} {
		if len(params[k]) < 1 {
			errs.Add(fmt.Sprintf("Please provide --%s.", v))
		}
	}
	if errs.HaveError() {
		return resp, errs.Errorify()
	}
	return resp, ecs.Request(params, &resp)
}
Ejemplo n.º 2
0
func ForAllRegionsDo(do func(region string) (err error)) (err error) {
	var regions ECSRegions
	var wg sync.WaitGroup
	var errs errors.Errors
	regions, _, err = ECS_INSTANCE.DescribeRegions()
	if err != nil {
		return
	}
	for _, region := range regions {
		wg.Add(1)
		go func(region string) {
			err := do(region)
			if err != nil {
				errs.Add(err.Error())
			}
			wg.Done()
		}(region.RegionID)
	}
	wg.Wait()
	if errs.HaveError() {
		err = errs.Errorify()
		return
	}
	return
}