atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

feat: auto-plan projects when modules change

Open iamnoah opened this issue 2 years ago • 9 comments

Fixes #920

See testdata for an example repo structure. Any project that uses modules in the same repo should be able to take advantage.

Only files that are not considered part of a project will be considered. With the current auto-plan heuristic, only changed files in /modules/ without a main.tf would trigger a check of the modules dependencies.

iamnoah avatar Sep 08 '22 19:09 iamnoah

What are the repo structure and the module instantiation used?

a more detailed example could help to understand the feature

jamengual avatar Sep 08 '22 19:09 jamengual

@jamengual updated the description to point to the test data. It's layout agnostic as it parses the module dependencies out of the projects.

iamnoah avatar Sep 08 '22 20:09 iamnoah

so this only works when the source = is relative to the checked out repo not when the source = cloudposse/vpc/aws which is the terraform registry ?

jamengual avatar Sep 08 '22 20:09 jamengual

@jamengual correct, it's only detecting changes to local modules.

iamnoah avatar Sep 08 '22 20:09 iamnoah

Sorry for the churn, in testing this out, I've squashed some bugs and cleaned things up.

I think the docs now lay out the use case. Since it's a departure from current behavior, it requires a flag to activate, but I think --autoplan-modules does what one would intuitively expect. If the module indexing does something undesired, e.g., take a long time or fail on unusual projects, it can be disabled selectively by changing its pattern.

iamnoah avatar Sep 12 '22 20:09 iamnoah

Anything else I need to do to have this considered? A week of using it in our pipelines hasn't revealed any new issues.

iamnoah avatar Sep 19 '22 21:09 iamnoah

This sounds similar to something I have in my atlantis.yaml generation script. I'm curious to know if you can disable autoplanning for individual child modules. For example, I have a child module that is called hundreds of times that I don't want to autoplan for obvious reasons, so I include a header in my main.tf file so my script knows to ignore it.

pauloconnor avatar Sep 20 '22 20:09 pauloconnor

@pauloconnor yup! --autoplan-file-list=**/*.tf...,!modules/really-common-child-module/* would keep changes to that module from being planned.

iamnoah avatar Sep 20 '22 21:09 iamnoah

@iamnoah Damn, that's fantastic! Hopefully this'll get merged in soon.

pauloconnor avatar Sep 20 '22 21:09 pauloconnor

@jamengual rebased and tried to fix linter issues. LMK what can help move this forward.

iamnoah avatar Oct 25 '22 15:10 iamnoah

@iamnoah please merge from the default branch to fix the branch test failure

nitrocode avatar Oct 28 '22 22:10 nitrocode

@iamnoah can you fix the conflicts?

jamengual avatar Nov 09 '22 06:11 jamengual

@iamnoah please fix conflicts

nitrocode avatar Nov 13 '22 21:11 nitrocode

@iamnoah please fix linting error in failed branch pr check

nitrocode avatar Nov 14 '22 17:11 nitrocode

@iamnoah apologies but looks like this PR has some conflicts, could you resolve them?

nitrocode avatar Nov 19 '22 00:11 nitrocode

@iamnoah Thanks for the contribution

jamengual avatar Nov 28 '22 22:11 jamengual

@jamengual what are the chances of getting a release cut with this in it? Looks like the merge happened less than two hours after the release was tagged.

lattwood avatar Dec 01 '22 14:12 lattwood

we do pre-release for new features before they go to the stable branch.

We will do a prerelease soon.

jamengual avatar Dec 01 '22 15:12 jamengual