Tags are an incredibly useful yet often overlooked feature of most cloud computing platforms. Once created they let you manage your infrastructure more effectively by providing the ability to filter resources and perform tasks and actions based on nominated tag values.
Tags are essentially pairs of user defined metadata made up of a name and a value that are added to resources when they are created.
Tag Name | Tag Value |
environment | development |
team | security |
department | devops |
status | production |
In AWS and Azure these are referred to as "Tags" whereas GCP refers to these as "Labels" apart from some network components where they are referenced as "Network Tags".
Platform | Max Tag Length | Max Value Length | Allowed Chars | Case Sensitive |
AWS | 128 | 256 | a-z, 0-9, + - =._:/@ | Yes |
GCP | 63 | 63 | a-z, 0-9, _, - | Yes |
Azure | 512 | 256 | a-z, 0-9, _, - | No |
Tag names can be pretty much anything although the "aws:" tag is reserved within the AWS ecosystem.
Some platforms only allow lower case characters in tag names, so should you be planning or leveraging hybrid cloud architecture, then keeping to a naming convention that works across platforms is advisable.
Tag Usage:
Azure Tags
AWS Tags
AWS tags can easily be added by navigating to the desired resource in your AWS console. Each resource has a "Tags" tab where you add/edit/remove tags.
AWS tags can also be added and modified using the AWS CLI
aws ec2 run-instances \
--image-id ami-abc12345 \
--count 1 \
--instance-type t2.micro \
--key-name MyKeyPair \
--subnet-id subnet-6e7f123e \
--tag-specifications 'ResourceType=instance,Tags=[{Key=webserver,Value=production}]' 'ResourceType=volume,Tags=[{Key=cost-center,Value=cc123}]'
GCP Labels
Labels can also be added using the gcloud command line tool. ie:
gcloud compute disks update example-disk --add-labels backend=webserver, media=images
or via API ie:
POST https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/instances/example-instance/setLabels
{
"labels": {
"environment": "test",
"an-existing-tag": ""
},
"labelFingerprint": "42WmSpB8rSM="
}
Using Tags to create custom Hava diagrams
Once you have well tagged resources you can leverage your tags to create custom diagrams within Hava.
This allows you to achieve things like:
- Segment and document cloud infrastructure by individual tag
- Produce diagrams containing resources just in production
- Produce diagrams for infrastructure in a shared development environment
- Produce diagrams for specific client resources in a managed services environment
- Produce hybrid diagrams from different cloud providers using commonly named tags
- Produce diagrams containing resources of interest to particular roles ie: managing_role: dbAdmin
The options are almost limitless.
Hava provides a query function that will build on-the-fly diagrams based on specified parameters like region:, name:, vpc:, subnet:, virtual_network:, project: and so on.
This allows you to build custom diagrams that just include the resources that meet your query. For instance you could enter region:us-east-1 and region:us-east1 to build a diagram that could contain AWS and GCP resources detected in connected cloud accounts.
On top of these pre-defined options is the ability to specify your own custom tag names and the value you wish to match.
Say for instance you have tagged all your resources with a "status" tag of dev, staging or production and also tagged a "security_level" of high, medium or low.
You could produce a diagram for your security team with just "production" resources with a security status of "high" with the following query:
Both the "status" and "security_level" tags are user generated within your AWS, GCP or Azure accounts.
Any query term that is entered into the custom query diagram builder that is not a reserved term in the drop down menu will be treated as a user generated tag/label and the query search will inspect all your resources looking for a match.
Deep Search using Tags
When you create a custom diagram using the style of query above, then only the resources with the nominated tags will be visualised.
Sometimes you need to know what is connected to your tagged resources. To do this, adding the deep search @ prefix will force the diagram to visualise anything connected to your tagged resources.
Excluding Tags
Just as you can specify tags to search and diagram, you can also exclude tags by adding a "-" prefix. -status:production would return everything that is not tagged "production"
This is a useful method when retro tagging your infrastructure to find any un-tagged resources.
If you are currently using Hava to automate your cloud infrastructure then please check out the custom diagram builder utilising tags. If you are not using Hava yet, you can try it out for free for 14 days using the button below.
You can auto generate diagrams, build custom diagrams for Azure, Google Cloud and AWS and compare architecture versions easily - Learn more here