How to Deploy AWS EC2 Instance with Terraform — No Fuss, No BS

Alright, here's the deal. You wanna deploy an EC2 instance with Terraform, huh? Well, you've come to the right place.

Here's an example script that uses locals for EC2 instance parameters and a data source for AMI ID retrieval based on the owner and AMI name.

 # Set up locals for EC2 instance parameters
locals {
subnet_id = "subnet-12345678"
security_group_id = "sg-12345678"
instance_type = "t2.micro"
iam_instance_profile = "ec2_iam_role"
name =…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store