Fixing the ‘DeleteTag Not Found’ Error Easily

Written by

in

In AWS, there is no single global DeleteTag function; instead, removing tags from your cloud infrastructure depends entirely on the specific AWS service API or the generalized Resource Groups Tagging API you are using. For core compute resources like Amazon EC2, the exact action is named DeleteTags, while many modern services utilize an UntagResource API action. Service-Specific API Functions

The method you call depends on your development tool (like the AWS CLI or an AWS SDK):

Amazon EC2 (DeleteTags): Used to delete metadata tags from instances, security groups, or EBS volumes.

AWS Lambda (UntagResource): Used to strip administrative or cost-tracking markers from your serverless functions.

Amazon S3 (DeleteObjectTagging): Specifically targeting object-level data tracking instead of the bucket configuration itself. How to Use DeleteTags (Amazon EC2 Example)

When managing virtual infrastructure, you drop specific tags by referencing the unique resource identification string. 1. Via the AWS CLI

To remove a single tracking tag regardless of its value, provide the resource ID and the matching key:

aws ec2 delete-tags –resources i-1234567890abcdef0 –tags Key=Environment Use code with caution.

If you only want to remove the tag when it matches a very specific value (safeguarding against accidental deletion of a production tag), include the target value:

aws ec2 delete-tags –resources i-1234567890abcdef0 –tags Key=Environment,Value=Staging Use code with caution. 2. Via the Python SDK (Boto3)

When writing infrastructure management scripts in Python, initialize your client and call the delete_tags method:

import boto3 ec2 = boto3.client(‘ec2’) response = ec2.delete_tags( Resources=[‘i-1234567890abcdef0’], Tags=[ { ‘Key’: ‘Environment’ } ] ) Use code with caution. How to Use UntagResource (Generalized API)

For modern services like AWS Lambda, Organizations, or IAM, you call UntagResource and pass the Resource Name (ARN) along with an array of keys. 1. Via the AWS CLI

aws lambda untag-resource –resource arn:aws:lambda:us-east-1:123456789012:function:my-function –tag-keys Environment Team Use code with caution. Critical Rules & Edge Cases Adding, updating, and removing tags – AWS Organizations

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *