TL;DR Applying some Bash knowhow on exit codes, you can cut down the time required for a Terraform apply if no changes are to be done. The Simple Plan and Apply Over the past couple of weeks, I’d been working on getting our alerts deployed with Terraform. The initial proof of concept was a very simple shell script with a lot of copy-paste to handle the many accounts, environments and regions that I work on.
Since my new job involves lot more of Linux, shell scripting bash and automation, I’ve been trying to brush up my Linux skills. Ran into this “problem” today where there’s an init script which handles unicorn start/stop/reload and we were debugging some kinks around this. The init script had a chain of cd to the directory and the unicorn invoke script. Was trying to figure out why unicorn wasn’t starting up, till I read a bit more and dropped to using echo to understand what’s happening
Quick tip - if you use the Terminal as much as I do, ever been in a situation where you’ve written a particularly long command, and then want to issue that command again but can’t recall it ? Use the history command, and pipe it to grep to search it! history | grep -i <search-term> This will give you all commands with the search term and the corresponding line number.