Now we're going to look at the structure of our code. We'll look at the directory structure I (highly) recommend you stick to, as well as a naming convention that will help you manage your code in the long run.
You're free to go outside of this advice, especially if it helps you learn, but just remember that if I refer to a particular file further on in this book, or in the community during a community session, you might struggle to follow along.
The structure of our Terraform code is very simple, and very flat:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
We're going to create these files as we go along through the sections of this chapter.
Let's look at each part of the structure in a bit of detail, file by file, and determine a few details:
- The filename I (highly) recommend you use
- The AWS technology being used, or
- Whether the file is specific to Terraform
- And the tier it belongs to in the stack
This information is to help you understand where each file fits into the architecture we saw previously.
| ||EC2 Key Pairs||Security|
| ||Virtual Private Cloud||Networking|
| ||Internet Gateway||Networking|
| ||VPC Subnets||Networking|
| ||AWS Security Groups||Security|
| ||EC2 Instances||Compute|
| ||Elastic IPs||Networking|
| ||Application Load Balancer||Networking|
| ||AWS Route53||Networking|
| ||Amazon Certificate Manager||Security|
Now let's start exploring each of these files, one by one, and writing them out, from top to bottom.