Skip to content

Commit 7c96c1a

Browse files
🐛 Remove debug echo and fixed positional arguments
Updated documentation to better show usage
1 parent f1c1fc3 commit 7c96c1a

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Velez
22

3-
Python framework for interacting with a Terragrunt configurations and performing various cloud operations.
3+
Python framework for interacting with Terragrunt configurations and performing various cloud operations.
44

55
![Velez](velez.jpg)
66

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

3030
## Usage
3131

32+
### Help
33+
34+
Run the CLI with the `--help` argument to see the available commands:
35+
36+
```sh
37+
velez --help
38+
```
39+
3240
To use the Velez CLI, you have two options:
3341

42+
3443
### Interactive Menu
3544

3645
Run the CLI without additional arguments to use the interactive menu:
@@ -39,15 +48,38 @@ Run the CLI without additional arguments to use the interactive menu:
3948
velez
4049
```
4150

51+
4252
### Automation
4353

44-
Run the CLI with additional arguments for automation:
54+
Run the CLI with additional arguments for automation/scripting:
4555

4656
```sh
47-
velez --terragrunt <operation> <module>
57+
velez --terragrunt <operation> <module> <other-arguments>
58+
```
59+
60+
Where:
61+
* `<operation>` is a Terraform/Terragrunt operation to perform, e.g. `plan`.
62+
* `<module>` is a relative path to a Terragrunt module to operate on, e.g. `aws/dev-account`.
63+
* `<other-arguments>` are additional arguments for the operation, e.g. `--target=module.resource`.
64+
65+
For example for the following directory structure:
66+
67+
```plaintext
68+
.
69+
├── aws
70+
│ ├── dev-account
71+
│ │ └── terragrunt.hcl
72+
│ ├── prod-account
73+
│ │ └── terragrunt.hcl
74+
│ └── aws.hcl
75+
└── root.hcl
4876
```
4977

50-
Replace `<operation>` with `plan`, `apply`, or `destroy`, `<module>` with the path to the specific module directory.
78+
Run the following command to plan the `aws/dev-account` module:
79+
80+
```sh
81+
velez --terragrunt plan aws/dev-account
82+
```
5183

5284

5385
## Features

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pick==2.4.0
22
setuptools==75.8.0
3+
boto3==1.36.25

terragrunt_ops.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,7 @@ def action_menu(self, module):
346346
def execute_terragrunt(self, module, arguments):
347347
args = [i for i in arguments if i is not None or i != '']
348348
module = os.path.relpath(module, self.velez.base_dir)
349-
# TODO: echo to debug
350-
command = ['echo', 'terragrunt', '--terragrunt-forward-tf-stdout'] + args + ['--terragrunt-working-dir', f'{module}']
349+
command = ['terragrunt', '--terragrunt-forward-tf-stdout'] + args + ['--terragrunt-working-dir', f'{module}']
351350
print(f"Running command: {command}")
352351
try:
353352
result = subprocess.run(
@@ -361,4 +360,4 @@ def execute_terragrunt(self, module, arguments):
361360
print(result.stderr)
362361
except Exception as e:
363362
print(f"An error occurred: {e}")
364-
input("Press Enter to return to the previous menu...")
363+
input("Press Enter when ready to continue...")

velez.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def main_menu(self):
3131

3232
def run(self, terragrunt=False, **kwargs):
3333
if terragrunt and kwargs.get('pos_args'):
34-
self.terragrunt_ops.execute_terragrunt(module=self.base_dir, arguments=kwargs.get('pos_args'))
34+
pos_args = kwargs.get('pos_args')
35+
option = pos_args[0]
36+
module = pos_args[1]
37+
additional_args = pos_args[2:]
38+
self.terragrunt_ops.execute_terragrunt(module=module, arguments=[option] + additional_args)
3539
elif terragrunt:
3640
self.terragrunt_ops.folder_menu()
3741
else:

0 commit comments

Comments
 (0)