3

I have a repo in which I manage Terraformcode for multiple environments. For example I would have these files:

/terraform/dev/superapp/main.tf
/terraform/prod/superapp/main.tf

In those files, I define the used providers, modules, etc. The versions of those components are identical on dev and prod.

I enabled renovate on that repo and it works almost perfectly.

But renovate will open a PR that updates the versions for e.g. the aws provider or the eks-module in dev and prod in just one PR.

But I would like to have separate PRs for each module, provider, etc and then again separate PRs for dev and prod.

So I would end up with four PRs regarding the aws-provider and the eks-module. One for each dependency in each environment. I checked the docs of Renovate, but I could not really find out which parameter would trigger such a behaviour, but I am sure this has to be possible.

Any help is much appreciated.

2 Answers2

6

You can specify the configuration option additionalBranchPrefix to add a prefix to the branch name created by Renovate. By using parentDir or baseDir in the prefix, Renovate will split PRs based on where the package definition is located.

In your case, since the immediate parent directory has the same name (superapp), you would have to use baseDir to take into account the whole path of the file to update.

Adding this configuration in renovate.json should do the trick:

{
  "packageRules": [
    {
      "managers": ["terraform"],
      "additionalBranchPrefix": "{{baseDir}}-",
      "packagePatterns": [".*"]
    }
  ]
}
fparga
  • 151
  • 3
  • Do you know if there is also a possibility to do this if these two occurrences of the same dependency are in the same `basedir` or even in the same file? – Domi W Jul 31 '23 at 16:33
0

As far as I know that is not possible at the moment with renovate. You could try and include the files/paths one by one, but I do not think that will work.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 10 '22 at 10:55