[MUSIC PLAYING]
DANA HOFFMAN: Hi, I'm Dana, an engineer
at Google working on Google Cloud Platform and open source
integrations.
PADDY FORAN: And I'm Paddy, an engineer at HashiCorp
on the Terraform team.
Terraform is a tool that lets you provision
your infrastructure on any cloud,
or even across multiple clouds, in a safe, easy to manage way.
DANA HOFFMAN: In the last two videos
you saw demos of Vagrant development environments
with Google Compute Engine, and Packer,
for producing Compute Engine images.
We're going to pick up where we left off last time with using
Packer to create a Compute Engine
image with our 80s-style arcade game,
Hyperspace, pre-installed and ready to go.
Continuing our story, our game has neared completion.
And now we're getting ready for our big launch.
But because we know our game is going to be viral,
we want to make sure that we can handle the load.
So rather than run Hyperspace on a single compute instance,
and hope that it can handle thousands of players,
we're going to take advantage of the architecture.
And create one image with the front end web server
and a separate image with the back end server.
And I had to do for that was make
some customizations to my Hyperspace install scripts.
And use Packer to create two images instead
of the single all-in-one image you saw in the last video.
So now that we have a scalable way to package Hyperspace,
let's talk about how we can deploy it
to Google Cloud Platform.
Paddy, any idea how we should go about that?
PADDY FORAN: Actually Dana, I think I know just the thing.
Today we're going use another HashiCorp tool called
Terraform, to help us deploy Hyperspace with this new split
front end and back end approach.
Terraform is a tool that allows you
to write declarative configuration
files describing the state of your infrastructure.
It allows to provision resources such as VMs, disks, networking
configurations, and databases.
And it works with many Cloud providers,
including Google Cloud Platform.
But you already knew that, right Dana?
DANA HOFFMAN: Yeah, you could say I'm
pretty familiar with Terraform.
I'm the lead engineer at Google working on our Terraform
integration with Google Cloud Platform.
We've heard from plenty of our customers,
that they really like using Terraform
to manage GCP and appreciate that Terraform has support
for multiple cloud providers.
With Terraform, users can manage GCP resources spanning
many of our products such as Compute Engine, Cloud
Storage, IM, Cloud SQL, CLOUD DNS, et cetera.
But for this demo, we're going to focus on Compute Engine.
So let's get started.
PADDY FORAN: The first thing you want to do
is go to terraform.io and download
the software for your platform.
Refer back to the Vagrant and Packer videos
for setting up your GCP project.
For this demo we're going to use Terraform from an existing
Google Compute Engine instance.
Navigating to the list of GC images,
you can see that I already have two separate images.
One for the front end and one for the back.
OK, before we step through Terraform config file,
let's show you how to use Terraform plan
to see what resources Terraform will create.
In this case we don't have any of our infrastructure
provisioned.
And as you can see, Terraform is expecting provisions
to set them new resources with zero changes and zero
deletions.
When we're happy with what we expect Terraform to do,
we can then run Terraform apply to perform
the actual infrastructure provisioning.
While that's provisioning let's walk through that configuration
file.
This first section of the file contains the GCP project
parameters.
I haven't specified a service account key in this example,
because I'm running Terraform on a Compute Engine instance.
And Terraform is smart enough to pull credentials
from the metadata service.
Next, you see I have a resource specifying my back end GC
virtual machine instance, including the name, zone
location, and machine type.
Here is the snippet where I've specified
that I want this instance to use the back end
image built with Packer.
Skipping down to the stanza for our front end VM instances,
you can see that I've specified the other package image.
But we want three of these instances.
So we need to set its count to three.
I'm also provisioning a GCU load balancer
using a target pool and forwarding rule.
Using the output parameter, I can tell Terraform to print out
the load balancers virtual IP address when
it's completed provisioning all of our resources.
DANA HOFFMAN: Flipping back to the other terminal,
you can see that Terraform has indeed finished
provisioning our resources.
And here's the front end IP.
Let's put that IP address into our browser
and see what happens.
PADDY FORAN: It works, awesome.
DANA HOFFMAN: Yay.
[MUSIC PLAYING]
PADDY FORAN: OK well let's go ahead and delete
all of these resources.
We can easily do that with Terraform destroy.
DANA HOFFMAN: So that wraps up the demo.
While we only showed you a subset of GCP services
in the demo, there's enough I think for you
to get started with the others.
So Paddy, how do users get started of a Terraform?
PADDY FORAN: Simple enough Dana.
Just go to terraform.io check out the docs,
and keep track of our github repository, where
we're constantly adding new GCP resources to Terraform.
This has been fun Dana, and I've really enjoyed
working with you on Terraform.
DANA HOFFMAN: Thanks Paddy, I've enjoyed working with you too.
And I'm looking forward to adding new resources
and features over time.
Thanks to all of you for watching us today.
We hope you give Terraform and GCP a try.
And don't forget to subscribe to the channel
so you can catch the next video in the HashiCorp corp series.
Thanks for watching make sure to check out
some other videos in this series as well as the playlist
and don't forget to subscribe.