huevos-y-bacon / tf-ec2-instance

Easy Terraform AWS EC2 Instance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quick Terraform EC2 Instance

  • Create an EC2 instance (Latest Amazon Linux 2) in AWS in a chosen VPC and subnet (run bash script to populate locals!)
  • Create a security group, role, instance profile, etc.

NOTE - STATE IS STORED LOCALLY

Steps

  1. Prepare the necesary subnet locals using the script
    • get_vpc_and_subnet.sh
      • NOTE: this script is used to generate the vpc_subnet.tf file
    • Filter subnets by name with the first argument
      • e.g. ./get_vpc_and_subnet.sh private
  2. Run tfinit, tfplan, tfapply, etc as usual

Instance State

Three scripts available to control the instance's state:

  1. ./instance_start - Start the instance
  2. ./instance_stop - Stop the instance
  3. ./instance_state - Check the current state of the instance

Cleanup

  1. Run ./cleanup.sh to initiate cleanup.
  2. It will first destroy the TF resources (after confirmation), after which it will delete local generated config and all .terraform* files (after another confirmation)

About

Easy Terraform AWS EC2 Instance


Languages

Language:HCL 52.3%Language:Shell 47.7%