コード例 #1
0
ファイル: server.go プロジェクト: JonPulfer/goamz
func removeInstanceFromLB(lb *elb.LoadBalancerDescription, id string) {
	index := -1
	for i, instance := range lb.Instances {
		if instance.InstanceId == id {
			index = i
			break
		}
	}
	if index > -1 {
		copy(lb.Instances[index:], lb.Instances[index+1:])
		lb.Instances = lb.Instances[:len(lb.Instances)-1]
	}
}
コード例 #2
0
ファイル: server.go プロジェクト: JonPulfer/goamz
func (srv *Server) makeLoadBalancerDescription(value url.Values) *elb.LoadBalancerDescription {
	lds := []elb.ListenerDescription{}
	i := 1
	protocol := value.Get(fmt.Sprintf("Listeners.member.%d.Protocol", i))
	for protocol != "" {
		key := fmt.Sprintf("Listeners.member.%d.", i)
		lInstPort, _ := strconv.Atoi(value.Get(key + "InstancePort"))
		lLBPort, _ := strconv.Atoi(value.Get(key + "LoadBalancerPort"))
		lDescription := elb.ListenerDescription{
			Listener: elb.Listener{
				Protocol:         strings.ToUpper(protocol),
				InstanceProtocol: strings.ToUpper(value.Get(key + "InstanceProtocol")),
				LoadBalancerPort: lLBPort,
				InstancePort:     lInstPort,
			},
		}
		i++
		protocol = value.Get(fmt.Sprintf("Listeners.member.%d.Protocol", i))
		lds = append(lds, lDescription)
	}
	sourceSecGroup := srv.makeSourceSecGroup(value)
	lbDesc := elb.LoadBalancerDescription{
		AvailabilityZones:    srv.getParameters("AvailabilityZones.member.", value),
		Subnets:              srv.getParameters("Subnets.member.", value),
		SecurityGroups:       srv.getParameters("SecurityGroups.member.", value),
		HealthCheck:          srv.makeHealthCheck(value),
		ListenerDescriptions: lds,
		Scheme:               value.Get("Scheme"),
		SourceSecurityGroup:  sourceSecGroup,
		LoadBalancerName:     value.Get("LoadBalancerName"),
	}
	if lbDesc.Scheme == "" {
		lbDesc.Scheme = "internet-facing"
	}
	return &lbDesc
}