getting snapshots by tag for rds2

835 views
Skip to first unread message

harpingon

unread,
Apr 13, 2015, 7:56:49 AM4/13/15
to boto-...@googlegroups.com
Hello

Trying to get a list of db_snapshots via rds2, filtered by tag.

I'm trying this:

       snapshots=s.rds2conn.describe_db_snapshots(filters={'tag:tenant':tenant,})


Because I have a tag key of 'tenant' and the value is in 'tenant' variable.

I get this response:

JSONResponseError: 400 Bad Request

 u
'Error': {u'Message': u'Unrecognized filter name: null', u'Code': u'InvalidParameterValue', u'Type': u'Sender'



If I remove the filters clause, it works, although unfiltered.

Have I got the correct syntax for tag filter on rds2 describe_db_snapshots? Can it even be done?

I do think sometimes that rds support in boto is more  muddled than it should be.

Can't find many (any) rds2 examples online

Thanks!

Adrian Klaver

unread,
Apr 13, 2015, 9:05:56 AM4/13/15
to boto-...@googlegroups.com
On 04/13/2015 04:21 AM, harpingon wrote:
> Hello
>
> Trying to get a list of db_snapshots via rds2, filtered by tag.
>
> I'm trying this:
>
> |
>
> snapshots=s.rds2conn.describe_db_snapshots(filters={'tag:tenant':tenant,})
> |
>
>
> Because I have a tag key of 'tenant' and the value is in 'tenant' variable.
>
> I get this response:
>
> |
> JSONResponseError:400BadRequest
>
> u'Error':{u'Message':u'Unrecognized filter name:
> null',u'Code':u'InvalidParameterValue',u'Type':u'Sender'
>
>
> |
>
> If I remove the filters clause, it works, although unfiltered.
>
> Have I got the correct syntax for tag filter on rds2
> describe_db_snapshots? Can it even be done?

Well from here:

http://boto.readthedocs.org/en/latest/ref/rds2.html

It says filters is a list, so have you tried:

snapshots=s.rds2conn.describe_db_snapshots(filters=[{'tag:tenant':tenant,}])

>
> I do think sometimes that rds support in boto is more muddled than it
> should be.
>
> Can't find many (any) rds2 examples online
>
> Thanks!
>
> --
> 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

harpingon

unread,
Apr 13, 2015, 10:03:16 AM4/13/15
to boto-...@googlegroups.com
Darn it you know, I was really close at one point.

This worked:

describe_db_snapshots(filters=[{'tag:tenant':tenant},])

As distinct from:

describe_db_snapshots(filters=[{'tag:tenant':tenant,}])

Which doesn't :)

I had the tag in a list at one point, but I had the the comma in the wrong place.

Thanks for the kick in the right direction.

Jeff Gentile

unread,
Apr 22, 2015, 10:37:29 AM4/22/15
to boto-...@googlegroups.com
Im trying the same thing as you, and it isn't working...


snapshotList = rdsWestConn.describe_db_snapshots(filters=[{'tag:Name': 'Python Automated'}])

boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
{u'RequestId': u'e181a4a6-e8fc-11e4-82c3-9735a38857d9', u'Error': {u'Message': u'Unrecognized filter name: null', u'Code': u'InvalidParameterValue', u'Type': u'Sender'}}

Adrian Klaver

unread,
Apr 22, 2015, 11:10:07 AM4/22/15
to boto-...@googlegroups.com
On 04/22/2015 07:37 AM, Jeff Gentile wrote:
> Im trying the same thing as you, and it isn't working...
>

Well according to the previous post in this thread the below:
>
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:Name':'Python Automated'}])

should be:

snapshotList=rdsWestConn.describe_db_snapshots(filter
[{'tag:Name':'Python Automated'}, ])

Note the comma after the dictionary.

CADevOp

unread,
Apr 22, 2015, 1:58:10 PM4/22/15
to boto-...@googlegroups.com
Thanks for the reply!

I've tried both ways and neither seem to be working...

snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python Automated'},])
snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python Automated'}])


Still get the same error message:

boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
{u'RequestId': u'de60f36f-e918-11e4-adb1-b56a10e0bb83', u'Error': {u'Message': u'Unrecognized filter name: null', u'Code': u'InvalidParameterValue', u'Type': u'Sender'}}

Adrian Klaver

unread,
Apr 22, 2015, 4:35:52 PM4/22/15
to boto-...@googlegroups.com
On 04/22/2015 10:58 AM, CADevOp wrote:
> Thanks for the reply!
>
> I've tried both ways and neither seem to be working...
>
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python Automated'},])
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python Automated'}])
>
>
> Still get the same error message:
>
>
> boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
> {u'RequestId': u'de60f36f-e918-11e4-adb1-b56a10e0bb83', u'Error':
> {u'Message': u'Unrecognized filter name: null', u'Code':
> u'InvalidParameterValue', u'Type': u'Sender'}}
>

Hmm, is there a managedBy tag on the snapshots?



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

Jeff Gentile

unread,
Apr 22, 2015, 4:59:54 PM4/22/15
to boto-...@googlegroups.com

There is. Name was in there by accident.  Key = managed by. Value = python automated

iPhone. iTypos. iApologize

--
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/9xmmHOp_NNg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to boto-users+...@googlegroups.com.
To post to this group, send email to boto-...@googlegroups.com.

Adrian Klaver

unread,
Apr 22, 2015, 7:30:56 PM4/22/15
to boto-...@googlegroups.com
On 04/22/2015 01:59 PM, Jeff Gentile wrote:
> There is. Name was in there by accident. Key = managed by. Value =
> python automated

I am not following.

Does this mean it works now?


>
> iPhone. iTypos. iApologize
>
> On Apr 22, 2015 4:35 PM, "Adrian Klaver" <adrian...@aklaver.com
> <mailto:adrian...@aklaver.com>> wrote:
>
> On 04/22/2015 10:58 AM, CADevOp wrote:
>
> Thanks for the reply!
>
> I've tried both ways and neither seem to be working...
>
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python
> Automated'},])
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python
> Automated'}])
>
>
> Still get the same error message:
>
>
> boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
> {u'RequestId': u'de60f36f-e918-11e4-adb1-b56a10e0bb83', u'Error':
> {u'Message': u'Unrecognized filter name: null', u'Code':
> u'InvalidParameterValue', u'Type': u'Sender'}}
>
>
> Hmm, is there a managedBy tag on the snapshots?
>
>
>
> --
> Adrian Klaver
> adrian...@aklaver.com <mailto:adrian...@aklaver.com>
>


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

Jeff Gentile

unread,
Apr 22, 2015, 7:50:11 PM4/22/15
to boto-...@googlegroups.com

No. Still not working.  Just mixed up the key when pasting here.

iPhone. iTypos. iApologize

Adrian Klaver

unread,
Apr 22, 2015, 8:03:09 PM4/22/15
to boto-...@googlegroups.com
On 04/22/2015 04:50 PM, Jeff Gentile wrote:
> No. Still not working. Just mixed up the key when pasting here.
>

So, are you trying:

(filters=[{'tag:managed by':'python automated'},])

Remember we can't see your screen:)

I am always leery of empty spaces so have you tried:

(filters=[{"tag:'managed by'": 'python automated'},])



> iPhone. iTypos. iApologize
>
> On Apr 22, 2015 7:30 PM, "Adrian Klaver" <adrian...@aklaver.com
> <mailto:adrian...@aklaver.com>> wrote:
>
> On 04/22/2015 01:59 PM, Jeff Gentile wrote:
>
> There is. Name was in there by accident. Key = managed by. Value =
> python automated
>
>
> I am not following.
>
> Does this mean it works now?
>
>
>
> iPhone. iTypos. iApologize
>
> On Apr 22, 2015 4:35 PM, "Adrian Klaver"
> <adrian...@aklaver.com <mailto:adrian...@aklaver.com>
> <mailto:adrian...@aklaver.com
> <mailto:adrian...@aklaver.com>>> wrote:
>
> On 04/22/2015 10:58 AM, CADevOp wrote:
>
> Thanks for the reply!
>
> I've tried both ways and neither seem to be working...
>
>
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python
> Automated'},])
>
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python
> Automated'}])
>
>
> Still get the same error message:
>
>
> boto.exception.JSONResponseError: JSONResponseError:
> 400 Bad Request
> {u'RequestId': u'de60f36f-e918-11e4-adb1-b56a10e0bb83',
> u'Error':
> {u'Message': u'Unrecognized filter name: null', u'Code':
> u'InvalidParameterValue', u'Type': u'Sender'}}
>
>
> Hmm, is there a managedBy tag on the snapshots?
>
>
>
> --
> Adrian Klaver
> adrian...@aklaver.com <mailto:adrian...@aklaver.com>
> <mailto:adrian...@aklaver.com
> <mailto:adrian...@aklaver.com>>
>
>
>
> --
> 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/9xmmHOp_NNg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> boto-users+...@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.
> For more options, visit 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

Jeff Gentile

unread,
Apr 22, 2015, 8:04:12 PM4/22/15
to boto-...@googlegroups.com

:)  yes. I tried with and without spaces.

iPhone. iTypos. iApologize

To unsubscribe from this group and all its topics, send an email to boto-users+...@googlegroups.com.
To post to this group, send email to boto-...@googlegroups.com.

Adrian Klaver

unread,
Apr 22, 2015, 8:09:16 PM4/22/15
to boto-...@googlegroups.com
On 04/22/2015 05:04 PM, Jeff Gentile wrote:
> :) yes. I tried with and without spaces.

Tried what?

You need to show exactly what you did to eliminate the guessing.

What is the tag as shown in the AWS Management console?

If they are?:

managed by = python automated

What happens if you change to?:

managedBy = pythonAutomated

>
> iPhone. iTypos. iApologize
>


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

Jeff Gentile

unread,
Apr 22, 2015, 8:10:38 PM4/22/15
to boto-...@googlegroups.com

Almost home. I will get screen shots and post them in just a bit

iPhone. iTypos. iApologize

Jeff Gentile

unread,
Apr 23, 2015, 10:04:00 AM4/23/15
to boto-...@googlegroups.com
Here is all the information requested.  Note, I tried the following  for snapshotList:
snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python'}])
snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python'},])

::CODE::
from boto import rds2

rdsWestConn = rds2.connect_to_region('us-west-2')
snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python'}])
print snapshotList


::ERROR::

boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
{u'RequestId': u'09ecef89-e9c1-11e4-9af8-e1d278fbd34d', u'Error': {u'Message': u'Unrecognized filter name: null', u'Code': u'InvalidParameterValue', u'Type': u'Sender'}}


::TAG::
Inline image 1
--
Jeff Gentile
Jr. DevOps Engineer
The Common Application

3003 Washington Blvd. Ste 1000 | Arlington, VA  22201 | 703.236.2721

Adrian Klaver

unread,
Apr 23, 2015, 10:23:15 AM4/23/15
to boto-...@googlegroups.com
On 04/23/2015 07:03 AM, Jeff Gentile wrote:
> Here is all the information requested. Note, I tried the following for
> snapshotList:
>
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python'}])
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python'},])
>
>
> ::CODE::
>
> frombotoimportrds2
>
> rdsWestConn=rds2.connect_to_region('us-west-2')
> snapshotList=rdsWestConn.describe_db_snapshots(filters=[{'tag:managedBy':'Python'}])
> printsnapshotList
>
>
> ::ERROR::
> boto.exception.JSONResponseError: JSONResponseError: 400 Bad Request
> {u'RequestId': u'09ecef89-e9c1-11e4-9af8-e1d278fbd34d', u'Error': {u'Message': u'Unrecognized filter name: null', u'Code': u'InvalidParameterValue', u'Type': u'Sender'}}
>
>
>
> ::TAG::
> Inline image 1
>


Well on the face of it, everything looks like it should work. Not sure
why it is not.

What happens if you run describe_db_snapshots() without the filter?


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

Jeff Gentile

unread,
Apr 23, 2015, 10:32:13 AM4/23/15
to boto-...@googlegroups.com
That brings back all snapshots just fine.




--
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/9xmmHOp_NNg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to boto-users+...@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,
Apr 23, 2015, 10:37:11 AM4/23/15
to boto-...@googlegroups.com
On 04/23/2015 07:32 AM, Jeff Gentile wrote:
> That brings back all snapshots just fine.
>

So if you introspect one of the snapshots do you see tag information?

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

Jeff Gentile

unread,
Apr 23, 2015, 10:42:07 AM4/23/15
to boto-...@googlegroups.com
When I do the following, this is the result I get.  No where in the dictionary are the tags...

CODE::

from
boto import rds2

rdsWestConn = rds2.connect_to_region('us-west-2')
snapshotList=rdsWestConn.describe_db_snapshots()
for snap in snapshotList['DescribeDBSnapshotsResponse']['DescribeDBSnapshotsResult']['DBSnapshots']:
print snap

Result::

{u'Engine': u'mysql', u'SnapshotCreateTime': 1406379334.974, u'AvailabilityZone': u'us-west-2b', u'SourceRegion': None, u'MasterUsername': u'NA', u'VpcId': u'NA', u'LicenseModel': u'general-public-license', u'Status': u'available', u'PercentProgress': 100, u'DBSnapshotIdentifier': u'ca-db-2013-archive-20170726-0855', u'InstanceCreateTime': 1373758541.193, u'OptionGroupName': u'default:mysql-5-6', u'AllocatedStorage': 1536, u'EngineVersion': u'5.6.12', u'SnapshotType': u'manual', u'Iops': 15000, u'Port': 3306, u'DBInstanceIdentifier': u'proddb'}




--
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/9xmmHOp_NNg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to boto-users+...@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,
Apr 23, 2015, 10:58:15 AM4/23/15
to boto-...@googlegroups.com
On 04/23/2015 07:42 AM, Jeff Gentile wrote:
> When I do the following, this is the result I get. No where in the dictionary are the tags...
>
>
> CODE::
>
> frombotoimportrds2
>
> rdsWestConn=rds2.connect_to_region('us-west-2')
> snapshotList=rdsWestConn.describe_db_snapshots()
> forsnap insnapshotList['DescribeDBSnapshotsResponse']['DescribeDBSnapshotsResult']['DBSnapshots']:
> printsnap
>
> Result::
>
>
> {u'Engine': u'mysql', u'SnapshotCreateTime': 1406379334.974, u'AvailabilityZone': u'us-west-2b', u'SourceRegion': None, u'MasterUsername': u'NA', u'VpcId': u'NA', u'LicenseModel': u'general-public-license', u'Status': u'available', u'PercentProgress': 100, u'DBSnapshotIdentifier': u'ca-db-2013-archive-20170726-0855', u'InstanceCreateTime': 1373758541.193, u'OptionGroupName': u'default:mysql-5-6', u'AllocatedStorage': 1536, u'EngineVersion': u'5.6.12', u'SnapshotType': u'manual', u'Iops': 15000, u'Port': 3306, u'DBInstanceIdentifier': u'proddb'}
>
>


Hmm. Digging into the docs found this:

http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBSnapshots.html

Filters.member.N

This parameter is not currently supported.

Type: Filter list

Required: No

And here:

http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DBSnapshot.html

does not show tags being a returned value as you show.

So I not sure what is going on, much less how harpingon got it to work?

Might want to file an issue here:

https://github.com/boto/boto/issues


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

harpingon

unread,
Jun 15, 2015, 4:34:43 AM6/15/15
to boto-...@googlegroups.com
Ah, what I ended up doing is

           
for arn in rdslist['arns']:
                t
=rds2conn.list_tags_for_resource(arn)
                taglist
=t['ListTagsForResourceResponse']['ListTagsForResourceResult']['TagList']
               
for tag in taglist:
                   
print tag['Key'], tag['Value']

So basically I got all my RDS ARNs, then called list_tags_for_resource on each.

I got it to work by not doing it, and doing it a different way instead.

I suppose it's not so efficient to enumerate all my RDS ARNs, then call an API on each one.
Reply all
Reply to author
Forward
0 new messages