
Getting Started with Terraform - Second Edition
Manage production infrastructure as a code
作品简介
Key Features
An up-to-date and comprehensive resource on Terraform that lets you quickly and efficiently launch your infrastructure
Learn how to implement your infrastructure as code and make secure, effective changes to your infrastructure
Learn to build multi-cloud fault-tolerant systems and simplify the management and orchestration of even the largest scale and most complex cloud infrastructures
Book Description
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.
Kirill Shirinkin is an IT consultant who focuses on Cloud technologies and DevOps practices. He has worked in companies of different sizes and areas, from an online language learning leader to a major IT provider for the global travel industry and one of the largest management consultancies. He is also a cofounder of online mentorship platform mkdev.me, where he leads a team and teaches his students all about DevOps.
作品目录
Getting Started with Terraform
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Infrastructure Automation
What is Infrastructure as Code and why is it needed?
Declarative versus procedural tools for Infrastructure as Code
Infrastructure as Code in the Cloud
Requirements for infrastructure provisioner
Supports a wide variety of services
Idempotency
Dependency resolution
Robust integration with existing tools
Platform agnosticism
Smart update management
Ease of extension
Which tools exist for infrastructure provisioning?
Scripting
Configuration management
CloudFormation/Heat
Terraform
A short overview of Terraform
Journey ahead and how to read this book
Summary
Deploying First Server
History of Terraform
Preparing work environment
The many Terraform providers
Short introduction to AWS
Using Elastic Compute Cloud
Creating an instance through the Management Console
Creating an instance with AWS CLI
Configuring AWS provider
Static credentials
Environment variables
Credentials file
Creating an EC2 instance with Terraform
Working with state
Handling resource updates
Destroying everything we've built
Summary
Resource Dependencies and Modules
Creating an AWS Virtual Private Cloud
Understanding dependency graph
Playing with Terraform graphs
Controlling dependencies with depends_on and ignore_changes
Making sense of our template
Removing duplication with modules
Configuring modules
Retrieving module data with outputs
Using root module outputs
Summary
Storing and Supplying Configuration
Understanding variables
Using map variables
Using list variables
Supplying variables inline
Using Terraform environment variables
Using variable files
Configuring data sources
Providing configuration with template_file
Providing data from anywhere with external_data
Exploring Terraform configuration resources
Taking a quick look at Consul
Summary
Connecting with Other Tools
Returning data with outputs
Testing servers with Inspec
Provisioners
Provisioning with local-exec and Ansible
Provisioning with Chef
Provisioning with remote-exec and Puppet
Uploading files with a file provisioner
Reprovisioning machines with null_resource
Using third-party plugins
Summary
Scaling and Updating Infrastructure
Counting servers
Bringing in high availability
Load balancing and simulating conditionals
Immutable infrastructure
Baking images with Packer
Rolling out AMI upgrades with Terraform
Performing blue-green deployments
Refreshing infrastructure
Importing resources
Summary
Collaborative Infrastructure
Version control with Git 101
Moving templates to Git
Protecting secrets in a Git repository
Storing state files remotely
Connecting remote states together
Storing modules remotely
Locking state files with Terragrunt
Moving infrastructure updates to the CI pipeline
Integration testing of Terraform modules
Summary
Future of Terraform
Infrastructure as code and Terraform replacements
Learning AWS and compiling Terraform
Learning Consul
Provisioning and configuration management
Immutable infrastructure
Collaboration and CI/CD
The many tools around Terraform
The rapid development of Terraform
Closing thoughts on the future of Terraform
Summary