>> I'm Armon.
>>And I'm Aaron.
>> This is The Open Source Show.
[MUSIC]
>> I'm Aaron, I'm a Cloud Advocate at Microsoft.
>> I'm Armon, Co-founder and CTO of HashiCorp.
>> Can you walk me through super briefly
what are we talking about when we say infrastructure as code?
>> Well, we normally talk about infrastructure,
it's not something that we are really defining what exists.
It's this ephemeral, people went in,
point and clicks in a console,
booted some servers versus infrastructure as code.
The idea is, how do I define all of that infrastructure;
my servers, my network,
my applications, and capture it as code.
The way I would like an app.
>> As code. Now, we're talking a little bit more in my language,
because I know what to do with code.
I know I can check it in,
push it to GitHub,
version it, I can put CI on it.
There's a whole bunch of things.
What do we mean when we say infrastructure?
Like I can put my infrastructure in next to my code.
What can I do with that?
>> So I think, to make it super, super concrete.
Let's just say I take my definition of a simple app.
I've a web server, I've a database. Let's have a load balancer.
I'm going to take those three things,
and define it in a text file.
Just like my application, I'll use my text editor,
I'll define, "Here's the things I need."
I'll declaratively say, there should be a web sever,
there should be a load balancer, there should be a database.
I'm not going to say, I need
a create a thing or if it doesn't exist, delete it.
I just say these three should exist.
I declare that it does.
Then, what I can do is
get all of those same benefits that you mentioned.
I take that file and I can check it into version control.
So now, tomorrow when I modify and say,
"Oh, actually I need two web servers."
I make my change in my text file,
I check it in again, and I'll have a commit that says,
"Oh, I can see why did Armon,
there's a Git command says adding another web server to scale up."
So I get that versioning benefit of code.
But then to your point, now I can
take them and put it into a CI pipeline.
I can automate the execution.
So just the same way,
when you hit "Compile" on your application,
you get the binary each time that it's the same.
Executes and runs in the same way.
>> If I didn't change my code?
>> Yeah. If you don't change your code, it's the same pattern,
it doesn't vary, and
you can now get that same benefit with infrastructure,
which is, if I have the same definition every time I run it,
I'm going to get the carbon copy of
that same infrastructure each time.
>> When I want to take my production environment
and maybe spin up a little quick little test environment,
or dev or staging or something like that.
I'm imagining infrastructure as code can
do better than what I've tried to do with bash.
>> Yes, dramatically better.
Yeah. I think it's not just the bash thing.
I think normally when you look at a production environment,
it's someone going in,
point and clicking, create a bunch of stuff, and now you,
as developer, say, "Hey,
I need a development environment
to test this change" and it's like,
we don't even know what production looks like,
let alone how to make you a development environment.
Versus with infrastructure as code.
I think a key value of infrastructure as code is,
when we talk about the normal,
"Hey, I'm going to go point and click on the 'Console'".
Okay, I spent three weeks
pointing and clicking and setting up production.
But now let's say to your point,
I want a dev environment, I want to test this thing.
Well, I'm not going to spend three weeks,
and even if I could, what are the odds that point and
clicking get it exactly the same as production.
>> 0.001 percent maybe.
>> On a good day.
>> On a good day. Yeah.
>> On a good day. Infrastructure as code is,
it's like here's a perfect declaration
of what production looks like.
So it's like, great,
push a button and spin up a carbon copy of
production based on the identical definition of it.
So now you can have your dev environment,
do your test, make sure things work.
When you're happy with it, tear that whole thing down.
>> That sounds awesome.
>> It's a huge, huge benefit.
You get that parody of production looks like staging,
looks like development, and there's only one source of
truth as to what all of this looks like.
>> Yeah, and it's right next to my code too. Anyone can see it.
>> Anyone can see it. Anyone can see how it's changed over time.
So if you're like, "Hey the app was 20 percent
faster last week, what changed?"
Because you treat it as code,
you can go in and see it,
what was that change history?
I can see that the commits sort of
varied the system over the last week.
Just like with an app, you'll like what worked last week?
Someone introduced a bug,
which commit added that bug.
It's the same flow that you get now for infrastructure.
>> Yeah. All right.
How do I take advantage of all this stuff?
>> So there's a few different ways of doing this.
But the end of the day you need
some tool that basically you can think of it as a compiler.
There's the language that I declare what are the resources I want.
So I say I want a web server,
database, whatever, a load balancer.
What's the compiler I give it to that actually makes that happen?
So one of the tools we make is a tool called Terraform,
and that's exactly what it does.
So you give it that declaration in a language called HCL.
It's really a human-readable.
It's meant to look like JSON,
but with less random braces all over the place.
Terraform is sort of the compiler,
so you give it to Terraform,
and when it compiles,
it's going and booting and creating a bunch of infrastructure.
So it's going to make API calls out to Azure and say, "Great.
Someone asked for a web server and a database and a load balancer.
Go create all of the stuff."
>> So that's the thing that's going to go
and apply the declaration,
the HCL for me.
>> Exactly, and I hope that was no pun intended
because it's literally "terraform apply" is the commit
>> Okay, yeah. I actually didn't know that until now.
>> We did a video actually that goes into a bit more hands-on,
if folks are interested,
there's a video about using Terraform
on Azure that we did with Azure Friday.
So that video is available if you want.
A bit more of a hands-on,
what does the code actually look like,
how do I use it in the Azure context as well.
>> Okay. Right on. What else can I do with Terraform?
Can I get started right now?
Is it open-source? Where do I go to check this stuff out?
>> Super good question. The way to think about it is,
what we're doing with infrastructure as code is just defining,
what do I want to exist?
So I think when we talk about infrastructure as code,
I think the word infrastructure I think
sometimes pigeonholes our thinking to just,
does it just boot servers for us?
But I think really if you think about the concept,
what we're trying to do is apply a life-cycle management.
We're saying, there's a set of things I need to exist.
So I got to create it. I got to update them over time.
When I don't need it anymore, I got to destroy it.
But those things can be anything.
It could be hardware devices on-prem,
it could be infrastructure as a service so VMs,
networks, load balancers, it could be platform.
So it could be, you mentioned Kubernetes.
>> Yeah.
>> I want to provision Kubernetes and I
want to deploy my app on top of it.
So there's a platform,
but we still have to manage that, which is like,
what are the apps that are supposed to run Kubernetes?
What's my replica controller settings look like?
How do I manage that? I want my Kubernetes cluster to exist,
I want my apps to exist on top of that.
That should exist within a network.
So I'm defining all these layers,
but then there's a life-cycle for all
of those. I have to create it.
I have to update it over time.
Let's say, I change my Kubernetes version from
1.8 to 1.9, that's an update.
Then if I decide I don't need
that server anymore, I have to delete it.
>> The whole stack?
>> It's the whole stack.
>> It isn't just VMs and networking?
>> The goal is you can go from nothing,
push your button and your whole data center comes up,
nuts to bolts including your application.
>> That's really cool.
>> For folks that are interested in learning more,
I'd recommend checkout, start with the Azure video,
but then checkout Terraform's website.
It's has great examples about
all the different kind of integrations that it supports,
that goes into Azure and Kubernetes and Helm.
As well as then checkout learn.hashicorp.com,
which goes from 0 to 60 on learning infrastructure as code,
how it works and getting value out of it.
>> Awesome. Well go check out that stuff.
Go check out everything else Armon was talking about as well.
In the show notes below, we've got all the links.
Please subscribe and check out
opensource.Microsoft.com for even more awesomeness.
That's it. Take everybody.
>> Thanks.
[MUSIC]