Filtering Volume id's of Auto Scaling Group

101 views
Skip to first unread message

boto.u...@gmail.com

unread,
Jan 29, 2015, 10:26:14 AM1/29/15
to boto-...@googlegroups.com
Hello,

I am attempting to use the filters of the get_all_volumes function to find my volume id of
my auto-scaling group. I am filtering by the tag-value (My_ASG) of my autoscaling group in order to ensure it returns the associated volume, as this tag appears in the attachment information field of the volume.


conn = boto.ec2.connect_to_region(region) # connect to EC2
vol = conn.get_all_volumes(filters={'tag-value': 'My_ASG'})

I am getting back the following error:

<Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Value ([]) for parameter volumeId is invalid. Expected: 'vol-...'.</Message>
</Error></Errors><RequestID>f783506b-ffa4-487a-8acc-2f3d999cf0f0</RequestID></Response>

I would like to know if there is a better way to filter the volume in relation to its auto scaling group. Any help would be great,

Thanks.

Adrian Klaver

unread,
Jan 29, 2015, 11:22:33 AM1/29/15
to boto-...@googlegroups.com
On 01/29/2015 07:26 AM, boto.u...@gmail.com wrote:
> Hello,
>
> I am attempting to use the filters of the get_all_volumes function to
> find my volume id of
> my auto-scaling group. I am filtering by the tag-value (My_ASG) of my
> autoscaling group in order to ensure it returns the associated volume,
> as this tag appears in the attachment information field of the volume.
>
>
> conn = boto.ec2.connect_to_region(region) # connect to EC2
> vol = conn.get_all_volumes(filters={'tag-value': 'My_ASG'})

The tag filter format is as follows assuming you have a tag named
SomeTag and a value 'SomeValue'

filters={"tag:SomeTag": "SomeValue"})

>
> I am getting back the following error:
>
> <Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Value ([])
> for parameter volumeId is invalid. Expected: 'vol-...'.</Message>
> </Error></Errors><RequestID>f783506b-ffa4-487a-8acc-2f3d999cf0f0</RequestID></Response>
>
> I would like to know if there is a better way to filter the volume in
> relation to its auto scaling group. Any help would be great,
>
> Thanks.

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

boto user

unread,
Jan 29, 2015, 12:08:35 PM1/29/15
to boto-...@googlegroups.com
I tried this convention and it still does not work:
vol = conn.get_all_volumes(filters={"tag:Name": "My_Tag"})

I still receive the same error as before. This tag is my autoscaling group tag, which appears, along with the ami-id in the attachment information for the volume id.
Any other ideas?



--
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/Bb7cg334yM4/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.
Visit this group at http://groups.google.com/group/boto-users.
For more options, visit https://groups.google.com/d/optout.

Adrian Klaver

unread,
Jan 29, 2015, 12:22:42 PM1/29/15
to boto-...@googlegroups.com
On 01/29/2015 09:08 AM, boto user wrote:
> I tried this convention and it still does not work:
> vol = conn.get_all_volumes(filters={"tag:Name": "My_Tag"})
>
> I still receive the same error as before. This tag is my autoscaling
> group tag, which appears, along with the ami-id in the attachment
> information for the volume id.
> Any other ideas?

What boto module is generating the conn?

Where are you seeing the attachment information?

>



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

boto user

unread,
Jan 29, 2015, 12:33:47 PM1/29/15
to boto-...@googlegroups.com
ec2 is generating the connection. 

I found the attachment information in the volume console where I view the volume details on AWS.







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

Adrian Klaver

unread,
Jan 29, 2015, 12:40:39 PM1/29/15
to boto-...@googlegroups.com
On 01/29/2015 09:33 AM, boto user wrote:
> ec2 is generating the connection.
>
> I found the attachment information in the volume console where I view
> the volume details on AWS.

Under the Description tab or the Tags tab?

>
> On Thu, Jan 29, 2015 at 5:22 PM, Adrian Klaver
> <adrian...@aklaver.com <mailto:adrian...@aklaver.com>> wrote:
>
> On 01/29/2015 09:08 AM, boto user wrote:
>
> I tried this convention and it still does not work:
> vol = conn.get_all_volumes(filters={__"tag:Name": "My_Tag"})
>
> I still receive the same error as before. This tag is my autoscaling
> group tag, which appears, along with the ami-id in the attachment
> information for the volume id.
> Any other ideas?
>
>
> What boto module is generating the conn?
>
> Where are you seeing the attachment information?
>
>
>
>
>
>
> --
> Adrian Klaver
> adrian...@aklaver.com <mailto: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/Bb7cg334yM4/__unsubscribe
> <https://groups.google.com/d/topic/boto-users/Bb7cg334yM4/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> boto-users+unsubscribe@__googlegroups.com
> <mailto:boto-users%2Bunsu...@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
> <http://groups.google.com/group/boto-users>.
> For more options, visit https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
> --
> 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

boto user

unread,
Jan 30, 2015, 7:07:04 AM1/30/15
to boto-...@googlegroups.com
There is a tab called Attachment Information with the details contained in it.

On Thu, Jan 29, 2015 at 5:40 PM, Adrian Klaver <adrian...@aklaver.com> wrote:
On 01/29/2015 09:33 AM, boto user wrote:
ec2 is generating the connection.

I found the attachment information in the volume console where I view
the volume details on AWS.

Under the Description tab or the Tags tab?


On Thu, Jan 29, 2015 at 5:22 PM, Adrian Klaver
<adrian...@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:

    On 01/29/2015 09:08 AM, boto user wrote:

        I tried this convention and it still does not work:
        vol = conn.get_all_volumes(filters={__"tag:Name": "My_Tag"})

        I still receive the same error as before. This tag is my autoscaling
        group tag, which appears, along with the ami-id in the attachment
        information for the volume id.
        Any other ideas?


    What boto module is generating the conn?

    Where are you seeing the attachment information?






    --
    Adrian Klaver


    --
    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/Bb7cg334yM4/__unsubscribe
    <https://groups.google.com/d/topic/boto-users/Bb7cg334yM4/unsubscribe>.
    To unsubscribe from this group and all its topics, send an email to
    boto-users+unsubscribe@__googlegroups.com
    <mailto:boto-users%2Bunsu...@googlegroups.com>.
    To post to this group, send email to boto-...@googlegroups.com

    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>.


--
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/Bb7cg334yM4/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 30, 2015, 10:05:08 AM1/30/15
to boto-...@googlegroups.com
On 01/30/2015 04:07 AM, boto user wrote:
> There is a tab called Attachment Information with the details contained
> in it.
>

Hmm, I do not see that. In any case if the the information is not under
Tags, you will not be able to filter using a tag. So either you need to
add a tag or go a different route. Per the boto docs:

filters (dict) – Optional filters that can be used to limit the results
returned. Filters are provided in the form of a dictionary consisting of
filter names as the key and filter values as the value. The set of
allowable filter names/values is dependent on the request being
performed. Check the EC2 API guide for details.

So the relevant EC2 API docs are the following:

http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-DescribeVolumes.html

Look for Supported Filters


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

boto.u...@gmail.com

unread,
Feb 2, 2015, 5:11:03 AM2/2/15
to boto-...@googlegroups.com
Hi again!

 I have tried filtering by a different parameter, the snapshot id as follows (snap is declared as a global variable):


    conn = boto.ec2.connect_to_region(region) # connect to EC2
    vol = conn.get_all_volumes(filters={'snapshot-id': snap})

It is still giving me the error message but it is returning the correct volume-id in the error:

<Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Value ([Volume:vol-c9d637cf]) for parameter volumeId is invalid. Expected: 'vol-...'.</Message></Error></Errors><RequestID>1e4a05df-5b7a-4e32-b7d5-bd3fd46bfd36</RequestID></Response>

So the returned value is in the wrong format. I am unsure as to how to convert this.

Adrian Klaver

unread,
Feb 2, 2015, 9:30:36 AM2/2/15
to boto-...@googlegroups.com
On 02/02/2015 02:11 AM, boto.u...@gmail.com wrote:
> Hi again!
>
> I have tried filtering by a different parameter, the snapshot id as
> follows (snap is declared as a global variable):
>
>
> conn = boto.ec2.connect_to_region(region) # connect to EC2
> vol = conn.get_all_volumes(filters={'snapshot-id': snap})
>
> It is still giving me the error message but it is returning the correct
> volume-id in the error:
>
> <Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Value ([Volume:vol-c9d637cf])
> for parameter volumeId is invalid. Expected:
> 'vol-...'.</Message></Error></Errors><RequestID>1e4a05df-5b7a-4e32-b7d5-bd3fd46bfd36</RequestID></Response>
>
> So the returned value is in the wrong format. I am unsure as to how to
> convert this.

Looks to me like there is more code after:

vol = conn.get_all_volumes(filters={'snapshot-id': snap})

and that you are submitting a list(vol I assume) [Volume:vol-c9d637cf]
instead of an item from the list vol[0], Volume:vol-c9d637cf


--
Adrian Klaver
adrian...@aklaver.com
Reply all
Reply to author
Forward
0 new messages