How Do I Get A Summary of Task Times With Terraform?

HOW TO -️ October 18, 2021

If I run ansible with profile_tasks I get a nice table at the end that shows me how long each task took.

How can I get a similar summary at the end of running terraform apply?


profile tasks is an ansible _callback_ plugin. You'd need to extend terraform's cli with a similar plugin. to my knowledge none exists. That's surprising! A lot of people work with both tools. You'd think by now someone would have wanted to do it! Anyway, a answer with how to extend the cli is probably out of scope. Maybe the answer has to be something with grep, sort, awk etc Perhaps you could hook in something using the terraform CDK. Just a guess, but a language might provide you with the hooks you need to profile the resource actions (modify/destroy/create) I wonder if it could be as simple as capturing and parsing the text output from an apply as it usually includes timing information in the output.

For example grep'ed on "complete" on a captured output, should be able easy to parse further; "aws_security_group.bastions: Modifications complete after 1s [x]"