Check out a free preview of the full Enterprise DevOps & Cloud Infrastructure course

The "Creating the Service Repo" Lesson is part of the full, Enterprise DevOps & Cloud Infrastructure course featured in this preview video. Here's what you'd learn in this lesson:

Erik focuses on service infrastructure automation. One workspace will be configured to work with multiple cloud providers to simplify the architecture. The service repository is created and represents a service created by the development team

Preview
Close

Transcript from the "Creating the Service Repo" Lesson

[00:00:00]
>> So we're gonna go ahead and we're gonna do a couple of different things here really quickly. The next thing we really need to focus on is our service infrastructure automation. So if I go here, right, we see that we've gotten pretty far, honestly, right? We got TFP now, we got GitHub now, we got network, we got cluster.

[00:00:18]
We don't have an opinionation around our services, though, we have no automation around that. So even though we have an ECS cluster up and running, we don't actually have automation for that. Now, this is completely speculative. You can do this different ways, it's totally up to you. My personal opinion is pick the scenario that fits best for you, okay?

[00:00:40]
What we're gonna do is, we're gonna make one workspace that in the future could talk to multiple cloud providers, okay? However, if you wanted, you could also have workspaces per cloud provider and follow that same pattern just like we do with the other workspaces, right? So this decision is kind of up to you, right, but it is something that to consider.

[00:01:03]
To make it quick for us, I just kept everything in one repo. So let's go to GitHub, because remember, we need a repository created for the repo that we're trying to copy from. So we're gonna go to, actually, sorry, we're first going to pull, make sure we've always got our recent changes because we don't want to make changes accidentally, [LAUGH] when we don't mean to.

[00:01:24]
And then I'm gonna create a new branch. Again, I'm gonna call this feature/add-service-repo. And then I'm gonna go to my locals.tf, right? And I'm gonna copy and paste from the repo. Again, make sure that the visibility is set to public if you don't see it set to public.

[00:01:48]
One other thing to note, this has actually got a go gitignore_template. Because it's a go so, this is our actual service, right? This isn't automation, this is our actual service, right? So what I'm gonna do is, I'm gonna create that example product service, right? That's it, validate, Feature/added-service-repository.

[00:02:18]
Push it. Gh pr create. Go to our second branch or our second pr. And again, we might see some things that are updating, don't worry about it. Focus on the things that we're creating, which are these two repositories. They look good, cool. Squash and merge, Beautiful. When you're really flying, that's how quick it is.

[00:03:03]
So yeah, cool. All right, now while this pipeline, actually no, we need to wait for this pipeline, my apologies. Yeah, actually, while this pipeline is running, I want you guys to also pull up the Frontend Masters ECI service repository. Now, this repository is the actual service repo where the code exists for the service that we're gonna be trying to deploy here.

[00:03:32]
Realistically, you wanna copy pretty much everything in this repository. So all the GitHub stuff, the config stuff, the gitignore, all of this needs to be copied, right? And so once our repository is created, we're gonna do that. So if you ever find yourself in a circumstance like this where it's just taking a while and you're like, I don't know what to do, you should probably just let it run.

[00:03:58]
The reason for that is that if you cancel it while it's running, there might be state going on. I'm sorry, there might be state that is still being updated or stuff like that. So if that's the case, then it you could potentially cancel during the middle of those changes, so I would let it just run.

[00:04:18]
There we go, i finally happened again. It just took a few seconds, no big deal. Yeah, okay, so if there was a TF cloud outage right now then we would not be able to finish. [LAUGH] And just to be fair, so yeah. Okay, cool so now we're applying.

[00:04:31]
Applies normally go quicker because plants have to go look up stuff check to see if things have changed all that kind of stuff whereas applies can really just kinda do what they need to. I'm just gonna keep refreshing here. There we go, here we go, created awesome. So all of our repositories are created.

[00:04:50]
So now I'm gonna clone it, right? I just created my service repo. I'm going to do git checkout really quickly in my GitHub repo, pull my changes so that I'm up to date, right? And then I'm gonna go and I'm gonna clone my last repo that we need for the course, which is my ECI service repository.

[00:05:08]
And so here, again, we're gonna move really fast because there's a few things we need to copy. The first one is the GitHub workflows file. Now we are gonna be using GitHub workflows underneath the hood, so it will be good of you to kind of get comfortable with this bit, and look at what we've got here.

[00:05:27]
The first thing to note is that you'll see a registry name here. This is unique to you guys. So this registry name, you will have to update with the account ID of your account, right, you cannot use my account to push images. But pretty much everything else but outside of this will handle the deployment and the configuration of the service, and I'll show you that in a second.

[00:05:49]
So I'm gonna go ahead and do new directory .github. Inside of that, new directory workflows. Inside of that, new file, main.yaml. I'm gonna paste in this whole thing. Now again, for me, this will work. For you, however, this value right here needs to be the value, sorry, this value right here needs to be the value of your account, right, so this is your account number basically.

[00:06:18]
So let's go ahead and save that, all right, and then let's get the other file. Now again, these are all related to the service itself. So we're gonna go to configs next. Remember how I told you that we could keep the configuration of the service with the service?

[00:06:36]
Well, this is how we're doing it, at least for this approach. Now this may not be the approach you want to take in an enterprise scenario, right? We can kind of say, okay, hey, let's make some way of configuration possible. And then when we run the pipeline, go get that data and apply it.

[00:06:54]
So the only thing I really want you to take away here is that, we have separated configurations we've put them somewhere else, right, somewhere is up to you. It can be Doppler, it can be Terraform, it can be whatever you want, really. But we have separated the configs so that they can run with the pipeline, okay?

[00:07:13]
So what I'm gonna do is, is I'm gonna copy this, new file, main.conf and I'm gonna paste this in, right? Now I have an actual configuration for my services. That means that my service is expecting a Frontend Master instructor, a Frontend Master location, and a Frontend Master version value or variables, right?

[00:07:35]
And then the rest of it is pretty straightforward. It's a gitignor, Which already was kind of populated a bit. Yeah, so exact same thing. Docker file, so we are using Docker, so if you guys are curious and how we're actually, building the image, I would recommend looking at the Docker file, come on Docker file, Right, paste that in.

[00:08:11]
Again the the contents of these files are irrelevant. go.mod, And then finally the main.go. And by the way, I wanna make a quick shout out to my coworker, she was actually the wonderful person who created this example service for me. So, [LAUGH] shout out to him, he's a wonderful developer and super nice friends, so thank you.

[00:08:43]
Cool, so we'll save all that. And now, we basically have our repository set up. We want to achieve the ability to run this in Github actions, build the image, push it to our ECR, right, and then also update our configuration files as needed, right? So what I'm gonna do is I'm gonna do git checkout -b feature/initial-commit, right, my initial commit.

[00:09:15]
And then I'm just gonna do this, And add all my files, right? So I'm just adding all my files basically, let's go ahead and just commit these first because we need to create some automation. So we'll say feature added all source files. The reason why we're doing this first is because our automation hasn't been necessarily created yet, right, so we need to make sure that we do that now.

[00:09:40]
We just created the service repo, and that gives you an example of how all that is wired up. But we need to create an automation repository for actually handling the process of doing our service infrastructure you. So I've gone ahead and showed you how to set up a service, right?

[00:09:59]
So let's now go ahead and make it so that that service can exist inside of automation.

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