How to create a resource after an action has completed

I have a Terraform action that runs after resource A is created using events = [ after_create ]. The creation of resource B depends on the action in resource A completing. How can I create this dependency? If I use depends_on in resource B and reference the action, I get the error The depends_on attribute cannot reference action blocks directly. You must reference a resource or data source instead.

Hi @mikeassel,

This is a known issue in the current actions implementation, and you can follow the status in Actions not respecting resource dependencies · Issue #37975 · hashicorp/terraform · GitHub

Thanks @jbardin. Any rough idea on a timeframe for a fix?

Sorry, I don’t have a timeline. I do know that it’s a deeper issue, so it’s not something that will land in an upcoming patch release.

1 Like