- Terraform
- Local Command Prompt
- AWS Management Console
First we need to SSH into our machine.
We now need to create a directory to house our Terraform code, we'll call the directory
"terraform_code".
Then we create a new file for the code called main.tf by using the command 'vim main.tf'. And then add the code for creating an EC2 instance in AWS to the main.tf file.
Now we need to initialize the Terraform configuration with the 'terraform init' command. Which initializes our working directory containing the configuration files (main.tf) and installs plugins for required providers.
After initializing, we need to run the 'terraform plan' command to create an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure.
Now that we have a plan set, we can now execute that plan with 'terraform apply' which will create our instance in AWS.
Let's check the AWS management console to see if our EC2 instances has been created. Looks like it did!
Finally, we can destroy our infrastructure using the 'terraform destroy' command.
I hope you enjoyed following along if you did!