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

Поділитися
Вставка
  • Опубліковано 19 вер 2024

КОМЕНТАРІ • 10

  • @abdulazizbarkat1701
    @abdulazizbarkat1701 11 місяців тому +2

    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.

    • @azure-terraformer
      @azure-terraformer  11 місяців тому

      Good idea! I should tackle this example *explicitly* 🤣

  • @tomaskunka2801
    @tomaskunka2801 11 місяців тому +1

    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!

    • @azure-terraformer
      @azure-terraformer  11 місяців тому +1

      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.

  • @glibmar
    @glibmar 11 місяців тому +1

    Nice explanation Mark🎉 keep going

  • @abdulazizbarkat1701
    @abdulazizbarkat1701 11 місяців тому +1

    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.

    • @azure-terraformer
      @azure-terraformer  11 місяців тому

      Yeah I wanted to address the craziness of decorating every resource with explicit depends on clauses! 🤣

  • @ManneyM
    @ManneyM 11 місяців тому +1

    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