EC2 with Terraform

Simple Terraform template to create an AWS EC2 Instance.

View Codebase »

This template will create a single EC2 instance with Terraform. The repository documents what the files do and what commands to run in order to successfully provision the EC2 instance.

Usage

  1. Insert AWS credentials to dev.conf and dev.tfvars
  2. Add the S3 Bucket where the .tfstate will be stored in dev.conf
  3. Pick your ami ID and copy it into main.tf
  4. Copy your key name into main.tf
  5. Add your security group(s) into main.tf (optional)
  6. Run the following commands

Initialize Terraform with our config:

terraform init --backend-config=config/dev.conf

Output the plan:

terraform plan --var-file=config/dev.tfvars

Terraform will check the current state and attempt to match the desired state.

Save the plan to a file:

terraform plan -out myplan --var-file=config/dev.tfvars

Apply the changes:

terraform apply myplan