LAB 23 ‐ Tags - gautam-amitesh/OCI GitHub Wiki

Oracle Cloud Infrastructure Tagging allows us to add metadata (data about data) to resources like instance, database, storage, and VCN, which enables us to define a namespace, key, and value and associate them with resources. We can use the tags to organize and list resources based on our business needs.

  • Tag Namespace: A logical container for tags which is beneficial for preventing naming collision, creating a security boundary, enforcing standardization

    • Preventing naming collision: In an organization multiple departments might want to use the same tag key for different purpose. Like the HR team and the Finance team both want a tag called Project, here namespace differenciate them as HR.Project and Finance.Project.

    • Creating a security boundary: Tag namespace integrate with OCI IAM so we don't need to write security rules for individual tags.

    • Enforcing Standardization: When we build defined tags inside inside a namespace, we can enforce rules such as restricting a to only accept predefined values (eg. choose from Dev, QA, or Prod) which prevent typos like Prd or Production from breaking your cost-tracking algorithms.

  • Tag Key: It represent the name of the attribute or category needed to assign to a resource, like Environment or Project

  • Tag Value: It represent a specific value associated with the key, such as Test or Dev

Types of Tags

  • Free-form Tags: It is a simple key value pair, useful for Ad-hoc labeling, temporary notes, or personal developer sandboxes.

  • Defined Tags: It is a pre-defined key value pair within a tag namespace, usefull for production environments, cost allocation, security classification, and automation.

Usages

  • Cost Tracking and Billing: filter OCI billing reports to see exactly how much money a specific department, project, or environment (like Production vs. Dev) is spending.
  • Dynamic Access Control (IAM): Instead of writing security rules for specific server IDs, you write Identity and Access Management policies based on tags (e.g., "Allow the QA group to manage resources only if they are tagged Environment=Testing").
  • Resource Management and Automation: group resources across different compartments and regions. You can write scripts targeting these tags to execute bulk actions, such as shutting down all instances tagged Lifecycle=Temporary
  • Security and Compliance: highlighting which workloads require strict monitoring, making it easier to prove compliance during a security audit.

Process to create Tags and use it

  1. Navigation

    Navigation menu > Governance & Administration > Tag Namespaces
    
  2. Click Create tag namespace

  3. Select root compartment for best visibility, type Namespace definition name, and provide Description. Click Create

  4. Click on the namespace name

  5. Click Create tag key definition

  6. Provide Tag key and Description and enable Cost-tracking

  7. Choose Tag value type:

    • A list of values is preffered and enter Values. Click Create

    • Static value and enter Values. Click Create

  8. Tagging a resource (eg. block volume)

    • Using a list of valued tag

      1. Navigate to the tags section in a specific block volume and click Add

      2. Select Namespace, Key, and Value. Click Add tags

    • Using static valued tag

      1. Select Namespace and Key and enter a Value manually. Click Add tags