These are notes that I've written when I was working on building a Hashicorp Packer Builder plugin in Go.

The issue with the development of this Packer Builder plugin is that some of the Tencent documentation are outdated, and the Chinese/Mandarin documentation are more updated than the English ones.


The following lists the issues encountered when developing the plugin.


Invalid SSL certificate
Encountering the error
x509: certificate is valid for *.ap-singapore.tencentcloudapi.com, not cvm.tencentcloudapi.com
when making a call to https://cvm.tencentcloudapi.com/...


Missing required parameter
Wrong domain name
account.api.qcloud.com vs cvm.tencentcloudapi.com

Connecting to the nearest datacenter

When connecting to the general URL: cvm.tencentcloudapi.com, the CVM API would connect to the nearest data center.
So, for example, if you’re using cvm.tencentcloudapi.com, and you’re located in Singapore, you get redirected to cvm.ap-singapore.tencentcloudapi.com.
And, if you’re located in Silicon Valley, you get redirected to cvm.na-siliconvalley.tencentcloudapi.com.

While this speeds up performance, it gives the issue listed in the Invalid SSL certificate above. The alternative is to connect to a regional-specific data center each time, or alter the plugin to read and connect to a specific domain specified in the configuration. See also the issue: “Information available only in Chinese” below.


No information available
When attempting to create a keypair, the following issues were encountered:

  1.     the SSL certificate issue listed above when making a call to cvm.tencentcloudapi.com
  2.     It requires a ProjectId parameter, and refers to getting it from the Console’s Project section, and alternatively, getting from the DescribeProject API which lists a different domain: account.api.qcloud.com to get it from.

When attempting to bind a keypair to a cloud machine, the following issues were encountered:

  1.     Undocumented TaskId as a return parameter
  2.     The cloud machine cannot be started until the keypair binding completed, otherwise, SSH login to the cloud machine isn’t possible. The alternative is to wait a few minutes, long enough for it to work.


Information available only in Chinese

https://intl.cloud.tencent.com/document/product/409/16763
This says that the service address suffix (or domain) supports redirecting to the nearest geographical domain.


Confusing response

When you provide too much data, the response from Tencent can be misleading.
For example, when you provide two PrivateIpAddresses instead of  one as documented here: https://intl.cloud.tencent.com/document/api/213/9451#virtualprivatecloud, the error message received reads:

"Message": "The value `1` specified in the parameter `InstanceCount` is not valid."


User References:

  1.     Introduction to the Tencent Cloud: https://intl.cloud.tencent.com/document/api/213/11646
  2.     Zones - https://intl.cloud.tencent.com/document/product/213/9452#zone
  3.     Image IDs: https://intl.cloud.tencent.com/document/product/213/1272
  4.     Billing type: See https://intl.cloud.tencent.com/document/api/213/9384 and Pricing modes: https://cloud.tencent.com/document/product/213/2180
  5.     Log into Linux instances: https://intl.cloud.tencent.com/document/product/213/5436?lang=en  
  6.     Instance Types: https://intl.cloud.tencent.com/document/product/213/11518 and https://intl.cloud.tencent.com/document/product/213/7153

Development References:

  1. Packer plugins: https://www.packer.io/docs/extending/plugins.html
  2. Custom Builders: https://www.packer.io/docs/extending/custom-builders.html
  3. Third party Builders
    1. Softlayer: https://github.com/leonidlm/packer-builder-softlayer 
    2. XenServer: https://github.com/xenserver/packer-builder-xenserver
    3. Ali Cloud: https://github.com/archcentric/packer-builder-aliyun
  4. https://stackoverflow.com/questions/37679939/how-do-i-execute-a-command-on-a-remote-machine-in-a-golang-cli
  5. Log into Linux instances: https://intl.cloud.tencent.com/document/product/213/5436
  6. Creating SSH keypair: https://intl.cloud.tencent.com/document/product/213/9400
  7. Parsing JSON in golang:  https://www.sohamkamani.com/blog/2017/10/18/parsing-json-in-golang/    
  8. A getting started guide for Go newcomers: https://github.com/alco/gostart
  9. How are external Packer plugins supposed to configure the communicator?:  https://github.com/hashicorp/packer/issues/4342
  10. Packer plugin for remote builds on VMware vSphere: https://github.com/jetbrains-infra/packer-builder-vsphere
  11. Types - https://github.com/SiCo-Ops/cloud-go-sdk/tree/master/qcloud
  12. HTTP Upload:  https://github.com/xenserver/packer-builder-xenserver/blob/master/builder/xenserver/common/http_upload.go
  13. Help & Documentation: https://intl.cloud.tencent.com/document/api/213/15692