Jump right in and see Terraform in action. Use the starter code to get your initial AWS VPC set up. Note: Terraform init, Terraform apply.
- [Narrator] Now that we've got that initial code written, we're ready to actually try out Terraform. So first we'll need to run the Terraform init command. And that's literally just Terraform init. And that needs to be run in the same directory, as that .tf file we just created. This will initialize Terraform, and it will look for any .tf files, it can find in the local directory. So, it should see ours, pick up the fact, that we're using A-W-S, and then automatically download, and install the additional Terraform plugin it needs, for working with A-W-S. If we had other providers to find, it would find them, and download plugins for them at this point. So, once that's done, you're really ready, to apply this code, and the command, in this case is Terraform apply. And I know we're going kind of quickly through this, I just want to point that out. We're going to circle back to all these commands, and to the code, and syntax, and go through it in detail later on. The point of this is just to get a taste, of what Terraform is like, so that you can see how powerful it is. So, I'm just going to run that Terraform apply. And you may or may not see a message, about setting your A-W-S region. If you do, just follow those instructions. I didn't, because I've already run through it. And if you've already used A-W-S for something else, you may not see it then, because it will already be configured. So, now we've run our apply, and Terraform has given us this output, which is actually a detailed description of, what it's going to do. It's saying an execution plan has been generated, and is shown below. It's going to create this resource. This A-W-S S-3 bucket that we've defined. And here's the various details, and a lot of them are not known yet, they'll be known after it's actually been created. So, it's asking us do we want to perform these actions. I'm going to say yes, and hit enter. Now Terraform is actually going out, and making those changes and you can see it's done. It happens pretty quickly. If you run into a credentials error here, go ahead and double check that A-W-S credentials file. A simple typo in that file, will cause Terraform to throw a no valid credentials error, and it can be a little bit cryptic. Also make sure that the file is just called credentials, with no file extension. Notepad will save it by default as a .txt file, so you might need to rename it. If your still struggling with that point, I'd recommend, pausing this course, and going and finding a course on A-W-S, where you can just kind of learn the details, about how to do that basic C-L-I setup. This is kind of standard A-W-S command line config, and so anything you learn in another course, should cross-apply in this case. And that's really it for our initial deployment. As I said, we'll dig in deeper to what's happening later on. But I hope this shows you, just how powerful Terraform can be. With that tiny bit of code, and just a couple of simple commands, we're already up and running, and managing a resource on A-W-S.
- Setting up Terraform
- How Terraform works
- Core Terraform commands
- Leveraging style conventions to keep code readable
- Configuring security groups
- Adding load balancers
- Using variables in your code