From the course: Learning Terraform

Terraform plan

- [Instructor] Before we talk about theory, we're going to jump right in and see Terraform in action by doing a Terraform run. To get started with our first Terraform run, we'll need to trigger a Terraform plan. So from your workspace, click on overview and scroll down here to start a new plan. This will take us to the runs tab, and you can see here it says plan queued. Usually pretty quickly, it'll initiate the run. And once that's complete, we can see what is represented by our starter code. We can see it says it's going to create something here. Going to open up this upper tab and get a little more detail. And if you want to look at the code, you can click the link and that'll take you to the code. At the top of our plan tab, there's a note here. It says resources, one to add, zero to change, zero to destroy. And we can go down here to see what it's actually creating. There's two items. The first one is, it says aws_instance.web. So if we open up the dropdown, this is an AWS virtual server or an EC2 instance, as it's called. There are some details spelled out here, like AMI and get_password_data false, but most of them just say known after apply. Here's a few more. And then there's another one here, which is a data object, and we can't open that. Now we have the option to confirm and apply, discard, or add a comment. But before we do any of those, let's go to our code repository and take a look. We can scroll down here, we want to be on the main branch, and let's look at main.tf. This is mostly adapted from an example in the Terraform documentation. This actually deploys a Tomcat server. And the way this works is pretty clever. It uses this filter to find the latest version of this bitami Tomcat server, and we'll explain some of these other settings a little later on. So it takes that image, and then down here, it provisions an AWS instance. And this one's just named web. Don't worry if this code is looking confusing, we're going to cover all of this in depth later. But you can see some of the information we saw. There's an AMI setting, and here it's actually pulling that from this data block up here. There's an instance type specified and tags. Let's look back at our plan and see if we can find those. So there's the AMI, but you can see it's actually filled in the value. We've got our instance type, and there's our hello world tag. And that's our Terraform plan. In the next lesson, we'll actually apply this and watch as the infrastructure is deployed.

Contents