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
HRteam and theFinanceteam both want a tag calledProject, here namespace differenciate them asHR.ProjectandFinance.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, orProd) which prevent typos likePrdorProductionfrom 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
TestorDev
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
-
Navigation
Navigation menu > Governance & Administration > Tag Namespaces -
Click
Create tag namespace -
Select
rootcompartment for best visibility, typeNamespace definition name, and provideDescription. ClickCreate -
Click on the
namespacename -
Click
Create tag key definition -
Provide
Tag keyandDescriptionand enableCost-tracking -
Choose
Tag value type:-
A list of valuesis preffered and enterValues. ClickCreate -
Static valueand enterValues. ClickCreate
-
-
Tagging a resource (eg. block volume)
-
Using a list of valued tag
-
Navigate to the tags section in a specific block volume and click
Add -
Select
Namespace,Key, andValue. ClickAdd tags
-
-
Using static valued tag
-
Select
NamespaceandKeyand enter aValuemanually. ClickAdd tags
-
-