Book Image

Getting Started with Terraform - Second Edition

By : Kirill Shirinkin
1 (1)
Book Image

Getting Started with Terraform - Second Edition

1 (1)
By: Kirill Shirinkin

Overview of this book

Terraform is a tool used to efficiently build, configure, and improve the production infrastructure. It can manage the existing infrastructure as well as create custom in-house solutions. This book shows you when and how to implement infrastructure as a code practices with Terraform. It covers everything necessary to set up the complete management of infrastructure with Terraform, starting with the basics of using providers and resources. It is a comprehensive guide that begins with very small infrastructure templates and takes you all the way to managing complex systems, all using concrete examples that evolve over the course of the book. The book ends with the complete workflow of managing a production infrastructure as code—this is achieved with the help of version control and continuous integration. The readers will also learn how to combine multiple providers in a single template and manage different code bases with many complex modules. It focuses on how to set up continuous integration for the infrastructure code. The readers will be able to use Terraform to build, change, and combine infrastructure safely and efficiently.
Table of Contents (15 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback

Storing modules remotely

We've stored the application module in the very same directory where our main Terraform template resides. It makes it impossible to reuse: if there is a new application in the company that requires the same infrastructure (meaning the same module), then we cannot easily use it.

Remember the source attribute of the module?

module "mighty_trousers" { 
  source = "./modules/application" 

Well, it turns out that it doesn't have to be a path to a local directory. In fact, there are multiple supported sources for modules:

  • GitHub
  • BitBucket
  • Generic Git and Mercurial repositories
  • S3 buckets

Storing modules in one of these destinations allows us to have a collection of reusable components. We can even version our modules, just like system packages or programming language libraries.

As we are deep into GitLab already, let's create yet another repository and call it packt-terraform-app-module. As always, all the code written in this chapter is available on GitLab at https:/...