Cloud Infrastructure: Startup to Scale

Service Locals, Variables, & Outputs

Erik Reinert
TheAltF4Stream
Cloud Infrastructure: Startup to Scale

Lesson Description

The "Service Locals, Variables, & Outputs" Lesson is part of the full, Cloud Infrastructure: Startup to Scale course featured in this preview video. Here's what you'd learn in this lesson:

Erik adds the locals, outputs, and variables configuration files for the service.

Preview
Close

Transcript from the "Service Locals, Variables, & Outputs" Lesson

[00:00:00]
>> Erik Reinert: So we've gone through the main thing now let's go ahead and grab the other small things that we need. So I'm going to create a locals TF file and again, you can kind of tell the standard patterns that like, you know, a lot of. At least I know of a lot of terraform users use with like variables, tf locals TF outputs, TF data tf.

[00:00:30]
It's just a common convention. It's not something you have to do. So we have our locals file, and just really quickly, I didn't really go over this, but we wanna make it so that we have a standardized name for the service and all of its resources that it creates.

[00:00:48]
But we don't want it to be the cluster name because that's just dev. We want to separate that in some shape or form. So in this case what we're doing is we're saying cluster name name. So you could do the same thing with environment where you could say you want the full name to be dev name or something else.

[00:01:08]
If you don't want it to be cluster name, you can put whatever else you want there. But the only thing I want you to understand is that this is an easy way to take a value or two values, combine them, and then just use this value for everything else.

[00:01:21]
So in my module I'm using full name for everything to name it. Then that will combine these two values and make it so that it's easier to read in the environment. Cool. Variables. Pretty straightforward. Again, we've gone through variables a whole bunch. The only thing I want to note is these lines right here, really.

[00:01:44]
So two things, one, we can actually run a service without even giving it an image parameter. The idea here is maybe I want to configure a service and not push to it yet, or maybe I just want to get it up and running or something like that. I'm not really worried about giving it code yet.

[00:02:02]
This is a flexible option that you can basically give yourself. Or you can say, well underneath, just run nginx, run some simple image just so that the deployment works, the service is up and running. You don't have to really care about what's inside of it. Now we are going to provide it our own image because of what we're trying to do.

[00:02:20]
And this is the second part of what I wanted to mention, which is it's okay to deploy broken services. I know that sounds terrible to sound, but the only caveat I give to that is if you're going to deploy a broken service, have the intention of Fixing it.

[00:02:36]
We have some infrastructural things where I work where there isn't code there yet, but, but they can create a service and get the terraform out of the box, the service out of the box, everything running. But if we are provisioning the repository at the exact same time we are provisioning the service in Amazon, it's not gonna run cause there's no source code for it yet.

[00:03:01]
So what we actually do is we just let it fail. It's like just let it fail for now it's fine. Because then what'll happen is the developers will go, they'll push up their code, the repo or the deployment will run and the deployment will grab it and go no, no, no, this is the act.

[00:03:16]
And then push up that change and then everything comes online and starts working. Now we don't normally say deploy that to production, but that at least gets them set up with everything before they write a single line of code. So that by the time they write code they're just shipping, they're not worried about setting up more stuff and will it work or not or whatever.

[00:03:36]
So in this scenario we are actually going to deploy it and it will be broken, but then we'll fix it and it will auto resolve itself basically and then we'll be fine. So, so again we put that in there just to be helpful if we want to make it so that it is a successful deployment, but it doesn't mean we have to.

[00:03:54]
Some other things in here are just like log retention, kind of important, memory, CPU as well up here, all of the basics, pretty much everything we need to configure a service. So then we're going to do one more which is our outputs TF and we're going to save this.

[00:04:14]
And there we go. This is just all the stuff we need from a service, all the roles and everything else if we wanna use them later.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now