These commits add support for listing, creating and removing tags to and from RDS-DBInstances (ListTagsForResource, AddTagsToResource and RemoveTagsFromResource API calls).
Amazon requires an ARN to reference the DBInstance on which the actions are performed, but doesn't supply this ARN, afaik. I added a property to the DBInstance-class, which uses IAM (for the account-id) to construct the ARN itself when asked for. It's not very clean, but I didn't see another way. If Amazon does supply the ARN in another way, or in the future, this could easily be removed while retaining backwards compatibility.
I'm hoping to add support for a TaggedRDSResource, similar to the TaggedEC2Resource.
I welcome your thought and suggestions!
PS: this is the same pull-request as #1050, but from it's own branch
Implement classmethods for getting, adding and removing tags as methods from boto.rds.DBInstance. This is different than the implementation of EC2 tags. This is due to differences in the API: the EC2 API offers tags for more than just Instances, hence the superclass TaggedEC2Object. It also supplies all tags from a resource in each DescribeResource API call.
RDS only offers tags for DBInstances, and separate API calls are needed to retrieve them.
However, the interface for the user (dbinstance.tags, dbinstance.add_tag(key, value) and dbinstance.remove_tag(key)) is the same as for EC2 tags. If Amazon in the future does provide tags in the same way as EC2 tags, this could easily be refactored (and maybe even use the same superclass).
Implement a wrapper object for User-data from IAM
Fetch account-id from IAM and construct ARN for a dbinstance, when db…
…instance.arn is requested.
Add an RDSTag-object, based on ec2/tag.py
Implement ListTagsForResource, AddTagsToResource and RemoveTagsFromRe…
…source from RDS API
Merge remote-tracking branch 'upstream/develop' into develop
Can we get this in?
implement dbinstance.tags property, and dbinstance.add_tag(key,value)…
… and dbinstance.remove_tag(key) methods
Add documentation for dbinstance.arn property
Merge branch 'pull/classmethods-for-tagging-dbinstance' into pull/imp…
👍 would love to see this merged in
Me too :). But I haven't received feedback from Mitch, so I don't know what it's waiting for.
Thanks for this patch. I have it monkey patched into our code. One thing I would like to mention is that you are getting the account_id via an IAM call which we may not have access to since we are doing these calls as a third party on behalf of our clients using restricted IAM roles. Instead we grab the account id through the security groups API:
sg = ec2.get_all_security_groups()
account_id = sg.owner_id
I had previously implemented the same functionality and bowed to this one, but I've recently opened another pull request, #1641 which also has unit tests for everything.
+1 This is already merged?
+1. This would be nice to have.
+1. Could really do with being able to see the tags on RDS instances as well as on EC2.
+1 Could definitely use this feature as well.
Would someone on the Boto team mind telling us what you'd want for this to get merged? It looks like #1641 has unit tests, which wasn't enough to get it merged, either. I'm happy to take a stab at whatever improvements you guys are looking for.
@bpollack This PR wasn't merged because there aren't any tests on it. The rough consensus is that some combination of this & #1061 + tests would be best, but there hasn't been time to get back there.
We're still discussing what to do about RDS, given that we're lagging significantly behind on the module vs. the API. I'll update here when we have something to share.
+1 for sure
Please note that boto now contains a new rds2 module with the latest Amazon RDS API support. It is a low-level module, but supports all the new features and is significantly easier for us to maintain.
This module will be released soon in boto 2.26.0.
Is there a ETA on 2.26.0?
Boto-2.26.0 is now out! Closing this PR for the time being - please resubmit with tests if you wish to backport these features to boto.rds.