3 Functional programming

This chapter covers

  • Using the full gamut of input variables, local values, and output values
  • Making Terraform more expressive with functions and for expressions
  • Incorporating two new providers: Random and Archive
  • Templating with templatefile()
  • Scaling resources with count

Functional programming is a declarative programming paradigm that allows you to do many things in a single line of code. By composing small modular functions, you can tell a computer what you want it to do instead of how to do it. Functional programming is called that because, as the name implies, programs consist almost entirely of functions. The core principles of functional programming are as follows:

  • Pure functions—Functions return the same ...

Get Terraform in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.