Chapter 4. Terraform Modules and Providers
Modules in Terraform are self-contained packages of Terraform configurations that are managed as a group. They are used to encapsulate code into reusable components and to organize code to facilitate teamwork and collaboration. Each module can include several resources that are configured to work together.
Modules can be compared to functions in traditional programming languages. Like a function, a module encapsulates a code block with a specific purpose and can be reused in different contexts. However, unlike a function, a module manages a collection of resources rather than performing computation.
Terraform modules are created using the same language syntax as the root-level Terraform configurations (.tf files). Using the module configuration block, they can be called from within other modules or the root module.
While modules help us organize resources and reuse code, Terraform Providers interact with external APIs to create, read, update, and delete those resources. Each provider is responsible for understanding API interactions and exposing resources.
Terraform is compatible with many cloud providers, including AWS, GCP, Microsoft Azure, and other service providers such as GitHub, Datadog, and many others.
4.1 Using Public Modules to Create an EKS Cluster
Problem
You have set up a VPC within AWS, and now you’d like to start hosting some applications on Kubernetes. You want to set up an Elastic Kubernetes Service (EKS) cluster and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access