Preface

Google Cloud has adopted Terraform as the standard Infrastructure-as-Code (IaC) tool. Thus, a good understanding of Terraform is essential for any cloud architect and engineer working on Google Cloud. Yet no specific resources are available that focus on how to use Terraform on Google Cloud.

This book is the first book that teaches the reader about Terraform specifically for Google Cloud. We will take you on a journey from the basic concepts to deploying complex architectures using Terraform. Using easy-to-understand code examples, we will show you how to authenticate Terraform in Google Cloud, teach you all the essential concepts of the Terraform language as applied to Google Cloud, and deploy complete working architectures at the push of a button. We will also show you how to improve your Terraform workflow using Google Cloud-native and third-party tools.

By the end of this book, you will have gained a thorough understanding of Terraform and how to use it on Google Cloud. You will have learned how to develop effective Terraform code, build reusable modules, and utilize public domain Terraform modules to deploy on Google Cloud faster and more securely.

Who this book is for

If you are working in Google Cloud and want to become more efficient in provisioning and managing Google Cloud infrastructure, this book is for you. We teach you the rationale of IaC and guide you on how to use Terraform as the IaC tool for Google Cloud. We will take you on a journey from provisioning a virtual machine using a single file to deploying multi-tiered architecture in different environments at the proverbial push of a button.

What this book covers

Chapter 1, Getting Started with Terraform on Google Cloud, introduces the concept of IaC before provisioning virtual machines using four methods of authenticating Terraform in Google Cloud.

Chapter 2, Exploring Terraform, details how Terraform uses state information to decide what actions to take. It also explains the use of meta-arguments, which enable you to write effective Terraform code.

Chapter 3, Writing Efficient Terraform Code, introduces specific Terraform constructs to help you develop efficient Terraform code and explains how to expose Terraform state information.

Chapter 4, Writing Reusable Code Using Modules, explains how to develop Terraform Modules to reuse and share Terraform code.

Chapter 5, Managing Environments, compares the two primary methods to manage multiple environments using the same Terraform code base.

Chapter 6, Deploying a Traditional Three-Tier Architecture, uses the concepts introduced so far to build a complete three-tier architecture.

Chapter 7, Deploying a Cloud-Native Architecture Using Cloud Run, continues to apply the concepts learned to deploy a cloud-native, completely serverless architecture.

Chapter 8, Deploying GKE Using Public Modules, describes how to use two of the most common Public Modules to deploy a development and production GKE cluster using only differing variable assignments.

Chapter 9, Developing Terraform Code Efficiently, introduces four of the most common tools to improve your Terraform workflow.

Chapter 10, Google Cloud Integration, shows how to use Cloud Build to create a CI/CD pipeline for Terraform and introduces a unique Google Cloud feature for importing existing cloud resources into the realm of Terraform.

To get the most out of this book

You should have a basic knowledge of Google Cloud, including how to provision Google cloud resources using the web console and the Google Cloud command-line interface, gcloud. We use Ubuntu and the Bash shell but Terraform and gcloud work equally well on macOS using zsh and on Windows using PowerShell.

Download the example code files

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Terraform-for-Google-Cloud-Essential-Guide. If there’s an update to the code, it will be updated in the GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/yzxje.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “By convention, we have three files: main.tf, which contains the main code, variables.tf, which defines the variables that need to be passed to the module, and outputs.tf, which contains the information passed back to the calling module.”

A block of code is set as follows:

output "public_ip_address" {
  value = var.static_ip ? google_compute_instance.this.network_interface.0.access_config.0.nat_ip : null
}
output "private_ip_address" {
  value = google_compute_instance.this.network_interface.0.network_ip
}
output "self_link" {
  value = google_compute_instance.this.self_link
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

module "deny_ssh_ingress" {
  source       = "terraform-google-modules/network/google//modules/firewall-rules"
  version      = "5.2.0"
  project_id   = var.project_id
  network_name = module.network.network_name

Any command-line input or output is written as follows:

$ terraform init
$ terraform apply
$ terraform state list

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Using Web Console, go to Cloud Overview | Activity, and look at the…”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share Your Thoughts

Once you’ve read Terraform for Google Cloud Essential Guide, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application. 

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781804619629

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset