Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Preface
Who Should Read This Book
Why I Wrote This Book
What You Will Find in This Book
What’s New in the Second Edition
What You Won’t Find in This Book
Open Source Code Examples
Using the Code Examples
Conventions Used in This Book
O’Reilly Online Learning
How to Contact O’Reilly Media
Acknowledgments
1. Why Terraform
The Rise of DevOps
What Is Infrastructure as Code?
Ad Hoc Scripts
Configuration Management Tools
Server Templating Tools
Orchestration Tools
Provisioning Tools
The Benefits of Infrastructure as Code
How Terraform Works
How Terraform Compares to Other IaC Tools
Configuration Management Versus Provisioning
Mutable Infrastructure Versus Immutable Infrastructure
Procedural Language Versus Declarative Language
Master Versus Masterless
Agent Versus Agentless
Large Community Versus Small Community
Mature Versus Cutting Edge
Using Multiple Tools Together
Conclusion
2. Getting Started with Terraform
Setting Up Your AWS Account
Install Terraform
Deploy a Single Server
Deploy a Single Web Server
Deploy a Configurable Web Server
Deploying a Cluster of Web Servers
Deploying a Load Balancer
Cleanup
Conclusion
3. How to Manage Terraform State
What Is Terraform State?
Shared Storage for State Files
Limitations with Terraform’s Backends
Isolating State Files
Isolation via Workspaces
Isolation via File Layout
The terraform_remote_state Data Source
Conclusion
4. How to Create Reusable Infrastructure with Terraform Modules
Module Basics
Module Inputs
Module Locals
Module Outputs
Module Gotchas
File Paths
Inline Blocks
Module Versioning
Conclusion
5. Terraform Tips and Tricks: Loops, If-Statements, Deployment, and Gotchas
Loops
Loops with the count Parameter
Loops with for_each Expressions
Loops with for Expressions
Loops with the for String Directive
Conditionals
Conditionals with the count Parameter
Conditionals with for_each and for Expressions
Conditionals with the if String Directive
Zero-Downtime Deployment
Terraform Gotchas
count and for_each Have Limitations
Zero-Downtime Deployment Has Limitations
Valid Plans Can Fail
Refactoring Can Be Tricky
Eventual Consistency Is Consistent…Eventually
Conclusion
6. Production-Grade Terraform Code
Why It Takes So Long to Build Production-Grade Infrastructure
The Production-Grade Infrastructure Checklist
Production-Grade Infrastructure Modules
Small Modules
Composable Modules
Testable Modules
Releasable modules
Beyond Terraform Modules
Conclusion
7. How to Test Terraform Code
Manual Tests
Manual Testing Basics
Cleaning Up After Tests
Automated Tests
Unit Tests
Integration Tests
End-to-End Tests
Other Testing Approaches
Conclusion
8. How to Use Terraform as a Team
Adopting IaC in Your Team
Convince Your Boss
Work Incrementally
Give Your Team the Time to Learn
A Workflow for Deploying Application Code
Use Version Control
Run the Code Locally
Make Code Changes
Submit Changes for Review
Run Automated Tests
Merge and Release
Deploy
A Workflow for Deploying Infrastructure Code
Use Version Control
Run the Code Locally
Make Code Changes
Submit Changes for Review
Run Automated Tests
Merge and Release
Deploy
Putting It All Together
Conclusion
A. Recommended Reading
Books
Blogs
Talks
Newsletters
Online Forums
Index
← Prev
Back
Next →
← Prev
Back
Next →