Things have moved on since 2019, and we've continued improving the Aiven command line tool.
There's a new blog post at Get things done with the Aiven CLI which explains how to get started, and how to manage a PostgreSQL® service from start to finish. It also gives examples of using the --json switch and the jq tool to extract data in a more powerful way than with grep and friends.
You can do most of your Aiven service administration straight from your Aiven Console. However, for those times when you need to run a quick shell command on our CLI (command line interface) to check service status, power on or off services, filter through available plans or clouds, upgrade some of your services or watch for patterns in event logs, this guide is for you.
You can also use these commands for scripting and automation, as a basis for constructing your own commands or aliases, or even to dig deeper into the CLI for more possibilities. In this article, we’ll focus more on grepping through the sometimes rather lengthy and / or verbose avn outputs to find specific information more easily — although there are some admin and service deployment commands included.
While intended for use with our CLI, we also hope you’ll find this as a useful guide to get familiar with — or to revisit -- some basic bash scripting.
Feel free to copy / paste, but remember to adjust to the variables you need, for example your --cloud, and/or your --project setting depending on what you’re trying to do. Other variables may include such items as your login name as well as your chosen project and service instance names. Also, while we've specified writing to files or stdout; or clearing screens for aesthetic purposes, feel free to customize the commands you need.
Our list of commands here isn’t exhaustive but is complementary to the one on the Aiven client’s github profile, with some overlapping on the basic stuff. Be sure to check out both!
Finally, we’ll share the lot on github and include a few keyboard-friendly aliases for useful commands that you can use as a basis for some of your own Aiven service deployment and DevOps infrastructure.
Note: we now recommend logging in with an access token (using the --token switch) - see Log in to Aiven with avn in the 2022 article.
Find help with user admin
Loading code...
Get session/auth info on all users in your project
Loading code...
Logout
Loading code...
Viewing clouds, services, regions and plans
List all available services on Aiven
Loading code...
List all available clouds
Loading code...
List all available clouds in the United States
Loading code...
List the last 5 clouds alphabetically in the US
Loading code...
List the first five clouds alphabetically in the US
Loading code...
List the first 20 clouds in the US region
Loading code...
List all clouds available in "California" region.
NOTE: writes a file (ca_clouds)
Loading code...
Exclude all clouds in Finland and California.
NOTE: writes to a file (not_ca_not_fi_clouds)
Loading code...
Count all clouds in a given region
Loading code...
List clouds in successive alphabetical order by 3 specified regions
Loading code...
List all clouds filtered by a specific cloud provider within two regions
Loading code...
Count the total number of available Aiven clouds
Loading code...
List all clouds, sorted alphabetically by provider
Loading code...
List all available plans, given the cloud
Loading code...
List all available hobbyist plans, given the cloud
Loading code...
List all available kafka plans, given the cloud
Loading code...
List all available postgres and kafka plans within a specified cloud, filtered by CPU constraints
Loading code...
Count the number of available plans in a specific cloud
Loading code...
Count all plans on a specific cloud with cost < $10/hr
Loading code...
Make a nicely formatted text file of < $10/hr plans on a specific cloud and display it
Loading code...
List all plans on a specific cloud with cost < $10/hr
Loading code...
List all plans on a specific cloud with cost > $10/hr
Loading code...
Creating, viewing, powering on / off and deleting services
Create an Postgres service on your default cloud with hobbyist plan
Loading code...
Create a Cassandra instance with startup-4 plan
Loading code...
Create a Kafka instance in next higher tier
Loading code...
Roll out multiple service instances on multiple tiers
Loading code...
Upgrade an existing service to a higher tier
Loading code...
Upgrade an existing service to a higher tier AND move it to another cloud region
Loading code...
List all of your available Aiven services
Loading code...
Power on multiple services
Loading code...
List only services currently running
Loading code...
List only services currently switched off
Loading code...
Get only the latest timestamps (CREATE_TIME and UPDATE_TIME) for each currently rebuilding service
This command is useful for troubleshooting a slowly-restarting service.
Loading code...
Get the timestamps for your recently switched off services
Loading code...
Get the latest timestamps for currently running services
Loading code...
Power off your service and list services
Loading code...
Poweroff multiple service instances
Loading code...
Terminate multiple service instances
Loading code...
Viewing and filtering event logs
Show all service events in your project
Loading code...
Find 5 most recent events
Loading code...
Find service maintenance events
Loading code...
Find service_delete events for your logged in project
Loading code...
Count the number of lines in event log
Loading code...
List all events related to powered on / off services
Loading code...
List all events not related to powered up or down services
Loading code...
AVN help and miscellaneous options
Get general AVN CLI help
Loading code...
Loading code...
Get help on a specific function
Loading code...
Loading code...
Loading code...
Loading code...
Loading code...
Loading code...
Loading code...
List all credit cards associated with your project
Loading code...
List all available credits in your project
Loading code...
List all of your current projects
Loading code...
Get project details, including associated credit card, billing address and country code
Loading code...
List all vpcs
Loading code...
Creating aliases for regularly used commands
If you are using a command often, it might be useful to create an alias or a shell function for it. You can add these to .bashrc or to a shell script in your path. Here are some examples:
List clouds in alphabetical order by 3 major regions
Loading code...
View plans on a specific cloud that cost < $10/hr
Loading code...
Turn on a specific service
Loading code...
Turn off a specific service
Loading code...
Get timestamps from all services
Loading code...
Wrapping up
In this piece, we looked at many things you can do with the Aiven command-line interface (CLI) including installation and authentication, viewing clouds, services, regions and plans, working with event logs, getting help, and even creating aliases for frequently-used functions.
We hope that you'll find this not only helpful as a comprehensive primer for Aiven CLI, but also as a general, basic bash reference.
As mentioned before, our CLI is only one of many ways to interact with our globally-available, open source services. Want to try them out? Check out our free 30 day trial. To stay apace with new developments, you can also subscribe to our blog and changelog RSS feeds, or follow us on Twitter or LinkedIn!