An open API service indexing awesome lists of open source software.

https://github.com/devops-infra/velez

DevOps/CloudOps CLI framework for making work with Terragrunt and performing various cloud operations much easier.
https://github.com/devops-infra/velez

cloud-engineering devops-tools terraform terragrunt

Last synced: 7 months ago
JSON representation

DevOps/CloudOps CLI framework for making work with Terragrunt and performing various cloud operations much easier.

Awesome Lists containing this project

README

          

# Velez

DevOps/CloudOps CLI framework for making work with Terragrunt and performing various cloud operations much easier.

Do you want to automate your daily tasks with Terragrunt, Terraform, GitHub, and other tools? Velez is here to help you!

Do you sometimes forget to add changed files before pushing to GitHub? Velez will do that for you and even format HCL
files before committing!


Gitmoji

## Disclaimer

This project is in the early development stage and is not ready for production use. It is a work in progress and may
contain bugs, incomplete features, incorrect documentation, backward incompatible changes or other issues.
Use it at your own risk.

Since it operates on the infrastructure, user is responsible for the consequences of the actions taken by the tool and
should review the code before using it.

![Velez](img/velez.jpg)

## Features

Supporting following services/tools and operations on them:

- Terragrunt operations `-tg`:
- Walk directory structure containing Terragrunt modules.
- Run Plan, Apply, Destroy and Output on a selected module or a specific target.
- Taint and Untaint a resource.
- Unlock module and show lock information.
- Run Validate and Refresh on a selected module.
- Import a resource to the state.
- Run State operations, like list, move, remove, show, pull and push.
- Run Module operations on source modules:
- Move a module to a new directory, including moving remote state.
- Destroy resources and backend of the module.
- Destroy backend of the module.
- File operations `-f`:
- Formatting all HCL files in the project.
- Cleaning up temporary files in the project or a selected module.
- GitHub operations `-gh`:
- Source operations, like commit, amend, push, pull or rebase.
- Branch operations, like create, change local or remote, delete local or remote.
- Manage pull requests, like create, list in the repository or the whole organization.
- Manage issues, like create, list in the repository or the whole organization.
- Easily remove stale branches.

## Installation

Framework is written in Python and can be installed as a package.

1. Clone the repository:
```sh
git clone https://github.com/devops-infra/velez.git
```
2. Navigate to the project directory:
```sh
cd velez
```
3. Install other dependencies:
* Install Python if not installed yet - required.
* Install Terragrunt, and Terraform or OpenTofu - required for IaaC operations.
* Install `hcledit` - required for updating `.hcl` files.
* Install `direnv` or similar solution - highly suggested for managing environments.

It can be installed, e.g. by running:
```sh
brew install python
brew install terraform
brew install terragrunt
brew install direnv
brew install minamijoyo/hcledit/hcledit
```
4. Install the package:
```sh
pip install .
```

## Usage

### Help

Run the CLI with the `--help` argument to see the available commands:

```sh
velez --help
```

To use the Velez CLI, you have three options:

### Interactive Menu

Run the CLI without additional arguments to use the interactive menu:

```sh
velez
```

### Interactive Menu for specific operation

#### Terragrunt operations (`-tg` or `--terragrunt`)

```sh
velez --terragrunt
```

#### File operations (`-f` or `--file`)

Show menu for file operations:

```sh
velez --file
```

#### GitHub operations (`-gh` or `--github`)

Show menu for GitHub operations:

```sh
velez --github
```

### Automation / CLI

Run the CLI with additional arguments for automation/scripting:

#### Terragrunt operations (`-tg` or `--terragrunt`)

```sh
velez --terragrunt
```

Where:

* `` is a Terraform/Terragrunt operation to perform, e.g. `plan`.
* `` is a relative path to a Terragrunt module to operate on, e.g. `aws/dev-account`.
* `` are additional arguments for the Terraform and Terragrunt operations, e.g.
`--target=module.resource`.

For example for the following directory structure:

```plaintext
.
├── aws
│ ├── dev-account
│ │ └── terragrunt.hcl
│ ├── prod-account
│ │ └── terragrunt.hcl
│ └── aws.hcl
├── .env
└── root.hcl
```

Run the following command to plan the `aws/dev-account` module:

```sh
velez -tg plan aws/dev-account
```

## Configuration

Velez expects following environment variables to be set:

| Variable | Description | Required for operations | Default |
|-----------------------------------|-------------------------------------------------------------------------------|-------------------------|-----------------------|
| `VELEZ_TG_ROOT_HCL` | Relative path to the Terragrunt configuration file. | Terragrunt | `root.hcl` |
| `VELEZ_TG_TEMP_CONFIG` | Absolute path to a temporary file created to render Terragrunt configuration. | Terragrunt | `/tmp/terragrunt.hcl` |
| `GITHUB_TOKEN` | GitHub token for accessing the GitHub API. | GitHub | `N/A` |
| `VELEZ_GH_STALE_BRANCHES_DAYS` | Number of days after which branches are considered stale. | GitHub | `45` |
| `VELEZ_GH_STALE_BRANCHES_COMMITS` | Number of commits after which branches are considered stale. | GitHub | `30` |

For the convenience, these variables can be set in a `.env` file in the project directory and use the `direnv` (
mentioned above) to load them automatically for every project separately.

Veles will read Terragrunt configuration and expand any dynamic config available statically.
For example for each selected Terragrunt module backed configuration will be read to determine exact values of the S3
bucket and DynamoDB table and key used for locking the state.

## License

This project is licensed under the MIT License.

## Velez

Name of the project is a misspelled name of the slavic god of the
underworld - [Veles](https://en.wikipedia.org/wiki/Veles_(god)).