This post is based on terraform tutorial Build infrastructure | Terraform | HashiCorp Developer
Make sure AWSCli being installed and configured correctly (aws configure). Make sure IAM user are configured with AWS role, AWS Access key ID and AWS Secret Access Key.
Use the ami catalog, to determine the ami ID, then after make necessary changes run the init
To solve this VPC and subnet needs to be created first.
Make small change to the EC2 instance of terraform file.
Rerun the terraform init, terraform plan, terraform validate before rerunning terraform apply, then type yes.
To clean up the experiment to avoid paying more, start by desstroying the instance then the VPC.