Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Custom destinations for modules #13

Merged
merged 19 commits into from
Feb 15, 2023

Conversation

ivan-kostko
Copy link
Contributor

This feature enables module management with specific destinations, while back compatibility is intact.

Centrally managed: Terrafile is located in "root" directory of your terraform code, managing modules in all subfolders / stacks
An example of using Terrafile in a root directory:

Let's assume following directory structure structure

.
├── iam
│   ├── main.tf
│   └── .....tf
├── networking
│   ├── main.tf
│   └── .....tf
├── onboarding
.
.
.
├── some-other-stack
└── Terrafile

In above scenarion Terrafile is not in every single folder but in the "root" of terraform code.

An example usage of centrally managed modules:

tf-aws-vpc:
    source:  "[email protected]:terraform-aws-modules/terraform-aws-vpc"
    version: "v1.46.0"
    destination:
        - networking
tf-aws-iam:
    source:  "[email protected]:terraform-aws-modules/terraform-aws-iam"
    version: "v5.11.1"
    destination:
        - iam
tf-aws-s3-bucket:
    source:  "[email protected]:terraform-aws-modules/terraform-aws-s3-bucket"
    version: "v3.6.1"
    destination:
        - networking
        - onboarding
        - some-other-stack

The destination of module is an array of directories (stacks) where the module should be used.
The module itself is fetched once and copied over to designated destionations.
Final destination of the module is handled in a similar way as in first approach: $destination/$module_path/$module_key.

The output of the run is exactly the same in both options.

Copy link
Collaborator

@nritholtz nritholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some typo fixes and minor suggestions on reworking the implementation.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
ivan-kostko and others added 3 commits February 14, 2023 11:10
* Destination -> Destinations

* SymLink instead of copy. Hardlinks won't work for directories

* Adjusted tests to fixes
Copy link
Collaborator

@nritholtz nritholtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome work! two very minor fixes, otherwise looks good to me

main.go Outdated Show resolved Hide resolved
main_test.go Outdated Show resolved Hide resolved
@ivan-kostko
Copy link
Contributor Author

Hi @nritholtz ,

Sorry for off topic, but as we discussed inside our team, the tool is missing -clean flag. The issue appears whenever some module is removed from file, but tool does not remove it from filesystem. Hence, we will prepare a separate PR introducing this functionality as soon as this PR is merged.

@nritholtz nritholtz merged commit 2c10832 into coretech:master Feb 15, 2023
@nritholtz nritholtz mentioned this pull request Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants