Managing cloud resources is a continuous challenge for enterprises. Many organizations move to the cloud to reduce operational costs and enhance business agility. Early adopters often allowed their business units to deploy infrastructure quickly to become more agile and better serve their customers. However, this approach has led to a rapid spread of data and application assets across various cloud accounts, lacking consistent standards and governance. Without centralized oversight, costs can spiral, and it becomes difficult to track what is deployed, where, and why.
To address these issues and enforce corporate standards for cloud resources Oracle Cloud Infrastructure offers a best-practice approach using standardized tags for improved governance and control over cloud usage.
Tagging is an essential practice in managing and organizing cloud resources. In Oracle Cloud Infrastructure (OCI), tagging is an integral part of the OCI Identity and Access Management service(IAM) which provides a systematic way to categorize and manage resources effectively, such as cost tracking, cloud resource searching, filtering and logical organization. OCI also offers standard tags that are tag namespace templates defined by Oracle which customers can import into a tenancy’s root compartment and get started with commonly used tags.
In this blog post, we will explore how to use cost tags to correlate the cost associated with a particular HeatWave MySQL DB System.
Understanding Different Tag Types
- Free-form Tags: Free-form tags are user-defined tags with no predefined schema, allowing flexibility in tagging resources. Free-form tags are limited in functionality, Oracle recommends that you only use them to try out the tagging feature or cater for specific use case.
- Defined Tags: Defined tags provide more features and control than free-form tags. These tags have a predefined schema called Tag Namespaces, offering a structured approach to tagging with specific namespaces, keys, and values.
- Cost Tracking Tags: Cost tracking is a feature of defined tags. These tags are used explicitly for cost management and billing purposes
The HeatWave MySQL Database System is designed with flexible, transparent billing, where compute (ECPUs or OCPUs), storage and the HeatWave cluster are each billed separately according to the chosen shape. This structure enables detailed billing, with charges for each component grouped under the same resource ID, allowing for a clear breakdown of costs by component while easily calculating the total database cost.
In billing, the resource ID displayed is the internal mysqlInstance ID, which is unique to the HeatWave service, while the OCI console shows a different OCID for the HeatWave MySQL Database System. This variation presents a challenge when trying to identify the exact costs for a specific HeatWave MySQL Database System. Additionally, when searching for this internal mysqlInstance ID in the Resource Explorer, no results are shown, as this ID is specific to the service and not available for general resource searches.



Solution
We’ll use cost tags to tag a resource, enabling the cost tag to appear on the billing report. This will make it easy to identify the costs associated with a specific HeatWave DB System.
Now, let’s walk through the steps to set it up.
Log in to your OCI Console
Navigate to Tag Namespaces:
- Go to the Navigation Menu
- Select Governance & Administration -> Tag Namespaces
- Select the compartment
- Create a new Tag namespace
Define Tags:
- Within the namespace, create Tag Key Definition.
- Provide Tag Key, Description, and provide Tag Value Type.
- Check Cost-Tracking checkbox
- Select Tag Value Type as “Static Value”

Here, we aim to map the MySQL instance resource ID shown in billing with the HeatWave MySQL Resource OCID, allowing us to easily correlate costs.
To achieve this, once the MySQL DB system is created, copy the OCID of the database. Then, click “Edit” on the DB system, navigate to “Show advanced options,” and select the “Tags” tab. Choose the previously created tag namespace and tag key, paste the copied OCID as the tag value, and click “Save Changes.”


The resource is now tagged with a cost tag that will appear on the billing report, simplifying the process of calculating the total cost incurred for a specific HeatWave DB System. In the billing report, the cost tag HeatWaveDBTag.ResourceOCID=<OCID> is displayed, representing the OCID of the HeatWave MySQL DB System.

Tags can be updated without any downtime after the HeatWave MySQL DB is created either through
- OCI Console
- OCI CLI
- OCI SDK
- OCI APIs
- Terraform
Here is the reference code for performing a bulk update of cost tags for all HeatWave MySQL instances within a tenancy
- Using OCI Python SDK – Github Link
- Using OCI CLI – Github Link
References
