Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with Terraform

You're reading from   Getting Started with Terraform Infrastructure automation made easy

Arrow left icon
Product type Paperback
Published in Jan 2017
Publisher Packt
ISBN-13 9781786465108
Length 206 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Kirill Shirinkin Kirill Shirinkin
Author Profile Icon Kirill Shirinkin
Kirill Shirinkin
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Infrastructure Automation FREE CHAPTER 2. Deploying First Server 3. Resource Dependencies and Modules 4. Storing and Supplying Configuration 5. Connecting with Other Tools 6. Scaling and Updating Infrastructure 7. Collaborative Infrastructure 8. Future of Terraform

Configuring modules


Let's list the data we need to pass to the module:

  • Name of the application

  • VPC ID

  • Subnet ID

That should be sufficient for now. Update the module inside template.tf to look as follows:

module "mighty_trousers" { 
  source = "./modules/application" 
  vpc_id = "${aws_vpc.my_vpc.id}" 
  subnet_id = "${aws_subnet.public.id}" 
  name = "MightyTrousers" 
} 

Passing data like this is not enough, though. We need to define variables inside the module template. The thing is, our tempate.tf is a module itself, a special module named root module. That's what you saw on the last graph we drew--resources were coming from the root module. So, we were actually already using modules all this time, and every module, including the root module, can be configured with variables.

Note

We did not look much into Terraform variables in general till now, and most of the content on this topic is explained in Chapter 4, Storing and Supplying Configuration. For now, let's get...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime