In this story, we will learn to deploy both Linux and Windows EC2 Instances in AWS using Terraform.
And also, we will learn how to deploy applications or configure settings at boot time (bootstrapping).
1. Requirements
To deploy a Virtual Machine in AWS, we will need:
- AWS Credentials
- Create an AWS Key Pair
- Define AWS and Terraform Providers
- Create a VPC, Subnet and other network components
- Create Operating System Versions Variables
- (Optional) Create a Bootstrapping script to install and/or configure applications
- Create a Security Group
- Create the EC2 Instance (Virtual Machine)
- (Optional) Request a Public IP and attach to the EC2 Instance
Note: For clarity, we prefer to define separate files, however, you can put together the code, using the traditional main.tf, variables.tf and output.tf layout.
2. AWS Credentials
Before creating our AWS EC2 Instance, we will need AWS Credentials to execute our Terraform code.