1. Resource Tagging for Cost Tracking of AI Workloads on OCI


    To manage and track costs associated with AI workloads on Oracle Cloud Infrastructure (OCI), you can utilize resource tagging. Tags are key-value pairs that you can attach to OCI resources to organize and manage them based on business needs. OCI supports two types of tags: defined tags and freeform tags. Defined tags are structured and must conform to a predefined schema, whereas freeform tags are flexible and can be any arbitrary key-value pair.

    OCI offers first-class support for tagging, including capabilities like cost-tracking. You can use the oci.Identity.Tag for creating individual tags that can be applied to resources, and the oci.Identity.TagNamespace for creating a namespace to group a collection of tags. Additionally, you can mark tags as cost-tracking, enabling them to be used specifically for cost reporting and analysis.

    Below is a complete Pulumi program written in Python, which sets up tag namespaces and tags suitable for tracking costs of AI workloads on OCI. The tags are created with the isCostTracking property set to True, allowing you to utilize these tags when generating cost reports in OCI.

    import pulumi import pulumi_oci as oci # Initialize the Oracle Cloud Infrastructure provider. # Note that it is assumed that you have already configured your OCI provider settings in # your environment or through Pulumi configuration. # The provider configuration includes API keys, tenancy OCID, user OCID, and region. # Create a Tag Namespace for AI workloads # Tag Namespaces help in logically grouping tags which can be applied to resources. ai_tag_namespace = oci.identity.TagNamespace("aiTagNamespace", description="Tag Namespace for AI Workloads", name="AiWorkloads") # Create a Tag within the Tag Namespace to denote the cost tracking for Compute Instances compute_cost_tracking_tag = oci.identity.Tag("computeCostTrackingTag", tag_namespace_id=ai_tag_namespace.id, name="ComputeCosts", description="Cost tracking tag for Compute Instances", is_cost_tracking=True) # Setting is_cost_tracking to True makes this tag suitable for cost analysis. # Create a Tag within the Tag Namespace for data storage costs storage_cost_tracking_tag = oci.identity.Tag("storageCostTrackingTag", tag_namespace_id=ai_tag_namespace.id, name="StorageCosts", description="Cost tracking tag for Block Storage", is_cost_tracking=True) # Create a Tag within the Tag Namespace for networking costs network_cost_tracking_tag = oci.identity.Tag("networkCostTrackingTag", tag_namespace_id=ai_tag_namespace.id, name="NetworkCosts", description="Cost tracking tag for Networking resources", is_cost_tracking=True) # pulumi.export is used to export output variables that we might want to easily access. # Here, we are exporting the OCIDs for the tag namespace and individual tags # which could be used later on to associate them with resources. pulumi.export("ai_tag_namespace_id", ai_tag_namespace.id) pulumi.export("compute_cost_tracking_tag_id", compute_cost_tracking_tag.id) pulumi.export("storage_cost_tracking_tag_id", storage_cost_tracking_tag.id) pulumi.export("network_cost_tracking_tag_id", network_cost_tracking_tag.id)

    In this program, we've created a tag namespace specifically for AI workloads, AiWorkloads. Within this namespace, we created three different tags for compute, storage, and networking costs, each marked as a cost-tracking tag.

    You can apply these tags to your OCI resources when provisioning them, allowing them to be grouped by these tags in cost reports. This functionality can be particularly useful for identifying and managing expenses across different categories of resources or for isolating the costs attributable to specific projects, departments, or use cases.

    To utilize these tags, you would include them in the provisioning code of your resources, adding a defined_tags or freeform_tags property as appropriate. For detailed guidance on applying these tags to your resources, you can refer to the OCI documentation, specifically how to work with tagging overview and tag namespaces.