TExcelTAD
Home › Azure & Google Cloud for AWS Users › Resource Groups, Tags and Labels

Resource Groups, Tags and Labels

Two everyday tools for keeping a cloud tidy: a way to group resources that live and die together, and metadata for cost reports and automation. AWS gives you tags (and optional Resource Groups that are just saved tag queries). Azure makes grouping mandatory; Google Cloud splits metadata into two different features.

On AWS this is… resource tags (Key=env,Value=prod), cost allocation tags in Pricing and Cost Management, and tag-based conditions in IAM Policies.

Azure resource groups

A resource group is a container inside a subscription. Every resource belongs to exactly one.

  • It has a location, but that only says where the group's metadata is stored. Resources in it can be in any region.
  • Deleting the group deletes everything in it. That is the fastest cleanup in any cloud, and the most dangerous command in Azure.
  • It is a scope for RBAC, Azure Policy, locks, budgets and deployments (az deployment group create).
  • Resources can be moved between groups (and subscriptions) for most resource types, but plan groups up front instead.

A common rule of thumb: group by lifecycle. Things created, updated and deleted together share a group: rg-shop-prod-network, rg-shop-prod-app, rg-shop-prod-data. Long-lived shared things (the hub network, the log workspace) go in their own groups so an app teardown can't touch them.

bash
az group create -n rg-shop-dev-app -l westeurope --tags env=dev app=shop owner=team-checkout
az lock create -n no-delete -g rg-shop-prod-data --lock-type CanNotDelete   # protect prod data
az group delete -n rg-shop-dev-app --yes --no-wait                          # removes every resource in it

A resource lock (CanNotDelete or ReadOnly) applies to everyone, even subscription Owners, until someone with permission removes the lock. It is a seatbelt against az group delete on the wrong group.

Google Cloud has no resource group. The project plays that role: delete the project and everything inside it goes (after a 30-day recovery window during which it can be restored). That is one reason GCP teams create many small projects.

Tags and labels

AWS Azure Google Cloud labels Google Cloud tags
What key/value metadata key/value metadata key/value metadata key/value resources defined at org or project level, attached to resources
Used for cost allocation, automation, ABAC conditions cost analysis, automation, Azure Policy conditions billing breakdowns, filtering IAM conditions, Organization Policy conditions, firewall policies
Inherited? no (tag policies and some services propagate) no by default; Azure Policy can copy tags from the resource group no yes, down the hierarchy
Rules case-sensitive names case-insensitive, values case-sensitive lowercase letters, digits, _ and -; up to 64 per resource created and governed centrally; need permission to attach

The Google Cloud split matters: labels are cheap, free-form metadata for billing reports; tags are a governed, permissioned feature meant for policy ("only resources tagged env=prod may have this firewall rule"). Older documents also use "network tags" on VMs, a third, unrelated thing used to target firewall rules.

Model: checking names and labels before you deploy

Each cloud has its own naming rules, and the errors arrive late (at apply time). A small validator catches the common ones early. The rules below are the documented ones for these resource types:

python · try it yourself
import re

RULES = {
    "azure storage account": (r"[a-z0-9]{3,24}", "3-24 lowercase letters and digits, globally unique"),
    "azure resource group":  (r"[-\w.()]{0,89}[-\w()]", "1-90 chars: letters, digits, _ - . ( ), not ending in ."),
    "gcp project id":        (r"[a-z][a-z0-9-]{4,28}[a-z0-9]", "6-30 chars, lowercase, start with a letter, no trailing -"),
    "gcp label key":         (r"[a-z][a-z0-9_-]{0,62}", "start with a lowercase letter, max 63 chars"),
    "gcs bucket":            (r"[a-z0-9][a-z0-9._-]{1,61}[a-z0-9]", "3-63 chars, lowercase, digits, - _ ."),
}

def check(kind, name):
    pattern, why = RULES[kind]
    ok = re.fullmatch(pattern, name) is not None
    print(f"{'ok ' if ok else 'BAD'} {kind:<22} {name!r:<28} {'' if ok else '-> ' + why}")

check("azure storage account", "stshopdev01")
check("azure storage account", "st-shop-dev")
check("azure resource group",  "rg-shop-dev-app")
check("gcp project id",        "shop-api-prod-4821")
check("gcp project id",        "Shop_API")
check("gcp label key",         "cost-center")
check("gcp label key",         "CostCenter")
check("gcs bucket",            "shop-prod-invoices")
ok  azure storage account  'stshopdev01'
BAD azure storage account  'st-shop-dev'                -> 3-24 lowercase letters and digits, globally unique
ok  azure resource group   'rg-shop-dev-app'
ok  gcp project id         'shop-api-prod-4821'
BAD gcp project id         'Shop_API'                   -> 6-30 chars, lowercase, start with a letter, no trailing -
ok  gcp label key          'cost-center'
BAD gcp label key          'CostCenter'                 -> start with a lowercase letter, max 63 chars
ok  gcs bucket             'shop-prod-invoices'

The storage account rule is the one everybody hits: no hyphens, so Azure's own naming guidance uses abbreviations like stshopdev01.

A tagging standard that works on all three

Pick a small, required set and enforce it with policy (next lesson):

Key Example Why
env prod, dev cost split, policy scoping
app shop cost split per product
owner team-checkout who to call
cost-center cc-4410 finance
managed-by terraform don't hand-edit

Use lowercase keys with hyphens: they are valid as AWS tags, Azure tags and Google Cloud labels, so one Terraform locals { tags = … } block can feed all three providers.

Test yourself

What happens when you delete an Azure resource group?

  1. Only the group object is removed
  2. Every resource in it is deleted
  3. Resources move to the default group
  4. Nothing until a lock is removed

Which Google Cloud feature is inherited down the hierarchy and can be used in IAM and Organization Policy conditions?

  1. Labels
  2. Network tags
  3. Tags (Resource Manager tags)
  4. Project names

Why is st-shop-dev rejected as an Azure storage account name?

  1. It is too long
  2. Storage account names allow only lowercase letters and digits
  3. It must start with 'sa'
  4. It must contain the region