Error: Invalid Availability Zone: eu-west-1a

354 views
Skip to first unread message

Anna Dowling

unread,
Jan 15, 2015, 12:16:17 PM1/15/15
to boto-...@googlegroups.com
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:
    zoneStrings.append(zone.name)
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
ec2_region_endpoint = 'ec2.eu-west-1.amazonaws.com' #endpoint for server addresses associated with this region.
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.

Adrian Klaver

unread,
Jan 15, 2015, 12:51:48 PM1/15/15
to boto-...@googlegroups.com
On 01/15/2015 09:16 AM, Anna Dowling wrote:
> Hello,

A couple of things, see inline notes below.
From below I see:

conn_elb = ELBConnection(aws_access_key_id, aws_secret_access_key)

I see no region specified. By default the region is 'us-east-1' or
whatever is specified in the boto conf file. Are you sure what region
you are connecting to?

>
>
>
> 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
> ec2_region_endpoint = 'ec2.eu-west-1.amazonaws.com' #endpoint for server
> addresses associated with this region.
> aws_access_key_id = 'AKIAIDBAGMFZ6OMA5JBQ' #AWS access key
> aws_secret_access_key = 'MEOWgKLf1ejCniz7/7eluSI9MKc/yRWubtK5bg7y' #AWS
> secret key

I hope the above are dummy values, otherwise I would suggest creating
new ones.

> 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.
>
> --
> You received this message because you are subscribed to the Google
> Groups "boto-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to boto-users+...@googlegroups.com
> <mailto:boto-users+...@googlegroups.com>.
> To post to this group, send email to boto-...@googlegroups.com
> <mailto:boto-...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/boto-users.
> For more options, visit https://groups.google.com/d/optout.


--
Adrian Klaver
adrian...@aklaver.com

Anna Dowling

unread,
Jan 15, 2015, 1:18:59 PM1/15/15
to boto-...@googlegroups.com
Hi Adrian,

Yes they are dummy values from an old project.
The region is specified at the start of the code with the other parameters: region = "eu-west-1".
I then connect to this as follows : conn_reg = boto.ec2.connect_to_region(region), passing in the specified parameter.

This then allows me to return the availability zones for this region : zones = conn_reg.get_all_zones()

I hope that makes things a little clearer.

Adrian Klaver

unread,
Jan 15, 2015, 1:40:21 PM1/15/15
to boto-...@googlegroups.com
On 01/15/2015 10:18 AM, Anna Dowling wrote:
> Hi Adrian,
>
> Yes they are dummy values from an old project.
> The region is specified at the start of the code with the other
> parameters: region = "eu-west-1".
> I then connect to this as follows : conn_reg =
> boto.ec2.connect_to_region(region), passing in the specified parameter.
>
> This then allows me to return the availability zones for this region :
> zones = conn_reg.get_all_zones()

I saw that, but it is a different connection. The connection that is
failing is conn_elb. The different connections are independent of each
other.

>
> I hope that makes things a little clearer.
>
>
> On Thursday, January 15, 2015 at 5:51:48 PM UTC, Adrian Klaver wrote:
>
> On 01/15/2015 09:16 AM, Anna Dowling wrote:
> > Hello,
>
> A couple of things, see inline notes below.
>
> >
> > 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:
> > zoneStrings.append(zone.name <http://zone.name>)
> <http://ec2.eu-west-1.amazonaws.com>' #endpoint for server
> > an email to boto-users+...@googlegroups.com <javascript:>
> > <mailto:boto-users+...@googlegroups.com <javascript:>>.
> > To post to this group, send email to boto-...@googlegroups.com
> <javascript:>
> > <mailto:boto-...@googlegroups.com <javascript:>>.
> <http://groups.google.com/group/boto-users>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> Adrian Klaver
> adrian...@aklaver.com <javascript:>
>
> --
> You received this message because you are subscribed to the Google
> Groups "boto-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to boto-users+...@googlegroups.com
> <mailto:boto-users+...@googlegroups.com>.

Anna Dowling

unread,
Jan 15, 2015, 1:58:41 PM1/15/15
to boto-...@googlegroups.com
Apologies, I am not accustomed to these forums.

You are correct, conn_elb = ELBConnection(aws_access_key_id, aws_secret_access_key), is connecting to the load balancer, but there is no region specified here.

So are you suggesting that the region needs to be passed in here aswell; if so, would this also be the case for the auto scaling connection? 



     > <mailto:boto-users+unsub...@googlegroups.com <javascript:>>.

     > To post to this group, send email to boto-...@googlegroups.com
    <javascript:>
     > <mailto:boto-...@googlegroups.com <javascript:>>.
     > Visit this group at http://groups.google.com/group/boto-users
    <http://groups.google.com/group/boto-users>.
     > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.


    --
    Adrian Klaver
    adrian...@aklaver.com <javascript:>

--
You received this message because you are subscribed to the Google
Groups "boto-users" group.
To unsubscribe from this group and stop receiving emails from it, send

To post to this group, send email to boto-...@googlegroups.com


--
Adrian Klaver
adrian...@aklaver.com


--
You received this message because you are subscribed to a topic in the Google Groups "boto-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/boto-users/MLtL7gIx3SM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to boto-users+unsubscribe@googlegroups.com.
To post to this group, send email to boto-...@googlegroups.com.

Adrian Klaver

unread,
Jan 15, 2015, 2:01:59 PM1/15/15
to boto-...@googlegroups.com
On 01/15/2015 10:58 AM, Anna Dowling wrote:
> Apologies, I am not accustomed to these forums.
>
> You are correct, conn_elb = ELBConnection(aws_access_key___id,
> aws_secret_access_key), is connecting to the load balancer, but there is
> no region specified here.
>
> So are you suggesting that the region needs to be passed in here aswell;
> if so, would this also be the case for the auto scaling connection?

Yes. You can set up a conf file that would provide this information, see
here:

http://boto.readthedocs.org/en/latest/elb_tut.html
>
>
>


--
Adrian Klaver
adrian...@aklaver.com

Anna Dowling

unread,
Jan 15, 2015, 2:03:53 PM1/15/15
to boto-...@googlegroups.com
Thank you for your help, I really appreciate it.
 I will try this now.







--
Adrian Klaver
adrian...@aklaver.com

Reply all
Reply to author
Forward
0 new messages