Here's something that's not very obvious but can be useful in certain cases: Output blocks can be configured with the depends_on meta argument! This is useful for example if you build a module that creates a key vault and the access policy for it. Just configure the outputs for the key vault to depend on the access policy and you have dependencies made transparent to your module's user.
depends on a whole module can also be a little dangerous for the dependent module. if it contains data sources and resources dependent on them, it can cause some unexpected recreations. thanks for the videos, keep up the great work!
True. Also recommend avoid data sources in modules. Reduces independence of module as you are baking in a huge assumption that the data sourced resource is not being provisioned in the current apply.
Implicit dependencies with modules are a bit smarter than what Mark explained here (maybe he wanted to keep it simpler for the video). If your module has multiple resources and only one of them use a variable all of the resources won't implicitly depend on it, only the resource using the variable will have that dependency. If that behaviour is needed you can configure depends_on for the module block.
Thanks Mark, that was really well explained👍 Me now: deleting my depends on attributes, put in before i actualy understood their true use case 🤦♂️🤷♂️ #EverydaysASchoolDay
Here's something that's not very obvious but can be useful in certain cases: Output blocks can be configured with the depends_on meta argument!
This is useful for example if you build a module that creates a key vault and the access policy for it. Just configure the outputs for the key vault to depend on the access policy and you have dependencies made transparent to your module's user.
Good idea! I should tackle this example *explicitly* 🤣
depends on a whole module can also be a little dangerous for the dependent module. if it contains data sources and resources dependent on them, it can cause some unexpected recreations.
thanks for the videos, keep up the great work!
True. Also recommend avoid data sources in modules. Reduces independence of module as you are baking in a huge assumption that the data sourced resource is not being provisioned in the current apply.
Nice explanation Mark🎉 keep going
Thanks! 😃
Implicit dependencies with modules are a bit smarter than what Mark explained here (maybe he wanted to keep it simpler for the video).
If your module has multiple resources and only one of them use a variable all of the resources won't implicitly depend on it, only the resource using the variable will have that dependency. If that behaviour is needed you can configure depends_on for the module block.
Yeah I wanted to address the craziness of decorating every resource with explicit depends on clauses! 🤣
Thanks Mark, that was really well explained👍
Me now: deleting my depends on attributes, put in before i actualy understood their true use case 🤦♂️🤷♂️ #EverydaysASchoolDay
🤣👍👍