Installing TCCLI
Configuring TCCLI
Using TCCLI
tccli configure command.$ tccli configureTencentCloud API secretId [*afcQ]:AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******TencentCloud API secretKey [*ArFd]:Gu5t9xGARNpq86cd98joQYCN3*******region: ap-guangzhououtput[json]:
tccli configure help command.# The `set` subcommand is used to configure one or more items.$ tccli configure set secretId AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******$ tccli configure set region ap-guangzhou output json# The `get` subcommand is used to obtain configuration information.$ tccli configure get secretKeysecretKey = Gu5t9xGARNpq86cd98joQYCN3*******# The `list` subcommand is used to print all configuration information.$ tccli configure listcredential:secretId = AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******secretKey = Gu5t9xGARNpq86cd98joQYCN3*******configure:region = ap-guangzhououtput = json# Specify the values of secretId and secretKey in the command line. For example, you can use the following command to query the CVM instance information:$ tccli cvm DescribeInstances --secretId AKIDz8krbsJ5yKBZQpn74WFkmLPx3****** --secretKey Gu5t9xGARNpq86cd98joQYCN3*******
# Specify the account name `test` in interactive mode.$ tccli configure --profile testTencentCloud API secretId [*BCDP]:AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******TencentCloud API secretKey [*ArFd]:Gu5t9xGARNpq86cd98joQYCN3*******region: ap-guangzhououtput[json]:# Specify the account name `test` for set/get/list subcommands.$ tccli configure set region ap-guangzhou output json --profile test$ tccli configure get secretKey --profile test$ tccli configure list --profile test# Use the `remove` subcommand to delete the configuration file of the specified account. If no account is specified, the default configuration file is deleted.$ tccli configure remove -profile test# Specify an account when calling an API such as the DescribeZones API of CVM.$ tccli cvm DescribeZones --profile test
tccli configure command, the default.configure and default.credential files for TCCLI are generated under the ~/.tccli directory. Content in the two files is in JSON format.
The default.configure file records the version (the latest version by default) of the API to call, the endpoint (the nearest endpoint by default), the default output format, and the specified region. The default.credential file records your key pairs. Example:# Format of the default.configure file: (The following takes CVM as an example. By default, the version of CVM APIs to call is 2017-03-12, and the endpoint for calling CVM APIs is cvm.tencentcloudapi.com.){..."cvm": {"endpoint": "cvm.tencentcloudapi.com","version": "2017-03-12"},..."output": "json","region": "ap-guanzhou",...}# Format of the default.credential file:{"secretId": "AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******","secretKey": "Gu5t9xGARNpq86cd98joQYCN3*******"}
tccli configure --profile test command, the test.configure and test.credential files are generated.set subcommand. For example, you can run the tccli configure set cvm.version 2017-03-12 command to set the version of CVM APIs to call to the default version 2017-03-12.# Set a TencentCloud API key SecretId.$ export TENCENTCLOUD_SECRET_ID=AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******# Set a TencentCloud API key SecretKey.$ export TENCENTCLOUD_SECRET_KEY=Gu5t9xGARNpq86cd98joQYCN3*******# Set the region of a Tencent Cloud product.$ export TENCENTCLOUD_REGION=ap-guangzhou
# Edit the /etc/profile file, and write the following content into the file:export TENCENTCLOUD_SECRET_ID=AKIDz8krbsJ5yKBZQpn74WFkmLPx3*******export TENCENTCLOUD_SECRET_KEY=Gu5t9xGARNpq86cd98joQYCN3*******export TENCENTCLOUD_REGION=ap-guangzhou# Then run the following command for the environment variables to take effect:$ source /etc/profile
# CAM role configuration is not available in interactive mode. Use the non-interactive mode instead:$ tccli configure set role-arn qcs::cam::uin/***********/**** role-session-name ****
role-arn and role-session-name fields support the get and list subcommands of configure. You can write values into the configuration file, or specify values in the command line, in the same way that you configure secretId and secretKey, as shown below:# Use the `get` subcommand to obtain configuration information.$ tccli configure get role-arnrole-arn = qcs::cam::uin/***********/****# Use the `list` subcommand to print all configuration information.$ tccli configure listcredential:role-arn = qcs::cam::uin/***********/****role-session-name = ****# Write the configuration information into environment variables.$ export TENCENTCLOUD_ROLE_ARN=qcs::cam::uin/***********/****$ export TENCENTCLOUD_ROLE_SESSION_NAME=****# Specify the `role-arn` and `role-session-name` fields in the command line. The following example is for calling the DescribeZones API:$ tccli cvm DescribeZones --role-arn qcs::cam::uin/***********/**** --role-session-name ****
secretId and secretKey. You can use --use-cvm-role to call APIs through the role.# Use a role to call the DescribeZones API.$ tccli cvm DescribeZones --use-cvm-role
フィードバック