Skip to content

Issue 123 all layers option - #151

Merged
juanmatias merged 15 commits into
ISSUE-141-s3-key-multi-region-supportfrom
ISSUE-123-all-layers-option
Jan 6, 2023
Merged

juanmatias merged 15 commits into
ISSUE-141-s3-key-multi-region-supportfrom
ISSUE-123-all-layers-option

Conversation

@juanmatias

Copy link
Copy Markdown
Contributor

What?

  • "All Layers"feature added
    TF base commands can be run as they are from inside a layer dir:
leverage tf init

...or with --layers option from the account dir:

leverage tf init --layers us-east-1/terraform-backend,global/sso
  • the code inside terraform.py was refactored for sake of readability.

Why?

  • Fulfill a user request
  • Take advantage of the work and refactor code for clarity

References

n/a

Comment thread leverage/container.py Resolved
Comment thread leverage/container.py Resolved
Comment thread leverage/container.py Resolved
Comment thread leverage/container.py Resolved
Comment thread leverage/container.py Resolved
Comment thread leverage/modules/aws.py Resolved
Comment thread leverage/modules/terraform.py Resolved
Comment thread leverage/modules/terraform.py Resolved
Comment thread leverage/modules/terraform.py Resolved
@juanmatias

juanmatias commented Jan 5, 2023 •

Copy link
Copy Markdown
Contributor Author

@angelofenoglio fixed and replied your comments

please take a look at function set_backend_key
I changed it so it can generate the key when the S3 backend configuration exists and the --skip-validation was set

also, please look at these lines
I added a comment on how to call --all-layers... but maybe it has to be in a better place (aka documentation)

@juanmatias

Copy link
Copy Markdown
Contributor Author

@angelofenoglio
regarding the scenarios for get_location_type

def get_location_type(self):

I renamed the 'other under project' to 'sublayer'

it is used to run with --layers from inside a sublayer dir (aka not a layer nor an account dir, but still a valid one)

if tf.get_location_type() == 'layer' and len(layers) == 0:

@angelofenoglio

Copy link
Copy Markdown
Contributor

please take a look at function set_backend_key
I changed it so it can generate the key when the S3 backend configuration exists and the --skip-validation was set

This looks good! And the small chart helps with understanding the logic.

also, please look at these lines
I added a comment on how to call --all-layers... but maybe it has to be in a better place (aka documentation)

The info in here works nicely as a quick reference but all the changes and different behaviors introduced in these last PRs should be clearly expressed in the documentation since they are going to be critical for the user.

I renamed the 'other under project' to 'sublayer'

I think in this case is the other way around, so for example the dns layer which is on shared/global/base-dns/binbash.com.ar
base-dns contains no .tf files but holds the same place as the other layers, meanwhile binbash.com.ar is a subdirectory but is the actual directory where the .tf files are stored, a sublayer if you will.
Maybe the best solution is calling the one that holds the .tf files layer and any directory like base-dns something like supralayer? or metalayer? what do you think.
Opinions @diego-ojeda-binbash @exequielrafaela?

@juanmatias

Copy link
Copy Markdown
Contributor Author

@angelofenoglio value changed from sublayer to layers-group.

Changes made here:

def get_location_type(self):

if tf.get_location_type() == 'layer' and len(layers) == 0:

if not cli.get_location_type() in ['account', 'layer', 'layers-group']:

@juanmatias
juanmatias merged commit 0e0eb74 into ISSUE-141-s3-key-multi-region-support Jan 6, 2023
@juanmatias
juanmatias deleted the ISSUE-123-all-layers-option branch January 6, 2023 20:12
juanmatias added a commit that referenced this pull request Jan 13, 2023
* ISSUE-141 Added multi options for s3 key checking

* ISSUE-141 Improved way to check DR

* ISSUE-1 added multi region support, tfautomv, s3 key autogeneration, layer region autodetection, region fallback system (layer dir, then account tfvars, then project tfvars)

* ISSUE-141 adding path to deploy beta and alpha images

* ISSUE-141 fixed python version

* ISSUE-141 added region var to tf command line; fixed var name in credentials

* ISSUE-141 set toolbox version

* ISSUE-141 imported tests from master

* ISSUE-141 fix to _find_region function

* Update leverage/container.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* Update leverage/container.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* Update leverage/container.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* Update leverage/modules/terraform.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* Issue 123 all layers option (#151)

* ISSUE-123 added logic for init-multi command

* ISSUE-123 all terraform commands keeps running on layers but accept --layers list to run from account level

* ISSUE-141 persist s3 key when dynamically generated

* ISSUE-123 added logic for recording the s3 key in the tf file when automagically generated; removed hidden commands from tf commands

* Update leverage/container.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* ISSUE-123 changed internal functions from click commands to regular functions; code refactor for sake of readability

* ISSUE-123 fixed test

* ISSUE-123 fixed makefile for testing

* Update leverage/container.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* Update leverage/container.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* Update leverage/modules/terraform.py

Co-authored-by: Angelo Fenoglio <[email protected]>

* ISSUE-123 fixed comments for PR 151

* ISSUE-123 removed comments

* ISSUE-123 fixed condition

* ISSUE-123 changed value sublayer to layers_group

Co-authored-by: Angelo Fenoglio <[email protected]>

* ISSUE-141 toolbox version updated

Co-authored-by: Angelo Fenoglio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants