Read state file after terraform apply?


I have a use case where I need to read the state file after terraform apply and push few details from it into database. We are keeping the state files in the backend storage.

By any chance, is it possible to make any custom plugin for terraform which can execute automatically after terraform apply as the part of terraform execution.

I need to push the updates from the state file after completion of terraform apply only.

Thank you


If using terraform Enterprise you can use a custom worker to do pre and post work, see an example.

You could also store the plan in the run (terraform plan -out) and use the output plan.

I am interested in how to do the same with a custom plugin as I see there is a need for that step or workflow. Maybe the new Terraform cloud run tasks could be implemented in the terraform cli?