aliyun / aliyun-cli

Alibaba Cloud CLI
Apache License 2.0
830 stars 198 forks source link

Unable to specify tag command line parameter #626

Open iggyzap opened 1 year ago

iggyzap commented 1 year ago

I am trying to invoke cli towards endpoint to list all the resources that have specific tag attached, unfortunately I am seeing error message from API.

Could someone help on how to pass tag array to cli ?

TsinghuaDream commented 1 year ago

aliyun resourcemanager ListTagResources --region cn-shanghai --Tag.1.Key 123 --Tag.1.Value 123 --ResourceId.1 123 --version 2020-03-31 --force There is a CLI command generated in the upper right corner. https://next.api.aliyun.com/api/ResourceManager/2020-03-31/ListTagResources?params={%22Tag%22:[{%22Key%22:%22123%22,%22Value%22:%22123%22}],%22ResourceId%22:[%22123%22]}

iggyzap commented 1 year ago

Thanks, that worked although I did not get data I would have expected. Also, there is another problem, without --force flag CLI fails parameter validation:

% aliyun resourcemanager ListTagResources --Tag.1.Key purpose --Tag.1.Value migration --endpoint resourcemanager.cn-shenzhen.aliyuncs.com
ERROR: '--Tag.1.Key' is not a valid parameter or flag. See `aliyun help resourcemanager ListTagResources`.

And if I do not specify --endpoint then it fails to recognise region:

% aliyun resourcemanager ListTagResources   --force --secure --region cn-shenzhen 
ERROR: unknown endpoint for resourcemanager/cn-shenzhen! failed unknown endpoint for region cn-shenzhen
  you need to add --endpoint xxx.aliyuncs.com
  LC_Error: [SDK.CanNotResolveEndpoint] Can not resolve endpoint(param = {"Domain":"","Product":"ResourceManager","RegionId":"cn-shenzhen","LocationProduct":"resourcemanager","LocationEndpointType":"openAPI"}), please check your accessKey with secret, and read the user guide

caused by:
SDK.ServerError
ErrorCode: InvalidRegionId
Recommend: https://next.api.aliyun.com/troubleshoot?q=InvalidRegionId&product=Location
RequestId: FE9C4719-965C-32E2-A7A4-291EF5E43F3F
Message: The specified region does not exist.
RespHeaders: map[Access-Control-Allow-Origin:[*] Connection:[keep-alive] Content-Length:[258] Content-Type:[application/json;charset=utf-8] Date:[Wed, 01 Mar 2023 09:04:48 GMT] X-Acs-Request-Id:[FE9C4719-965C-32E2-A7A4-291EF5E43F3F] X-Acs-Trace-Id:[20df621eb083c3cc8460f0d317cf9ca8]]

I've installed CLI via brew.

TsinghuaDream commented 1 year ago

Download the latest version directly in Git and decompress it. --force is necessary. Resource management is centralized deployment, so try it cn-hangzhou or just need add --endpoint xxx.aliyuncs.com.