Vikash Singh
Vikash Singh

Reputation: 14011

AutoScaleConnection.get_all_groups() not working with boto

I tried to connect to aws autoscale and get all groups. I got following error:

from boto import ec2
from boto.ec2.autoscale import AutoScaleConnection
import boto
AWS_ACCESS_KEY = "<key>"
AWS_SECRET_KEY = "secret"
REGION = 'us-west-1'
region_info = boto.ec2.get_region('us-west-1')

conn = AutoScaleConnection(aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY, region=region_info)

conn.get_all_groups()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/boto/ec2/autoscale/__init__.py", line 342, in get_all_groups
    [('member', AutoScalingGroup)])
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1185, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidAction</Code><Message>The action DescribeAutoScalingGroups is not valid for this web service.</Message></Error></Errors><RequestID>sadsdasdsdsdsadasdasd</RequestID></Response>

I tried another approach : This worked

conn = boto.ec2.autoscale.connect_to_region('us-west-1')
conn.get_all_groups()

But i dont want to use the default configuration file stored by boto. I want to provide the access keys etc as parameters (as tried in the above example)

Any help is appreciated.

I am following this tutorial: http://boto.readthedocs.org/en/latest/autoscale_tut.html

Upvotes: 1

Views: 736

Answers (1)

garnaat
garnaat

Reputation: 45906

You can still pass in explicit credentials to the connect_to_region method, like this:

import boto.ec2.autoscale
conn = boto.ec2.autoscale.connect_to_region('us-west-2', aws_access_key_id='YOUR_ACCESS_KEY', aws_secret_access_key='YOUR_SECRET_KEY')
conn.get_all_groups()

This way you can allow boto to handle the complications of creating RegionInfo objects for you.

Upvotes: 2

Related Questions