Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instance delete_tags() method #381

Closed
jonathanwcrane opened this issue Nov 27, 2015 · 10 comments
Closed

Add instance delete_tags() method #381

jonathanwcrane opened this issue Nov 27, 2015 · 10 comments
Assignees
Labels
ec2 feature-request This issue requests a feature.

Comments

@jonathanwcrane
Copy link
Contributor

So in boto there was instance.add_tag() and instance.remove_tag().

In boto3 there is instance.create_tags() but no corresponding delete_tag()s.

the client resource has delete_tags but the method should exist for the instance object.

Discussion?

@jonathanwcrane jonathanwcrane changed the title No instance delete_tags() method? Add instance delete_tags() method Nov 27, 2015
@JordonPhillips JordonPhillips added feature-request This issue requests a feature. ec2 labels Nov 30, 2015
@JordonPhillips JordonPhillips self-assigned this Nov 30, 2015
@JordonPhillips
Copy link
Contributor

Thanks for reporting, we'll look into adding it

@jonathanwcrane
Copy link
Contributor Author

Thanks, looking forward to it.

@kapilt
Copy link

kapilt commented Dec 2, 2015

you delete tag in boto3 by setting a tag with a value of None

@mlapida
Copy link

mlapida commented Jan 12, 2016

I'm not able to set the Value key to None. I'm getting a type error. Any other way to remove a tag?

@JordonPhillips
Copy link
Contributor

@mlapida You just omit Value

@jonathanwcrane
Copy link
Contributor Author

Could you guys give a quick code example?

JordonPhillips added a commit to JordonPhillips/boto3 that referenced this issue Feb 3, 2016
The Tag resource was incorrectly modeled such that it is not a
collection on an Instance. As a result, there is no way to batch delete
tags from an Instance resource. This adds that functionality in, in a
way that won't break on future EC2 resource changes.

In the long term there are plans to codify SDK specific customizations
while maintaining a canonically correct resource model, but that will
sometime in the future as part of a different story.

Fixes boto#381
@jonathanwcrane
Copy link
Contributor Author

Fantastic! Can you please link to documentation to show how it works now?

@JordonPhillips
Copy link
Contributor

Here's the doc section.

import boto3

ec2 = boto3.client('ec2')
instance = ec2.Instance('id')

# Delete the tag 'foo' if it has value 'bar'
instance.delete_tags(Tags=[{"Key": "foo", "Value": "bar"}])

# Delete the tag 'baz' if it exists
instance.delete_tags(Tags=[{"Key": "baz"}])

# Delete all tags
instance.delete_tags()

@jonathanwcrane
Copy link
Contributor Author

Awesome. You guys are ⁉️➗➰⚡ good.

@progre55
Copy link

This is dandy, but some other resources are missing delete_tags(), too. RouteTable would be one of them. Should I open a separate issue for it?
ping @JordonPhillips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ec2 feature-request This issue requests a feature.
Projects
None yet
Development

No branches or pull requests

5 participants