Leverage CLI is the tool used to manage and interact with any Leverage project.
It transparently handles the most complex and error prone tasks that arise from working with a state-of-the-art infrastructure definition like our Leverage Reference Architecture. Leverage CLI uses a dockerized approach to encapsulate the tools needed to perform such tasks and to free the user from having to deal with the configuration and management of said tools. Provides the means to interact with your Leverage project and allows you to define custom tasks to run.
Reviewing and implementing the Binbash Leverage Landing Zone for AWS would be a very good place to start!
For installation instructions and all documentation regarding Leverage CLI, please refer to this page.
If you come from Leverage CLI version <1.8.0 and want to install Leverage CLI version >= 1.8.0 keep into account the following.
The build.env
file format has changed. As an example, this is the old format:
# Project settings
PROJECT=bb
# General
MFA_ENABLED=false
# Terraform
TERRAFORM_IMAGE_NAME=binbash/terraform-awscli-slim
TERRAFORM_IMAGE_TAG=1.1.9
New version example:
# Project settings
PROJECT=bb
# General
MFA_ENABLED=false
# Terraform
TERRAFORM_IMAGE_TAG=1.5.0-0.2.0
So, if you have created a project with version <1.8.0 and want to use it with version >=1.8.0 you should:
For the second item you can check the version here.
Leverage CLI explicitly supports the following Python versions:
These versions are not only supported but are also the only versions used in our CI/CD pipelines to ensure compatibility and performance. This rigorous testing helps prevent compatibility issues and ensures that the Leverage CLI performs as expected under these versions.
Please ensure that your development and deployment environments are set up with one of these supported versions. Our GitHub Actions and other CI workflows are specifically configured to test against these Python versions, which reinforces our commitment to maintaining a reliable and stable toolset.
If you need to install one of the supported Python versions and would like to manage multiple
Python environments, pyenv
is a highly recommended tool. Here’s how you can use pyenv
to install and manage Python
versions:
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
exec "$SHELL"
Once pyenv is installed, you can install any supported Python version by following these steps:
pyenv install 3.9.7
pyenv install 3.10.1
pyenv install 3.11.8
pyenv install 3.12.7
Create a virtual environment for your project using Python 3.9.7:
pyenv virtualenv 3.9.7 leverage_py_39_venv
To set this virtual environment as the local environment for your project, navigate to your project directory and run:
cd <path_to_leverage_project_root>
pyenv local leverage_py_39_venv
This setup commands pyenv
to use leverage_py_39_venv
as the local Python version for your project directory,
ensuring that all Python operations within this directory use this isolated environment.
Before you begin, ensure you are running one of the supported Python versions.
We now use Poetry for dependency management. Setup your development environment as follows:
curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.2 python -
git clone https://github.com/binbashar/leverage.git
cd leverage
poetry install --with=dev --with=main
poetry shell
In order to run black automatically on every commit, you should install pre-commit
first:
https://pre-commit.com/#installation
And then the hooks:
poetry run pre-commit install
To run unit tests, pytest is the tool of choice, and the required dependencies are available in the
corresponding dev-requirements.txt
.
Integration tests are implemented using bats. Bear in mind that bats tests are meant to be run in a throwaway environment since they perform filesystem manipulations and installation and removal of packages, and the cleanup may not be completely thorough. As such, is highly recommended to run these tests using the docker image.
poetry run pytest
Install dependencies (MacOS):
brew install bats-core
brew tap bats-core/bats-core
brew install bats-support
brew install bats-assert
bats -r tests/bats
A Docker image suitable for running all tests can be crafted by running make build-image
. After crafting the image all
tests can be executed.
To run all tests, run make tests
. Alternatively make test-unit
or make test-int
for unit or integration tests
respectively.
Leverage CLI is licensed under MIT licenseBinBash Inc