aliyun / aliyun-cli

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

configuring the cli using env is not possible #314

Closed mo22 closed 3 years ago

mo22 commented 4 years ago

Hi,

aliyun-cli should be able to be configured using ALICLOUD_ACCESS_KEY_ID, ALICLOUD_ACCESS_KEY_SECRET and SECURITY_TOKEN.

However after the default installation the seems to be a predefined default account in ~/.aliyun/config.json with mode set to AK, which prevents the the logic to automatically set the mode to STS if SECURITY_TOKEN is set.

Also, if the active profile has any other data already set, the environment variables do not have any effect.

It would be nice to be able to configure aliyun-cli completely via environment variables

elsnepal commented 4 years ago

I have been in this situation too; where you need to generate those values and pass it through configure.

Also to mention; doesn't fall down the order for the auth method, e.g if the ECS instance holds ram role it should just read it from metadata yet it requires configuration saying which ram role you want to use (given its only possible to set 1 role per instance).

Also, the deletion of any added role will take you to default; which would be empty in the above situation.

night556 commented 3 years ago

CLI reads configuration file parameters first, please try to call after configuration.