<span>Infrastructure as Code (IaC) is gaining popularity and developers today are deploying their application environments through IaC tools to the cloud. However, it can become extremely difficult and time-consuming to manage the state of the infrastructure that has been deployed. This book will pr
Mastering Terraform: A practical guide to building and deploying infrastructure on AWS, Azure, and GCP
β Scribed by Mark Tinderholt
- Publisher
- Packt Publishing Pvt Ltd
- Year
- 2024
- Tongue
- English
- Leaves
- 642
- Edition
- 1
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
Learn from Terraform expert Mark Tinderholt and excel in designing and automating your infrastructure and CI/CD pipelines with Terraform across major cloud platforms and paradigms
Key Features
- Build comprehensive end-to-end solutions with Terraform using VMs, Kubernetes, and Serverless
- Integrate Terraform with other HashiCorp products and common tools such as Packer, Docker, Kubernetes, and Helm
- Streamline your operations using Gitflow powered by GitHub Actions CI/CD pipelines
Book Description
Advancements made in cloud technology and automation tools have led to increased challenges in defining and managing your infrastructure or app environment as code on your chosen cloud platform, integrating security, managing microservices complexity, and so on. This book takes a learning-by-doing approach to teach you how to employ Terraform features to develop efficient cloud infrastructure using real-world scenarios and best practices.
The book begins by introducing you to Terraform's architecture, both as a command-line tool and a programming language, HashiCorp Configuration Language (HCL). You'll discover best practices, usage, and architectural patterns and implement Terraform on virtual machines (VMs), Docker/Kubernetes, Serverless, and multiple cloud platforms such as AWS, Azure, and GCP. The chapters also show you how to industrialize your CI/CD pipeline by integrating Terraform with other popular technologies to build, provision, deploy, and manage cloud infrastructure. You'll gain a clear understanding of security, monitoring, troubleshooting, and cost optimization and be able to apply the concepts you've learned when preparing for Terraform Associate certification exams.
By the end of this book, you'll be equipped to confidently build, automate, and deliver your infrastructure and CI/CD pipelines in cloud-based applications.
What You Will Learn
- Explore Terraform architecture and configurations in depth
- Integrate Packer with Terraform for VM-based solutions
- Containerize apps with Docker and Kubernetes
- Explore GitOps and CI/CD deployment patterns
- Transform existing applications into serverless architectures
- Migrate and modernize legacy apps for the clou
- Implement Terraform on AWS, Azure, and GCP
- Use Terraform with teams of varying size and responsibility
Who this book is for
This book is for Devops engineers, cloud engineers, platform engineers, infrastructure engineers, site reliability engineers, developers, and cloud architects who want to utilize Terraform to automate their cloud infrastructures and streamline software delivery. Prior knowledge of cloud architecture, infrastructure, and platforms, as well as Terraform basics, will help you understand the topics present in this book.
β¦ Table of Contents
Mastering Terraform
Foreword
Contributors
About the author
About the reviewers
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Share your thoughts
Download a free PDF copy of this book
Part 1: Foundations of Terraform
1
Understanding Terraform Architecture
Understanding Terraform architecture
The plan
Configuration language
Modularity
Understanding Terraform state
State file
Partial resource management
Understanding how to build and consume modules
Module design
Consuming modules
Understanding how to use the CLI effectively
init
validate
workspace
plan
apply
destroy
Summary
2
Using HashiCorp Configuration Language
Resources and data sources
Resources
Data sources
Locals and types
Locals
Primitive types
Collection types
Complex objects
Inputs and outputs
Inputs
Outputs
Meta-arguments
Provider
Depends on
Lifecycle
Loops and iterations
For each
For expressions
Expressions
Conditional expressions
Splat expressions
Dynamic blocks
Functions
Numeric functions
String functions
Collection functions
Encoding functions
Filesystem functions
Date/time functions
Hash/crypto functions
IP network functions
Type conversion functions
Summary
3
Harnessing HashiCorp Utility Providers
Working with reality
Randomizing
Working with time
Adaptation and integration
Accessing external resources
When you want to make something from nothing
Making HTTP requests
Filesystem
Reading and writing local files
Templating files and directories
Generating file archives
Operating system and networking
Generating certificates and SSH keys
Generating CloudInit configuration
Configuring DNS records
Summary
Part 2: Concepts of Cloud Architecture and Automation
4
Foundations of Cloud Architecture β Virtual Machines and Infrastructure-as-a-Services
Understanding the key concepts of networking
Networking
Subnets
Routing
Network security
Network peering
Service endpoints
VPN and Direct Connect
Understanding the key concepts of compute
Disks
Network Interface Cards (NICs)
Linux versus Windows
Auto-scaling
Understanding the role of virtual machine images
Static virtual machines
Using configuration manager
Custom virtual machine images
Build versus bake
Summary
5
Beyond VMs β Core Concepts of Containers and Kubernetes
Understanding key concepts of container architecture
Containers
Leveraging Docker to build container images
Writing a Dockerfile
Building a Docker image
Running Docker images
Working with container registries
Docker Hub
Understanding key concepts of container orchestration and Kubernetes
Kubernetes architecture
Configuration and secrets
Continuous deployment (CD)
Understanding Kubernetes manifests
Kubernetes manifests
Configuration and secrets
Using the Kubernetes provider to provision Kubernetes resources
The Kubernetes Terraform provider
Kubernetes resources
Evaluating the trade-offs
Leveraging the Helm provider to provision Kubernetes resources
What is Helm?
The Helm Terraform provider
Summary
6
Connecting It All Together β GitFlow, GitOps, and CI/CD
Understanding key concepts of GitOps
Understanding CI/CD
Anatomy of pipeline
Leveraging GitHub for source control management
Gitflow
GitHub flow
Using GitHub Actions for CI/CD pipelines
Virtual machine workloads
Container workloads
Serverless workloads
Terraform tools
Summary
Part 3: Building Solutions on AWS
7
Getting Started on AWS β Building Solutions with AWS EC2
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Packer
Terraform
Automating the deployment
Packer
Terraform
Summary
8
Containerize with AWS β Building Solutions with AWS EKS
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Docker
Terraform
Kubernetes
Automating the deployment
Docker
Terraform
Kubernetes
Summary
9
Go Serverless with AWS β Building Solutions with AWS Lambda
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Terraform
Application code
Automating the deployment
Terraform
Deployment
Summary
Part 4: Building Solutions on Azure
10
Getting Started on Azure β Building Solutions with Azure Virtual Machines
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Packer
Terraform
Automating the deployment
Packer
Terraform
Summary
11
Containerize on Azure β Building Solutions with Azure Kubernetes Service
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Docker
Infrastructure
Kubernetes
Automating the deployment
Docker
Terraform
Kubernetes
Summary
12
Go Serverless on Azure β Building Solutions with Azure Functions
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Terraform
Application code
Automating the deployment
Terraform
Deployment
Summary
Part 5: Building Solutions on Google Cloud
13
Getting Started on Google Cloud β Building Solutions with GCE
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Packer
Terraform
Automating the deployment
Packer
Terraform
Summary
14
Containerize on Google Cloud β Building Solutions with GKE
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Docker
Infrastructure
Kubernetes
Automating the deployment
Docker
Terraform
Kubernetes
Summary
15
Go Serverless on Google Cloud β Building Solutions with Google Cloud Functions
Laying the foundation
Designing the solution
Cloud architecture
Deployment architecture
Building the solution
Terraform
Application code
Automating the deployment
Terraform
Deployment
Summary
Part 6: Day 2 Operations and Beyond
16
Already Provisioned? Strategies for Importing Existing Environments
Importing individual resources
The import command
Import block
Importing multiple resources
Identifying resources to import
AWS
Azure
Google Cloud Platform
Importing existing environments
Terraformer
The Azure Export Tool
Limitations
Best practices
Blast radius
Sometimes moving slowly is moving fast
Blue/green deployment
Summary
17
Managing Production Environments with Terraform
Operating models
State management
Standalone application
Shared infrastructure
Shared services
Applying changes
Patching
Upgrading providers
Upgrading modules
Refactoring
Planning for failure
Breakfixing
Apply-time failures
Removing from state
Importing into state
Summary
18
Looking Ahead β Certification, Emerging Trends, and Next Steps
Preparing for the exam
Scope and topics
Preparation
Terraform Cloud
Features
Whatβs next?
CDK
Terraform Stacks
Summary
Closing statement
Index
Why subscribe?
Other Books You May Enjoy
Packt is searching for authors like you
Share your thoughts
Download a free PDF copy of this book
π SIMILAR VOLUMES
<span>Infrastructure as Code (IaC) is gaining popularity and developers today are deploying their application environments through IaC tools to the cloud. However, it can become extremely difficult and time-consuming to manage the state of the infrastructure that has been deployed. This book will pr
AWS Lambda is a new compute platform in the cloud that offers a zero-administration experience for back-end developers and uses microservices to automatically manage compute resources for you. <br>This book is your one stop shop to learn and master anything and everything there is to know about AWSs
<p><span>Gain a thorough understanding of DevOps concepts and learn to deploy AWS DevOps services in an organization. This book covers AWS DevOps deployment and building applications and services for enhanced performance.</span></p><p><span>A Complete Guide to DevOps with AWS </span><span>will show
<p><span>Leverage Terraform's capabilities to reuse code, write modules, automate deployments, and manage infrastructure state</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Perform complex enterprise-grade infrastructure deployments using Terraform v1.0, the latest version of Terra