Boto3: Add instance delete_tags() method

Created on 27 Nov 2015  路  10Comments  路  Source: boto/boto3

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?

ec2 feature-request

Most helpful comment

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()

All 10 comments

Thanks for reporting, we'll look into adding it

Thanks, looking forward to it.

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

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

@mlapida You just omit Value

Could you guys give a quick code example?

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

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()

Awesome. You guys are :interrobang::heavy_division_sign::curly_loop::zap: good.

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

Was this page helpful?
0 / 5 - 0 ratings