latest
Subcommands
Powered By GitBook
IonosCTL CLI
IonosCTL command line interface (CLI) utility is currently under development. We are working on adding new commands and use-cases in order to support all the operations available in the Cloud API.

Overview

IonosCTL is a tool to help you manage your IONOS Cloud resources directly from your terminal.

Getting started

An IONOS account is required for access to the Cloud API; credentials from your registration are used to authenticate against the IONOS Cloud API.

Installing ionosctl

Downloading a Release from GitHub

Check the Release Page and find the corresponding archive for your operating system and architecture. You can download the archive from your browser or you can follow the next steps if you are using a linux operating system:
1
# Check if /usr/local/bin is part of your PATH
2
echo $PATH
3
4
# Download and extract the binary (<version> is the full semantic version):
5
curl -sL https://github.com/ionos-cloud/ionosctl/releases/download/v<version>/ionosctl-<version>-linux-amd64.tar.gz | tar -xzv
6
7
# Move the binary somewhere in your $PATH:
8
sudo mv ~/ionosctl /usr/local/bin
9
10
# Use the ionosctl CLI
11
ionosctl help
Copied!
For Windows users, you can download the latest release available on Release Page, unzip it and follow this [official guide](https://msdn.microsoft.com/en-us/library/office/ee537574(v=office.14).aspx) that explains how to add tools to your PATH. The path that you need to add is the path to the folder where you unzipped the ionosctl release.

Building a local version(on a Linux machine)

If you have a Go environment (Go 1.14, Go 1.15, Go 1.16) configured, you can build and install the development version of ionosctl with:
1
git clone https://github.com/ionos-cloud/ionosctl.git
Copied!
After cloning the repository, you can build ionosctl locally with:
1
make build
Copied!
To install ionosctl locally, you can use:
1
make install
Copied!
Note that the development version is a work-in-progress of a future stable release and can include bugs. Officially released versions will generally be more stable. Check the latest releases in the Release Page.
Dependencies: ionosctl uses Go Modules with vendoring.
On Windows, you just need to run the command
1
go install
Copied!
from the folder where you cloned the ionosctl git.

Authenticating with Ionos Cloud

Before using ionosctl to perform any operations, you will need to set your credentials for IONOS Cloud account. The authenticating mechanism is first checking the environment variables and if these are not set, it is checking if a configuration file exists and if the user has the right permissions for it.
You can provide your credentials:
    Using environment variables
You can set the environment variables for HTTP basic authentication:
1
export IONOS_USERNAME="username"
2
export IONOS_PASSWORD="password"
Copied!
Or you can use token authentication:
1
export IONOS_TOKEN="token"
Copied!
Also, you can overwrite the api endpoint: api.ionos.com via the --api-url global flag or via the following environment variable:
1
export IONOS_API_URL="api-url"
Copied!
    Using login command
1
ionosctl login --user username --password password -v
Copied!
The command can also be used without setting the --user and --password flags:
1
ionosctl login
2
Enter your username:
3
username
4
Enter your password:
Copied!
You can also authenticate via --token flag exclusively:
1
ionosctl login --token IONOS_TOKEN
Copied!
After providing credentials, you will be notified if you logged in successfully or not:
1
Status: Authentication successful!
Copied!
1
Error: 401 Unauthorized
Copied!
Setting --api-url will overwrite the default value of https://api.ionos.com for subsequent requests.
After a successful authentication with the login command, you will no longer need to provide credentials unless you want to change them. By default, they will be stored in
    macOS: ${HOME}/Library/Application Support/ionosctl/config.json
    Linux: ${XDG_CONFIG_HOME}/ionosctl/config.json
    Windows: %APPDATA%\ionosctl\config.json
    and retrieved every time you will perform an action on your account.

Enabling Shell Auto-Completion

ionosctl provides completions for various shells, for both commands and flags. If you partially type a command or a flag and then press TAB, the rest of the command will be automatically filled in.
To enable auto-completion, you need to use ionosctl completion [shell], depending on the shell you are using.
ionosctl uses the latest release of Cobra framework, which supports by default completion with descriptions for commands and flags. To disable it, --no-descriptions flag is available.

Enabling Bash Shell Auto-Completion

To load completions for the current session, execute:
1
source <(ionosctl completion bash)
Copied!
To make these changes permanent, append the above line to your .bashrc file and use:
1
source ~/.bashrc
Copied!
By default, TAB key in Bash is bound to complete readline command. If you want to use menu-complete append the following line to .bashrc file:
1
bind 'TAB':menu-complete
Copied!
You will need to start a new shell for this setup to take effect.

Enabling Fish Shell Auto-Completion

To load completions into the current shell execute:
1
ionosctl completion fish | source
Copied!
In order to make the completions permanent execute once:
1
ionosctl completion fish > ~/.config/fish/completions/ionosctl.fish
Copied!

Enabling Zsh Shell Auto-Completion

If shell completions are not already enabled for your environment, you need to enable them. Add the following line to your ~/.zshrc file:
1
autoload -Uz compinit; compinit
Copied!
To load completions for each session execute the following commands:
1
mkdir -p ~/.config/ionosctl/completion/zsh
2
ionosctl completion zsh > ~/.config/ionosctl/completion/zsh/_ionosctl
Copied!
Finally add the following line to your ~/.zshrcfile, before you call the compinit function:
1
fpath+=(~/.config/ionosctl/completion/zsh)
Copied!
In the end your ~/.zshrc file should contain the following two lines in the order given here:
1
fpath+=(~/.config/ionosctl/completion/zsh)
2
# ... anything else that needs to be done before compinit
3
autoload -Uz compinit; compinit
4
# ...
Copied!
You will need to start a new shell for this setup to take effect. Note: ZSH completions require zsh 5.2 or newer.

Enabling PowerShell Auto-Completion

PowerShell supports three different completion modes:
    TabCompleteNext (default Windows style - on each key press the next option is displayed)
    Complete (works like Bash)
    MenuComplete (works like Zsh)
You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
Descriptions will only be supported for Complete and MenuComplete.
Follow the next steps to enable it:
To load completions for the current session, execute:
1
PS> ionosctl completion powershell | Out-String | Invoke-Expression
Copied!
To load completions for every new session, run:
1
PS> ionosctl completion powershell > ionosctl.ps1
Copied!
and source this file from your PowerShell profile or you can append the above line to your PowerShell profile file.
Regarding the PowerShell profile, you can follow the next steps:
    You need to find the PowerShell Profile path using the command $PROFILE and verify it is created with Test-Path $PROFILE.
    If the result of the previous command is false, the profile doesn’t exist you need to create one, so you can use the command New-Item -Type File -Force $PROFILE.
    Now, you created the profile and you can oopen file with a text editor and add the following line: . $PATH\ionosctl.ps1, where $PATH is absolute path to ionosctl.ps1 (for example . D:\ionoscloud\ionosctl.ps1)
In case you want more details, the profile creating steps are detailed in this link: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.1
    If you get the following error:"path\Microsoft.PowerShell_profile.ps1" cannot be loaded because running scripts is disabled on this system, you can run the command Set-ExecutionPolicy RemoteSigned and restart the terminal.
    After you finish your work with ionosctl, you can run Set-ExecutionPolicy Restricted to disable running scripts.
You will need to start a new PowerShell for this setup to take effect.
Note: PowerShell completions require version 5.0 or above, which comes with Windows 10 and can be downloaded separately for Windows 7 or 8.1.

Output formatting

    Use the --output option
You can control the output format with the --output or -o option. IonosCTL supports JSON format for all commands output by specifying --output=json. By default, the output is set to human-readable format.
    Use the --quiet option
To redirect all the output to dev/null, except for error messages, you can use --quiet or -q option.
    Use the --force option
For deletion/removal commands, you will need to provide a confirmation to perform the action. To force the command to execute without a confirmation, you can use --force or -f option.
    Use the --cols option
To obtain only a specific field/column, or a collection of columns on output, you can use the --cols option with the list of desired fields.
For example, if you want to print only the Datacenter ID and the Location for your existing Virtual Data Centers, you can use the following command:
1
ionosctl datacenter list --cols "DatacenterId,Location"
2
DatacenterId Location
3
DATACENTER_ID1 us/ewr
4
DATACENTER_ID2 us/las
5
DATACENTER_ID3 us/las
Copied!
Note: When using TAB in autocompletion, on --cols option on a specific resource, the available columns for that resource will be displayed.
    Use the --verbose option
You will see step-by-step process when running a command.
This flag can be used with any command(in general create, read, update, delete, but it's available also for the other specific command) of any resource.

Help Information

You can see all available options for each command, use:
1
ionosctl help [command]
2
3
ionosctl help [command] [command]
4
5
ionosctl [command] --help
6
7
ionosctl [command] -h
Copied!

Testing

1
make test
Copied!

Examples

For each runnable command, use ionosctl [command] --help, ionosctl [command] -h or ionosctl help [command] or see the full reference documentation to see examples.

Uninstalling ionosctl

Local version

To uninstall a local version built with the steps from Installing Ionosctl, use:
1
make clean
Copied!

Feature Reference

The IONOS Cloud CLI aims to offer access to all resources in the IONOS Cloud API and also offers some additional features that make the integration easier:
    authentication for API calls
    handling of asynchronous requests

FAQ

    How can I open a bug/feature request?
Bugs & feature requests can be open on the repository issues: https://github.com/ionos-cloud/ionosctl/issues/new/choose
    Can I contribute to the IONOS Cloud CLI?
Sure! Our repository is public, feel free to fork it and file a PR for one of the issues opened in the issues list. We will review it and work together to get it released.
Last modified 18h ago