Originally published at: Terraform VPC and EC2 example - Computer How To
Terraform basic VPC and EC2 example: main.tf provider “aws” { region = var.region } resource “aws_instance” “Server” { instance_type = var.inst_type ami = var.ami key_name = var.key_name subnet_id = module.vpc.public_subnets[0] vpc_security_group_ids = [aws_security_group.EC2_security.id] tags = { “Name” = “EC2 Server” } depends_on = [ module.vpc.my_vpc ] } vpc.tf module “vpc” { source = “terraform-aws-modules/vpc/aws” version…