Consistently Tagging CVM, Cloud Disk, Public IP, and Elastic NIC in Tencent Cloud
The guide shows how to create a Tencent Cloud CVM and, using the RunInstances API for the instance and cloud disk, then the DescribeAddresses and TagResources (or AttachResourcesTag) APIs for the associated public IP and elastic NIC, apply an identical tag to all four resources for unified management and cost tracking.
This article from the Tencent Cloud Developer Community explains how to assign the same tag to a CVM instance, its attached cloud disk, the public IP (non‑EIP) and the elastic network interface (ENI) when creating the CVM.
Requirement: Create a CVM and bind identical tags to the CVM, its cloud disk, public IP, and elastic NIC.
Step 1 – Tag CVM and Cloud Disk: Use the RunInstances API and specify the TagSpecification field for the resource types instance (CVM) and cloudDisk . The API Explorer URL is https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=RunInstances.
Limitation: The RunInstances API does not support tagging the public IP and ENI directly; it only accepts the instance prefix for tags, so attempts to use eip or eni result in errors.
Step 2 – Retrieve IDs of Public IP and ENI: Call the DescribeAddresses API with a Filters block that includes instance-id and address-type . This returns the IDs of the public IP and the associated ENI. API Explorer URL: http://console.cloud.tencent.com/api/explorer?Product=vpc&Version=2017-03-12&Action=DescribeAddresses.
Step 3 – Tag Public IP and ENI: Use the TagResources (or AttachResourcesTag ) API to bind the same tag to the retrieved public IP and ENI IDs. API Explorer URL: http://console.cloud.tencent.com/api/explorer?Product=tag&Version=2018-08-13&Action=AttachResourcesTag. Detailed usage is documented at http://cloud.tencent.com/document/product/651/46294.
The article includes screenshots of the API Explorer calls, the DryRun results, and the final tagging verification.
By following these steps, developers can ensure that all resources created together share a consistent tag, which simplifies resource management and cost allocation in Tencent Cloud.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.