Package: aiven-client
Aiven is a next-generation managed cloud services platform.  Its focus is in
ease of adoption, high fault resilience, customer’s peace of mind and
advanced features at competitive price points.  Seehttps://aiven.io/for
more information about the backend service.aiven-client (avn) is the official command-line client for Aiven.ContentsGetting StartedInstall from PyPiBuild an RPM PackageCheck InstallationLog InUsageAuthenticate: Logins and TokensChoose your CloudWorking with ProjectsExplore Existing ServicesLaunch ServicesManaging service usersService IntegrationsWorking with TeamsConfiguring OAuth2 ClientsExtra FeaturesAutocompleteAuth HelpersContributingKeep ReadingGetting StartedRequirements:Python 3.8 or laterRequestsFor Windows and OSX,certifiis also neededInstall from PyPiPypi installation is the recommended route for most users:$ python3 -m pip install aiven-clientBuild an RPM PackageIt is also possible to build an RPM:$ make rpmCheck InstallationTo check that the tool is installed and working, run it without arguments:$ avnIf you see usage output, you’re all set.Note:On Windows you may need to usepython3-maiven.clientinstead ofavn.Log InThe simplest way to use Aiven CLI is to authenticate with the username and
password you use on Aiven:$ avn user login <you@example.com>The command will prompt you for your password.You can also use an access token generated in the Aiven Console:$ avn user login <you@example.com> --tokenYou will be prompted for your access token as above.If you are registered on Aiven through the AWS or GCP marketplace, then you need to specify an additional argument--tenant. Currently the supported value areawsandgcp, for example:$ avn user login <you@example.com> --tenant awsUsageSome handy hints that work with all commands:Theavn helpcommand shows all commands and cansearchfor a command,
so for exampleavn help kafka topicshows commands with kafkaandtopic in their description.Passing-hor--helpgives help output for any command. Examples:avn--helporavn service--help.All commands will output the raw REST API JSON response with--json,
we use this extensively ourselves in conjunction withjq.Authenticate: Logins and TokensLogin:$ avn user login <you@example.com>Logout (revokes current access token, other sessions remain valid):$ avn user logoutExpire all authentication tokens for your user, logs out all web console sessions, etc.
You will need to login again after this:$ avn user tokens-expireManage individual access tokens:$ avn user access-token list
$ avn user access-token create --description <usage_description> [--max-age-seconds <secs>] [--extend-when-used]
$ avn user access-token update <token|token_prefix> --description <new_description>
$ avn user access-token revoke <token|token_prefix>Note that the system has hard limits for the number of tokens you can create. If you’re
permanently done using a token you should always useuseraccess-tokenrevokeoperation
to revoke the token so that it does not count towards the quota.Alternatively, you can add 2 JSON files, first create a default config in~/.config/aiven/aiven-credentials.jsoncontaining the JSON with anauth_token:{
    "auth_token": "ABC1+123...TOKEN==",
    "user_email": "you@example.com"
}Second create a default config in~/.config/aiven/aiven-client.jsoncontaining the json with thedefault_project:{"default_project": "yourproject-abcd"}Choose your CloudList available cloud regions:$ avn cloud listWorking with ProjectsList projects you are a member of:$ avn project listProject commands operate on the currently active project or the project
specified with the--projectNAMEswitch. The active project cab be changed
with theproject switchcommand:$ avn project switch <projectname>Show active project’s details:$ avn project detailsCreate a project and set the default cloud region for it:$ avn project create myproject --cloud aws-us-east-1Delete an empty project:$ avn project delete myprojectList authorized users in a project:$ avn project user-listInvite an existing Aiven user to a project:$ avn project user-invite somebody@example.comRemove a user from the project:$ avn project user-remove somebody@example.comView project management event log:$ avn eventsExplore Existing ServicesList services (of the active project):$ avn service listList services in a specific project:$ avn service list --project proj2List only a specific service:$ avn service list db1Verbose list (includes connection information, etc.):$ avn service list db1 -vFull service information in JSON, as it is returned by the Aiven REST API:$ avn service list db1 --jsonOnly a specific field in the output, custom formatting:$ avn service list db1 --format "The service is at {service_uri}"View service log entries (most recent entries and keep on following logs, other options can be used to get history):$ avn service logs db1 -fLaunch ServicesView available service plans:$ avn service plansLaunch a PostgreSQL service:$ avn service create mydb -t pg --plan hobbyistView service type specific options, including examples on how to set them:$ avn service types -vLaunch a PostgreSQL service of a specific version (see above command):$ avn service create mydb96 -t pg --plan hobbyist -c pg_version=9.6Update a service’s list of allowed client IP addresses. Note that a list of multiple
values is provided as a comma separated list:$ avn service update mydb96 -c ip_filter=10.0.1.0/24,10.0.2.0/24,1.2.3.4/32Open psql client and connect to the PostgreSQL service (also available for InfluxDB):$ avn service cli mydb96Update a service to a different plan AND move it to another cloud region:$ avn service update mydb --plan startup-4 --cloud aws-us-east-1Power off a service:$ avn service update mydb --power-offPower on a service:$ avn service update mydb --power-onTerminate a service (all data will be gone!):$ avn service terminate mydbManaging service usersSome service types support multiple users (e.g. PostgreSQL database users).List, add and delete service users:$ avn service user-list
$ avn service user-create
$ avn service user-deleteFor Redis services running version 6 or above, it’s possible to create users withACLs:$ avn service user-create --username new_user --redis-acl-keys="prefix* another_key" --redis-acl-commands="+set" --redis-acl-categories="-@all +@admin" --redis-acl-channels="prefix* some_chan" my-redis-serviceService users are created with strong random passwords.Service IntegrationsService integrationsallow to link Aiven services to other Aiven services or to services
offered by other companies for example for logging. Some examples for various diffenent integrations:Google cloud logging,AWS Cloudwatch logging,Remote syslog integrationandGetting started with Datadog.List service integration endpoints:$ avn service integration-endpoint-listList all available integration endpoint types for given project:$ avn service integration-endpoint-types-list --project <project>Create a service integration endpoint:$ avn service integration-endpoint-create --project <project> --endpoint-type <endpoint type> --endpoint-name <endpoint name> --user-config-json <user configuration as json>
$ avn service integration-endpoint-create --project <project> --endpoint-type <endpoint type> --endpoint-name <endpoint name> -c <KEY=VALUE type user configuration>Update a service integration endpoint:$ avn service integration-endpoint-update --project <project> --user-config-json <user configuration as json> <endpoint id>
$ avn service integration-endpoint-update --project <project> -c <KEY=VALUE type user configuration> <endpoint id>Delete a service integration endpoint:$ avn service integration-endpoint-delete --project <project>  <endpoint_id>List service integrations:$ avn service integration-list <service name>List all available integration types for given project:$ avn service integration-types-list --project <project>Create a service integration:$ avn service integration-create --project <project> -t <integration type> -s <source service> -d <dest service> -S <source endpoint id> -D <destination endpoint id> --user-config-json <user configuration as json>
$ avn service integration-create --project <project> -t <integration type> -s <source service> -d <dest service> -S <source endpoint id> -D <destination endpoint id> -c <KEY=VALUE type user configuration>Update a service integration:$ avn service integration-update --project <project> --user-config-json <user configuration as json> <integration_id>
$ avn service integration-update --project <project> -c <KEY=VALUE type user configuration> <integration_id>Delete a service integration:$ avn service integration-delete --project <project> <integration_id>Working with TeamsList account teams:$ avn account team list <account_id>Create a team:$ avn account team create --team-name <team_name> <account_id>Delete a team:$ avn account team delete --team-id <team_id> <account_id>Attach team to a project:$ avn account team project-attach --team-id <team_id> --project <project_name> <account_id> --team-type <admin|developer|operator|read_only>Detach team from project:$ avn account team project-detach --team-id <team_id> --project <project_name> <account_id>List projects associated to the team:$ avn account team project-list --team-id <team_id> <account_id>List members of the team:$ avn account team user-list --team-id <team_id> <account_id>Invite a new member to the team:$ avn account team user-invite --team-id <team_id> <account_id> <somebody@example.com>See the list of pending invitations:$ avn account team user-list-pending --team-id <team_id> <account_id>Remove user from the team:$ avn account team user-delete --team-id <team_id> --user-id <user_id> <account_id>Configuring OAuth2 ClientsList configured OAuth2 clients:$ avn account oauth2-client list <account_id>Get a configured OAuth2 client’s configuration:$ avn account oauth2-client list <account_id> --oauth2-client-id <client_id>Create a new OAuth2 client information:$ avn account oauth2-client create <account_id> --name <app_name> -d <app_description> --redirect-uri <redirect_uri>Delete an OAuth2 client:$ avn account oauth2-client delete <account_id> --oauth2-client-id <client_id>List an OAuth2 client’s redirect URIs:$ avn account oauth2-client redirect-list <account_id> --oauth2-client-id <client_id>Create a new OAuth2 client redirect URI:$ avn account oauth2-client redirect-create <account_id> --oauth2-client-id <client_id> --redirect-uri <redirect_uri>Delete an OAuth2 client redirect URI:$ avn account oauth2-client redirect-delete <account_id> --oauth2-client-id <client_id> --redirect-uri-id <redirect_uri_id>List an OAuth2 client’s secrets:$ avn account oauth2-client secret-list <account_id> --oauth2-client-id <client_id>Create a new OAUth2 client secret:$ avn account oauth2-client secret-create <account_id> --oauth2-client-id <client_id>Delete an OAuth2 client’s secret:$ avn account oauth2-client secret-delete <account_id> --oauth2-client-id <client_id> --secret-id <secret_id>Extra FeaturesAutocompleteavn supports shell completions. It requires an optional dependency: argcomplete. Install it:$ python3 -m pip install argcompleteTo use completions in bash, add following line to~/.bashrc:eval "$(register-python-argcomplete avn)"For more information (including completions usage in other shells) seehttps://kislyuk.github.io/argcomplete/.Auth HelpersWhen you spin up a new service, you’ll want to connect to it. The--jsonoption combined with thejqutility is a good way to grab the fields you need for your specific service. Try this to get the connection string:$ avn service get --json <service> | jq ".service_uri"Each project has its own CA cert, and other services (notably Kafka) use mutualTLS so you will also need theservice.keyandservice.certfiles too for those. Download all three files to the local directory:$ avn service user-creds-download --username avnadmin <service>For working withkcat(see also ourhelp article) or the command-line tools that ship with Kafka itself, a keystore and trustore are needed. By specifying which user’s creds to use, and a secret, you can generate these viaavntoo:$ avn service user-kafka-java-creds --username avnadmin -p t0pS3cr3t <service>ContributingCheck theCONTRIBUTINGguide for details on how to contribute to this repository.Keep ReadingWe maintain some other resources that you may also find useful:Command Line Magic with avnManaging Billing Groups via CLI