ionos-cloud / ionosctl

The IONOS Cloud CLI (ionosctl) gives the ability to manage IONOS Cloud infrastructure directly from Command Line.
Apache License 2.0
30 stars 6 forks source link

Allow to provide account credentials via environment variables #35

Closed Govinda-Fichtner closed 3 years ago

Govinda-Fichtner commented 3 years ago

Let ionosctl source its credentials for account authentication from environment variables as an alternative to the config file based approach that is already implemented.

This would mean that you would not have to store the credentials, potentially unencrypted in a config file but in a transient environment variables.

This use of environment variables then could be combined with a tool like envdir that can load environment variables on the dynamically on the fly when you enter a project folder.

In combination with a tool like gopass those credentials could even be stored encrypted and then only dynamically loaded, encrypted and store in a transient environment variable by envdir.

The naming of the environment variables should be aligned with environment variables that we might are already use in other IONOS Cloud SDKs or tools like Terraform/Ansible.

We also need to define an order of precedence for different ways/locations that ionosctl is looking for credentials - falling back from one to the next.

firecyberice commented 3 years ago

It seems like this is already working but not yet documented

IONOS_USERNAME=$(gopass ionos/dcd username) \
IONOS_PASSWORD=$(gopass ionos/dcd password) \
ionosctl location list

LocationId   Name        Features
de/fra       frankfurt   [SSD]
us/las       lasvegas    [SSD]
us/ewr       newark      [SSD]
de/txl       berlin      [SSD]
gb/lhr       london      [SSD]