图片

Introduction | This article is selected from the column of Tencent Cloud Developer Community - [Technical Thinking Guangyi·Tencent Technician Original Collection]. This column is a sharing and communication window created by the Tencent Cloud developer community for Tencent technicians and a wide range of developers. The column invites Tencent technicians to share original technical accumulation, and to inspire and grow with a wide range of developers. The author of this article is Yang Shuo, a technician at Tencent. \
This article mainly manually decomposes the steps to label multiple types of resources. I hope this article can provide some experience and help for developers who are interested in this area.
Requirement: When creating CVM, CVM and its corresponding cloud disk, public network IP (non-eip), and elastic network card are bound to the same tag.

Implementation steps:

图片

When calling RunInstances interface to create cvm, tag cvm and cloud disk in the TagSpecification section

https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=RunInstances

图片

图片

I created my own account earlier, and I cannot directly tag the public IP and elastic network card when testing the RunInstances interface on my account.

https://cloud.tencent.com/document/product/213/10314

http://cloud.tencent.com/document/product/215/20171

图片

The official website document mentions that the prefix of the elastic network card is eni, the prefix of the public network IP is eip, and the prefix of cvm is instance. The document binding the label in the RunInstances interface clearly indicates that the cvm fills in the instance, but it doesn't say anything else. I tried pressing elastic. The prefix eni of the network card and the prefix eip of the public IP will report an error.

图片

The following pictures are when I use the RunInstances test to turn on DryRun to true:

图片

图片

图片

图片

图片

Call the DescribeAddresses interface and specify the instance-id and address-type in the Filters module to find the ID of the public IP and the ID of the ENIC

图片

http://console.cloud.tencent.com/api/explorer?Product=vpc&Version=2017-03-12&Action=DescribeAddresses

图片

图片

The DescribeAddresses interface specifies the public IP type and cvm instanceid to find the relevant ID, and calls the TagResources interface to bind the tag to the public IP and ENIC.

http://console.cloud.tencent.com/api/explorer?Product=tag&Version=2018-08-13&Action=AttachResourcesTag

http://cloud.tencent.com/document/product/651/46294

图片

图片

image.png

If you are a creator of Tencent technical content, the Tencent Cloud developer community sincerely invites you to join the [Tencent Cloud Original Sharing Program] to receive gifts and help with your rank promotion.


腾讯云开发者
21.9k 声望17.3k 粉丝