tgwrap 0.8.8__tar.gz → 0.8.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tgwrap-0.8.8 → tgwrap-0.8.10}/PKG-INFO +2 -1
- {tgwrap-0.8.8 → tgwrap-0.8.10}/pyproject.toml +1 -1
- {tgwrap-0.8.8 → tgwrap-0.8.10}/tgwrap/deploy.py +1 -1
- {tgwrap-0.8.8 → tgwrap-0.8.10}/tgwrap/main.py +1 -3
- tgwrap-0.8.8/setup.py +0 -42
- {tgwrap-0.8.8 → tgwrap-0.8.10}/LICENSE +0 -0
- {tgwrap-0.8.8 → tgwrap-0.8.10}/README.md +0 -0
- {tgwrap-0.8.8 → tgwrap-0.8.10}/tgwrap/__init__.py +0 -0
- {tgwrap-0.8.8 → tgwrap-0.8.10}/tgwrap/analyze.py +0 -0
- {tgwrap-0.8.8 → tgwrap-0.8.10}/tgwrap/cli.py +0 -0
- {tgwrap-0.8.8 → tgwrap-0.8.10}/tgwrap/printer.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tgwrap
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.10
|
4
4
|
Summary: A (terragrunt) wrapper around a (terraform) wrapper around ....
|
5
5
|
Home-page: https://gitlab.com/lunadata/tgwrap
|
6
6
|
License: MIT
|
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.8
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
18
|
Requires-Dist: click (>=8.0)
|
18
19
|
Requires-Dist: inquirer (>=3.1.4,<4.0.0)
|
19
20
|
Requires-Dist: networkx (>=2.8.8,<3.0.0)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "tgwrap"
|
3
|
-
version = "0.8.
|
3
|
+
version = "0.8.10"
|
4
4
|
description = "A (terragrunt) wrapper around a (terraform) wrapper around ...."
|
5
5
|
authors = ["Gerco Grandia <gerco.grandia@4synergy.nl>", "Pascal Alma <pascal.alma@4synergy.nl>"]
|
6
6
|
license = "MIT"
|
@@ -60,7 +60,7 @@ def run_sync(
|
|
60
60
|
f"--include='{terragrunt_file}' {lock_file_stmt} {env_file_stmt} {excludes_stmt} " + \
|
61
61
|
"--exclude='.terragrunt-cache/' --exclude='.terraform/' " + \
|
62
62
|
"--exclude='terragrunt-debug.tfvars.json' --exclude=planfile " + \
|
63
|
-
"--exclude='.DS_Store' "
|
63
|
+
"--exclude='.DS_Store' --exclude='*.log' "
|
64
64
|
|
65
65
|
cmd = f"rsync -aim {dry_run_stmt} {clean_stmt} " + \
|
66
66
|
include_statements + \
|
@@ -102,7 +102,7 @@ class TgWrap():
|
|
102
102
|
'info': '{base_command} terragrunt-info --terragrunt-non-interactive {update} {upgrade} {common}',
|
103
103
|
'plan': '{base_command} {command} --terragrunt-non-interactive -out={planfile_name} {lock_level} {update} {parallelism} {common}',
|
104
104
|
'apply': '{base_command} {command} {non_interactive} {no_auto_approve} {update} {parallelism} {common} {planfile}',
|
105
|
-
'show': '{base_command} {command} --terragrunt-non-interactive {
|
105
|
+
'show': '{base_command} {command} --terragrunt-non-interactive {planfile_name} {common}',
|
106
106
|
'destroy': '{base_command} {command} {non_interactive} {no_auto_approve} {parallelism} {common} {planfile}',
|
107
107
|
}
|
108
108
|
|
@@ -537,8 +537,6 @@ class TgWrap():
|
|
537
537
|
|
538
538
|
self.printer.verbose(f'Execute command: {command} in working dir: {working_dir}')
|
539
539
|
|
540
|
-
self.printer.verbose(f'Executing in directory: {working_dir}')
|
541
|
-
|
542
540
|
self.printer.header(
|
543
541
|
f'\n\nStart processing module: {module} ({progress})\n\n',
|
544
542
|
print_line_before=True,
|
tgwrap-0.8.8/setup.py
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
from setuptools import setup
|
3
|
-
|
4
|
-
packages = \
|
5
|
-
['tgwrap']
|
6
|
-
|
7
|
-
package_data = \
|
8
|
-
{'': ['*']}
|
9
|
-
|
10
|
-
install_requires = \
|
11
|
-
['click>=8.0',
|
12
|
-
'inquirer>=3.1.4,<4.0.0',
|
13
|
-
'networkx>=2.8.8,<3.0.0',
|
14
|
-
'outdated>=0.2.2',
|
15
|
-
'pydot>=1.4.2,<2.0.0',
|
16
|
-
'pyhcl>=0.4.4,<0.5.0',
|
17
|
-
'python-hcl2>=4.3.2,<5.0.0',
|
18
|
-
'pyyaml>=6.0',
|
19
|
-
'terrasafe>=0.5.1,<0.6.0']
|
20
|
-
|
21
|
-
entry_points = \
|
22
|
-
{'console_scripts': ['tgwrap = tgwrap.cli:main']}
|
23
|
-
|
24
|
-
setup_kwargs = {
|
25
|
-
'name': 'tgwrap',
|
26
|
-
'version': '0.8.8',
|
27
|
-
'description': 'A (terragrunt) wrapper around a (terraform) wrapper around ....',
|
28
|
-
'long_description': '# tg-wrap\n\nThis app simply wraps terragrunt (which is a wrapper around terraform, which is a wrapper around cloud APIs, which is...).\n\nWait, why on earth do we need a wrapper for a wrapper (for a wrapper)?\n\nWell, first of all it is pretty opinionated so what works for us, doesn\'t necessarily work for you.\n\nBut our reasoning for creating this is as follows:\n\n## 1. Less typing\n\nterraform is great, and in combination with terragrunt even greater! But let\'s face it, terragrunt does not excel in conciseness! The options are pretty long, which leads to lots of typing. We don\'t like typing!\n\n## 2. Testing modules locally\n\nHowever, more importantly, we are heavily utilising [TERRAGRUNT_SOURCE](https://terragrunt.gruntwork.io/docs/features/execute-terraform-commands-on-multiple-modules-at-once/#testing-multiple-modules-locally) when developing.\n\nThe thing is that as long as you use `run-all` you can use one setting for that variable (and conveniently set it as an environment variable), while if you run a regular command, you need to specify the full path. Which is obviously different for each project.\n\nWhich leads to (even) more typing, and worse: a higher chance for errors.\n\nLuckily you can use `run-all` and add the appriopriate flags to ensure it behaves like a regular plan|apply|destroy etc. But again, more typing.\n\nNothing a [bunch a aliases](https://gitlab.com/lunadata/terragrunt-utils/-/blob/main/tg-shell.sh) can\'t solve though!\n\n## 3. But the original reason was: Errors when using run-all are challenging\n\nOne of the main boons of terragrunt is the ability to break up large projects in smaller steps while still retaining the inter-dependencies. However, when working on such a large project and something goes wrong somewhere in the middle is pretty challenging.\n\nterragrunt\'s error messages are pretty massive, and this is extrapolated with every individual project in your dependency chain.\n\nAnd if it fails somewhere at the front, it keeps on trying until the last one, blowing up your terminal in the process.\n\nSo we wanted a possibility to run the projects step by step, using the dependency graph of terragrunt and have a bit more control over it.\n\nAnd when you can run it step by step, you can make the process also re-startable, which is also pretty handy!\n\nAnd this was not something a bunch of aliases could solve, hence this wrapper was born. And while we we\'re at it, replacing the aliases with this was then pretty straightforward next step as well.\n\n## 4. Analyzing plan files\n\nWhen using the run-all, analyzing what is about to be changed is not going to be easier. Hence we created the `tgwrap analyze` function that lists all the planned changes and (if a config file is availabe) calculates a drift score and runs a [terrasafe](https://pypi.org/project/terrasafe/) style validation check.\n\nIt needs a config file as follows:\n\n```yaml\n---\n#\n# Critically of resources as interpreted by \'tgwrap analyze\'.\n# It uses it for a \'terrasafe\' like validation if resources can safely be deleted.\n# On top of that it tries to analyze and quantify the drift impact of the changes,\n# so that this can be monitored.\n#\nlow:\n # defaults:\n # terrasafe_level: ignore_deletions\n # drift_impact:\n # default: minor\n # delete: medium\n azuread_application.: {} # if we you want to use the defaults\n azuread_app_role_assignment: # or if you want to override these\n drift_impact:\n delete: minor\n # and so on, and so forth\nmedium:\n # defaults:\n # terrasafe_level: ignore_deletion_if_recreation\n # drift_impact:\n # default: medium\n # delete: major\n azurerm_data_factory_linked_service_key_vault.: {}\n # and so on, and so forth\nhigh:\n # defaults:\n # terrasafe_level: unauthorized_deletion\n # drift_impact:\n # default: major\n # update: medium\n azuread_group.:\n drift_impact:\n create: minor\n update: minor\n azurerm_application_insights.: {}\n # and so on, and so forth\n```\n\n### Speeding up the performance of analyze\n\nThis `analyze` function turned out to be pretty slow, where most of the time went into the `terragrunt show` function that is executed for each individual module. \n\nThis was a bit surprising as the plan file is already available on the file system, but it turns out that terragrunt is taking quite a bit of time for managing the depdencies. Even when you\'re excluding the external dependencies and are located in a particular module.\n\nSo, if you add the following to your root `terragrunt.hcl`:\n\n```hcl\nterraform {\n after_hook "link_to_current_module" {\n commands = ["init", "plan", "apply", "validate", "destroy"]\n execute = ["bash", "-c", "ln -sf $(pwd) ${get_terragrunt_dir()}/.terragrunt-cache/current"]\n }\n}\n```\n\nThe directory where the plan file is stored (including the other resources that terraform needs) becomes predictable and it becomes possible to run a native `terraform show` (instead `terragrunt show`) which dramatically speed up things.\n\nJust set the proper value as an environment variable:\n\n```console\nexport TGWRAP_PLANFILE_DIR=".terragrunt-cache/current"\n```\n\nOr pass it along with the `--planfile-dir|-P` option and it will use that.\n\n## More than a wrapper\n\nOver time, tgwrap became more than a wrapper, blantly violating [#1 of the unix philosophy](https://en.wikipedia.org/wiki/Unix_philosophy#:~:text=The%20Unix%20philosophy%20is%20documented,%2C%20as%20yet%20unknown%2C%20program.): \'Make each program do one thing well\'.\n\nFor instance, the \'analyze\' functionality is already an example, but more features such as deploying a landing zone has crept into the application. It makes sense for how we\'re using it, but we\'re fully aware this makes it less generically applicable.\n\n## Usage\n\n```console\n# general help\ntgwrap --help\n\ntgwrap run -h\ntgwrap run-all -h\n\n# run a plan\ntgwrap plan # which is the same as tgwrap run plan\n\n# run-all a plan\ntgwrap run-all plan\n\n# run-all with excluding a particular directory\ntgwrap run-all plan -E \'excluded-dir/*\'\n# or a directory somewhere further down in the path\ntgwrap run-all plan -E \'**/excluded-dir/**\'\n\n# or do the same in step-by-step mode\ntgwrap run-all plan -s\n\n# or excluding (aka ignoring) external dependencies\ntgwrap run-all plan -sx\n\n# if you want to add additional arguments it is recommended to use -- as separator (although it *might* work without)\ntgwrap output -- -json\n```\n\n> Note: special precautions are needed when passing on parameters that contain quotes. For instance, if you want to move state like below, escape the double quote in the staate address:\n\n`tgwrap state mv \'azuread_group.this[\\"viewers\\"]\' \'azuread_group.this[\\"readers\\"]\'`\n\n## A word about escaping inputs\n\nYour shell is escaping special characters such as `*` and `"` before passing it to the program (`tgwrap` in this case). So some inputs **need** to be escaped in order to function properly.\n\nFor example:\n\n```console\n# to exclude certain modules from an action (such as analyze):\ntgwrap analyze -E \'integrations/\\*/\\*\'\n\n# to import a resource that has a " in its address:\ntgwrap import -a \'azuread_group.this[\\"my_group\\"]\' -i ${GROUP_ID}\n```\n\n## Deploy manifests\n\nIn order to easily deploy a new version of the terraform (and associated terragrunt) modules, we include a manifest file in the root of the landing zone:\n\n```yaml\n---\ngit_repository: ssh://git@gitlab.com/my-org/my-terraform-modules-repo.git\nbase_path: terragrunt/my-platform # path where the terragrunt modules are stored \nconfig_path: terragrunt/config/platform-dev # path (relative to base path) where the config files are stored\n\ndeploy: # which modules do you want to deploy\n dtap:\n applies_to_stages:\n - dev\n - tst\n - acc\n - prd\n source_stage: dev\n source_dir: platform # optional, if the source modules are not directly in the stage dir, but in <stage>/<source_dir> directory\n base_dir: platform # optional, if you want to deploy the base modules in its own dir, side by side with substacks\n config_dir: ../../../config # this is relative to where you run the deploy\n configs:\n - my-config.hcl\n - ../my-ss-config-dir\n # skip_all_modules: True # could be handy if you only want to deploy substacks and no regular modules\n exclude_modules: # these modules will always be excluded, can be omitted\n - my-specific-module\n include_modules: {} # omit or use an empty dict for all of them\n # or specify your modules as follows\n # base: {} # just a simple include\n # networking-connected: # or a bit more complicated\n # - source: networking\n # - target: networking-connected\n\nsub_stacks:\n is01:\n source: shared-integration/intsvc01\n target: integration/is01\n exclude_modules: # a list of modules that will always be excluded, can be omitted\n - my-specific-module\n configs:\n - my-ss-config.hcl\n - ../my-ss-config-dir\n is02:\n source: shared-integration/intsvc01\n target: integration/is02\n\n# global configuration files that are deployed as well\n# note that these files are typically applicable to all landing zones and stages!\n# this might lead to unexpected behaviour\n# note that you can exclude syncing these files with a command line switch\nglobal_config_files:\n root-terragrunt:\n source: ../../terragrunt.hcl # relative to base_path\n target: ../../terragrunt.hcl # can be omitted, then it is same as source path\n terrasafe-config:\n source: ../../terrasafe-config.json\n```\n\n## Generating change logs\n\ntgwrap can generate a change log by running:\n\n```console\ntgwrap change-log [--changelog-file ./CHANGELOG.md]\n```\n\nThe (optional) change log file will be, if passed along. tgwrap then checks the file for the existance of a start and end markers, in the following format:\n\n```python\n start_marker = \'<!-- BEGINNING OF OF TGWRAP CHANGELOG SECTION -->\'\n end_marker = \'<!-- END OF TGWRAP CHANGELOG SECTION -->\'\n```\n\nIf they exist, everything between these lines will be replaced by the new change log.\n\n## Development\n\nIn order to develop, you need to apply it to your terragrunt projects. For that you can use the `--terragrunt-working-dir` option and just run it from the poetry directory. Alternatively you can use the [tgwrap-dev](./tgwrap-dev) script and invoke that from your terragrunt directories. Either put it in your `PATH` or create an alias for convenience.\n',
|
29
|
-
'author': 'Gerco Grandia',
|
30
|
-
'author_email': 'gerco.grandia@4synergy.nl',
|
31
|
-
'maintainer': 'None',
|
32
|
-
'maintainer_email': 'None',
|
33
|
-
'url': 'https://gitlab.com/lunadata/tgwrap',
|
34
|
-
'packages': packages,
|
35
|
-
'package_data': package_data,
|
36
|
-
'install_requires': install_requires,
|
37
|
-
'entry_points': entry_points,
|
38
|
-
'python_requires': '>=3.8,<4.0',
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
setup(**setup_kwargs)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|