From the course: Learning Terraform

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Security group

Security group

- [Instructor] In this lesson, we'll be setting up a security group and for our purposes, you could think of this a bit like a firewall that we can just configure for our single instance. One thing we do before we set up our security group we'll need to define a VPC. That's the network infrastructure that Amazon provides, and every account by default has a default VPC, which is why we were able to define an AWS instance without actually specifying a VPC. It just put it into the default. For our security group, we'll need to get more explicit and to do that, there's a handy feature of Terraform that lets us just pull in the default values. So, the way to do it is to define another data block and the syntax is data aws_vpc, and we'll give it the name default. And all you have to say is default equals true. And now, we'll get the correct values. Now, for our security group, let's go to the bottom of the file. Let's scroll up just a little bit and our syntax here is resource…

Contents