Hi everyone,
I have below repository structure:
.
├── envs
│ ├── prod
│ │ ├── env.tfvars
│ │ ├── module1
│ │ │ ├── terraform.tfvars
│ │ │ └── terragrunt.hcl
│ │ └── module2
│ │ ├── terraform.tfvars
│ │ └── terragrunt.hcl
│ └── dev
│ ├── env.tfvars
│ ├── module3
│ │ ├── terraform.tfvars
│ │ └── terragrunt.hcl
│ └── module4
│ ├── terraform.tfvars
│ └── terragrunt.hcl
├── README.md
└── terragrunt.hcl
When a merge request is created I need to execute a custom command based on the list of files which are changed in the mr. Example:
- envs/prod/module1/terragrunt.hcl changes I need to:
cd envs/prod/module1
terragrunt plan
- envs/prod/env.tfvars changes I need to:
cd envs/prod
terragrunt run-all plan
- envs/dev/module4/terraform.tfvars changes I need to:
cd envs/dev/module4
terragrunt plan
I am thinking about adding as a first job a custom script which would create a list of commands which need to be invoked in the next step. This script would use plain git or gitlab API (example) to fetch a list of changed files and generate proper sequence of commands.
Is there maybe some other and better way to implement the needed functionality?
Thanks in advance for all help!
Best Regards,
Rafal.