Hello,
I am developing a boto python script to create an auto-scaling group in AWS.
To start with I am connecting to my region 'eu-west-1', then getting a list of availability zones for this region:
conn_reg = boto.ec2.connect_to_region(region)
zones = conn_reg.get_all_zones()
zoneStrings = []
for zone in zones:
if zones is None:
print "Error, No availability zones available"
else:
print "Availability zone list established"
print "Available zones: %s" % (zoneStrings)
This all works fine and prints out the following:
Availability zone list established
Available zones: [u'eu-west-1a', u'eu-west-1b', u'eu-west-1c'] #I looked up the u and it means unicode
However, when I move on to the next step, creating the load balancer, i recieve the following error:
Traceback (most recent call last):
File "./test.py", line 82, in <module>
elastic_load_balancer['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 1204, in get_object
raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<Error>
<Type>Sender</Type>
<Code>ValidationError</Code>
<Message>Invalid Availability Zone: eu-west-1a</Message>
</Error>
<RequestId>df1cd31c-9cd6-11e4-a081-cf6219f7a6ec</RequestId>
</ErrorResponse>
The code to create my load balancer is as follows:
hc = HealthCheck('healthCheck',
interval=elastic_load_balancer['interval'],
target=elastic_load_balancer['health_check_target'],
timeout=elastic_load_balancer['timeout'])
lb = conn_elb.create_load_balancer(elastic_load_balancer['name'],
zoneStrings,
elastic_load_balancer['ports'])
lb.configure_health_check(hc)
print "Map the CNAME of your website to: %s" % (lb.dns_name)
print "Load balancer successfully created! Please check aws for more information."
I am using dictionaries to map parameters to the code. The are defined at the beginning.
region = "eu-west-1" #The region I am connecting to
aws_access_key_id = 'AKIAIDBAGMFZ6OMA5JBQ' #AWS access key
aws_secret_access_key = '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' #AWS secret key
conn_elb = ELBConnection(aws_access_key_id, aws_secret_access_key)
conn_as = AutoScaleConnection(aws_access_key_id, aws_secret_access_key)
# Load balancer dictionary
elastic_load_balancer = {
'name': 'my-lb',#The name of your load balancer
'health_check_target': 'HTTP:8080/',#Location to perform health checks
'ports': [(80, 8080, 'http'), (443, 8443, 'tcp')],#[Load Balancer Port, EC2 Instance Port, Protocol]
'timeout': 5, #Number of seconds to wait for a response from a ping
'interval': 30 #Number of seconds between health checks
}
I though that it might be because I did not have an endpoint established, but this is not a parameter for creating the load balancer and creates further errors.
I have never encountered this error before and do not have a vast amount of experience in python programming. Any insights would be greatly appreciated.