Bootstrap FreeKB - Amazon Web Services (AWS) - Delete tags to an EC2 instance using the AWS CLI
Amazon Web Services (AWS) - Delete tags to an EC2 instance using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

The aws ec2 describe-instances command can be used to list your EC2 instances.

aws ec2 describe-instances

 

--filter can be used to only return the JSON for an specific instance.

aws ec2 describe-instances --filters "Name=tag:Name,Values=my-instance"

 

Something like this should be returned (this is just a small subset of the output that would be returned). Notice in this example that the EC2 ID is i-09112345cf1abcdd2 and currently has 1 tag (Name = my-instance).

{
    "Reservations": [
        {
            "Instances": [
                {
                    "AmiLaunchIndex": 0,
                    "ImageId": "ami-09d123474b6cabcda",
                    "InstanceId": "i-09112345cf1abcdd2",
                    "InstanceType": "t2.micro",
                    "KeyName": "aws",
                    "LaunchTime": "2022-11-06T09:23:52+00:00",
                    "Tags": [
                        {
                            "Key": "Name",
                            "Value": "my-instance"
                        }
                    ]
                }
            ]
        }
    ]
}

 

The aws ec2 delete-tags command can be used to delete tags from an EC2 instance.

aws ec2 delete-tags --resources i-0d4b6d80b3763f894 --tags Key=Name

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 72e15e in the box below so that we can be sure you are a human.