Terraform tips & tricks: loops, if-statements, and gotchas

<p><strong><em>Update, November 17, 2016</em></strong><em>: We took this blog post series, expanded it, and turned it into a book called&nbsp;</em><a href="http://www.terraformupandrunning.com/?ref=gruntwork-blog-comprehensive-terraform" rel="noopener ugc nofollow" target="_blank"><em>Terraform: Up &amp; Running</em></a><em>!</em></p> <p><strong><em>Update, July 8, 2019</em></strong><em>: We&rsquo;ve updated this blog post series for Terraform 0.12 and released the&nbsp;</em><a href="https://blog.gruntwork.io/terraform-up-running-2nd-edition-early-release-is-now-available-b104fc29783f" rel="noopener ugc nofollow" target="_blank"><em>2nd edition of Terraform: Up &amp; Running</em></a><em>!</em></p> <p><strong><em>Update, Sep 28, 2022:&nbsp;</em></strong><em>We&rsquo;ve updated this blog post series for Terraform 1.2 and released the&nbsp;</em><a href="https://blog.gruntwork.io/terraform-up-running-3rd-edition-is-now-published-4b99804d922a" rel="noopener ugc nofollow" target="_blank"><em>3rd edition of Terraform: Up &amp; Running</em></a><em>!</em></p> <p>This is Part 5 of the&nbsp;<a href="https://blog.gruntwork.io/a-comprehensive-guide-to-terraform-b3d32832baca#.b6sun4nkn" rel="noopener ugc nofollow" target="_blank">Comprehensive Guide to Terraform</a>&nbsp;series. In previous parts, you learned&nbsp;<a href="https://blog.gruntwork.io/why-we-use-terraform-and-not-chef-puppet-ansible-saltstack-or-cloudformation-7989dad2865c#.63ls7fpkq" rel="noopener ugc nofollow" target="_blank">why we picked Terraform</a>, how to use the&nbsp;<a href="https://blog.gruntwork.io/an-introduction-to-terraform-f17df9c6d180" rel="noopener ugc nofollow" target="_blank">basic syntax and features of Terraform</a>,&nbsp;<a href="https://blog.gruntwork.io/how-to-manage-terraform-state-28f5697e68fa" rel="noopener ugc nofollow" target="_blank">how to manage Terraform state</a>, and&nbsp;<a href="https://blog.gruntwork.io/how-to-create-reusable-infrastructure-with-terraform-modules-25526d65f73d" rel="noopener ugc nofollow" target="_blank">how to create reusable infrastructure with Terraform modules</a>. In this part, you are going to expand your Terraform toolbox with some more advanced tips &amp; tricks, such as how to do loops and if-statements. You&rsquo;ll also learn about some of Terraform&rsquo;s weaknesses so you can avoid the most common gotchas.</p> <p><a href="https://blog.gruntwork.io/terraform-tips-tricks-loops-if-statements-and-gotchas-f739bbae55f9"><strong>Read More</strong></a></p>
Tags: Terraform Tips