Terraform Dependency Armageddon!! Explicit vs. Implicit Dependencies in Terraform using 'depends_on'

preview_player
Показать описание
EPISODE 71
In this episode, we'll look at a common pitfall for Terraform newbies: when to declare an explicit dependency using the 'depends_on' meta-argument.

Follow me on Twitter for quick code snippets and thoughts on Cloud, Automation and other things!

Keep the knowledge flowing!

Source Code:
Рекомендации по теме
Комментарии
Автор

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.

abdulazizbarkat
Автор

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!

tomaskunka
Автор

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.

abdulazizbarkat
Автор

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

ManneyM