func()

in cmd/service_create.go [72:94]


func (o *ServiceCreateOperation) SetLoadBalancer(lb string) {
	if o.Port.Empty() {
		console.IssueExit("Setting a load balancer requires a port")
	}

	elbv2 := ELBV2.New(sess)
	loadBalancer := elbv2.DescribeLoadBalancer(lb)

	if loadBalancer.Type == typeNetwork {
		if o.Port.Protocol != protocolTcp {
			console.ErrorExit(fmt.Errorf("network load balancer %s only supports TCP", lb), "Invalid load balancer and protocol")
		}
	}

	if loadBalancer.Type == typeApplication {
		if !(o.Port.Protocol == protocolHttp || o.Port.Protocol == protocolHttps) {
			console.ErrorExit(fmt.Errorf("application load balancer %s only supports HTTP or HTTPS", lb), "Invalid load balancer and protocol")
		}
	}

	o.LoadBalancerName = lb
	o.LoadBalancerArn = loadBalancer.ARN
}