我对boto自动化相对较新,并创建了一个脚本,使用python的boto API在AWS上设置自动缩放基础架构。
但是,我无法将我的VPC与我的负载均衡器创建相关联。以下代码返回格式错误的输入错误:
zoneStrings = 'eu-west-1a', 'eu-west-1b' #The availability zones of my VPC
elb_conn = boto.ec2.elb.connect_to_region('eu-west-1') #
lb_name = 'my-lb'
zones = zoneStrings
subnets = 'subnet-09519f50', 'subnet-9fa12dfa' #VPC subnets
ports= [(80, 80, 'http'), (443, 443, 'tcp')]
lb = elb_conn.create_load_balancer(lb_name, zones, subnets, ports)
完整错误是:
Traceback (most recent call last):
File "./test.py", line 70, in <module>
lb = elb_conn.create_load_balancer(lb_name, zones, subnets, ports)
File "/usr/local/lib/python2.7/dist-packages/boto/ec2/elb/__init__.py", line 243, in create_load_balancer
params, LoadBalancer)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1207, in get_object
raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<Error>
<Type>Sender</Type>
<Code>MalformedInput</Code>
</Error>
<RequestId>12659703-a021-11e4-9488-1f8ceceab6a1</RequestId>
</ErrorResponse>
非常感谢任何见解。
答案 0 :(得分:0)
boto文档指出create_load_balancer
方法的参数顺序为:
您似乎以不同的顺序提供它们。也许最安全的方法是使用关键字参数而不是依赖于位置顺序。所以:
lb = elb_conn.create_load_balancer(name=lb_name, zones=zones, subnets=subnets, listeners=ports)
这对你有用吗?