When you're managing AWS resources like EC2 instances, keeping things organized is key especially as your environment grows. One of the easiest and most effective ways to stay organized is by using tags. Tags let you add key-value pairs to your resources, making it easier to track, sort, and manage everything.
Today, I’ll show you how to quickly add or update a tag on an EC2 instance using a simple AWS CLI command. It's quick and a habit that will make your cloud life a lot easier down the road.
1. Add or Update a Tag on an EC2 Instance
2. Business Use Case
3. Summary
1. Add or Update a Tag on an EC2 Instance
This command adds or updates a tag on an EC2 instance using AWS CLI.
Command:
aws ec2 create-tags
\
--resources i-0123456789abcdef0
\
--tags Key=Environment,Value=Production
\
--region us-east-1
- Just replace the instance ID and region with your own.
Explanation:
aws ec2 create-tags
- Main AWS CLI command to add or update tags
--resources
- Specifies the EC2 instance (or multiple instances) you want to tag
--tags
- Defines the key and value for the tag
--region
- sets which AWS region you're working in
✅ If the tag already exists, this command updates it to the new value.
✅ If the tag doesn't exist, it creates it.
2. Business Use Case
By tagging EC2 instances with keys like Environment=Production or Owner=DevTeam, companies can easily generate cost reports, enforce automation scripts, or quickly identify critical systems during incidents. Without proper tagging, cloud environments can quickly become chaotic and expensive.
3. Summary
In real-world cloud environments, tagging resources isn’t just a nice-to-have; it's a best practice. Tags help teams track costs, manage environments, enforce security policies, and even automate processes across hundreds or thousands of resources. Tagging may seem like a small detail, but it really adds up once you're managing dozens or hundreds of AWS resources.
Connect with me on LinkedIn to comment or share your experiences with Linux.
#30DaysLinuxChallenge #RedHatEnterpriseLinux
#CloudWhistler #CloudEngineer #Linux
#DevOps #RedHat #OpenSource
#CloudComputing #WomenInTech