Deploying modules with dependencies fails

Hi,

I am writing to you about the subject matter at hand. Specifically, when I try to deploy two modules one of which has a dependency on the first module, it fails. I provide an example: the first module creates a cluster aks, the second module should go and perform tasks on the cluster nodes. The problem is that the ‘depends_on’ in this case does not work, because already when the ‘terraform plan’ command is executed, it is expected that the cluster already exists. The only solution I have found so far is to separate the execution of the two or more modules that give this problem. Do you know if there is another more efficient solution?

If you need to create some resources in order to plan other parts of your infrastructure, then you should usually be using multiple configurations for these separate parts. Think of it as creating the first layer of infrastructure, on top of which you will later deploy more infrastructure.

It is possible to use -target on the first plan to limit the actions to only the first module you want to apply, but that is not really any more efficient, and can cause other complications later on if you need to update multiple parts of the configuration.

After version 0.13 its expected to respect dependencies between modules like this documentation:

@jbardin is right with our sugestion, creating plan/apply with target, but its does not sounds good for me too.

Can you share the version of terraform and part of code where you declare depends_on?