Terraform ECS with ec2 launch type

how to define ec2 instance along with AMI image id , instance type , keypair , vpc security group for ECS in terraform

should i use ec2 autoscaling along with launch template . and how to be identified in ECS cluster
and does the container need seperate subnet than subnet of ec2 intstances
for ec2 instance subnet
for container subnets