Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Velez

Python framework for interacting with a Terragrunt configurations and performing various cloud operations.
Python framework for interacting with Terragrunt configurations and performing various cloud operations.

![Velez](velez.jpg)

Expand Down Expand Up @@ -29,8 +29,17 @@ Python framework for interacting with a Terragrunt configurations and performing

## Usage

### Help

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

```sh
velez --help
```

To use the Velez CLI, you have two options:


### Interactive Menu

Run the CLI without additional arguments to use the interactive menu:
Expand All @@ -39,15 +48,38 @@ Run the CLI without additional arguments to use the interactive menu:
velez
```


### Automation

Run the CLI with additional arguments for automation:
Run the CLI with additional arguments for automation/scripting:

```sh
velez --terragrunt <operation> <module>
velez --terragrunt <operation> <module> <other-arguments>
```

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

For example for the following directory structure:

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

Replace `<operation>` with `plan`, `apply`, or `destroy`, `<module>` with the path to the specific module directory.
Run the following command to plan the `aws/dev-account` module:

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


## Features
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pick==2.4.0
setuptools==75.8.0
boto3==1.36.25
5 changes: 2 additions & 3 deletions terragrunt_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ def action_menu(self, module):
def execute_terragrunt(self, module, arguments):
args = [i for i in arguments if i is not None or i != '']
module = os.path.relpath(module, self.velez.base_dir)
# TODO: echo to debug
command = ['echo', 'terragrunt', '--terragrunt-forward-tf-stdout'] + args + ['--terragrunt-working-dir', f'{module}']
command = ['terragrunt', '--terragrunt-forward-tf-stdout'] + args + ['--terragrunt-working-dir', f'{module}']
print(f"Running command: {command}")
try:
result = subprocess.run(
Expand All @@ -361,4 +360,4 @@ def execute_terragrunt(self, module, arguments):
print(result.stderr)
except Exception as e:
print(f"An error occurred: {e}")
input("Press Enter to return to the previous menu...")
input("Press Enter when ready to continue...")
6 changes: 5 additions & 1 deletion velez.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def main_menu(self):

def run(self, terragrunt=False, **kwargs):
if terragrunt and kwargs.get('pos_args'):
self.terragrunt_ops.execute_terragrunt(module=self.base_dir, arguments=kwargs.get('pos_args'))
pos_args = kwargs.get('pos_args')
option = pos_args[0]
module = pos_args[1]
additional_args = pos_args[2:]
self.terragrunt_ops.execute_terragrunt(module=module, arguments=[option] + additional_args)
elif terragrunt:
self.terragrunt_ops.folder_menu()
else:
Expand Down