如何在VPC中使用boto创建ELB?
def create_lb(lb_name):
'create a new load balancer'
region = ['ap-southeast-1']
zones = ['none']
subnets = ['subnet-0d0b3379']
ports= [(80, 80, 'http'), (443, 443, 'tcp')]
lb = lb_conn.create_load_balancer(lb_name, zones, subnets, ports)
hc = HealthCheck(
interval=20,
healthy_threshold=3,
unhealthy_threshold=5,
target='HTTP:80/health')
lb.configure_health_check(hc)
print lb.dns_name
根据上面的定义,我正在一个虚拟私有云(VPC)里创建负载均衡器(lb),但是它显示出了一些问题:
<Code>MalformedInput</Code>
请帮我解决这个问题。
提前谢谢你。
3 个回答
0
我用下面的代码来创建负载均衡器:
conn = boto.connect_elb() lb = conn.create_load_balancer(name="lbName", listeners= [(80,80,'http')], zones=None, subnets=["subnet-xxxxxx", "subnet-xxxxxxx", "subnet-xxxxxxx"],security_groups=["sg-xxxxxxx"])
我选择了两个不同可用区的子网,这样可以让负载均衡器的可用性更高。
请忽略这个链接(只是为了测试): https://stackoverflow.com/questions/25545dfd058/how-tfdfo-create-elb-inside-vpc-using-boto#answer-32311648
0
值 none
对于 zones
参数来说是不合法的。你必须至少指定一个有效的可用区,这个可用区是你创建负载均衡器的区域内的。
0
我把区域从'none'改成了
zones = ['ap-southeast-1a','ap-southeast-1b']
但是它还是显示同样的错误,
boto.exception.BotoServerError: BotoServerError: 400 错误请求