title: Unable to utilize the existing pem file to create EC2 instanceby terraform
body: <p>I am wondering how to stop the infinite loop in the error message so that it creates AWS EC2 instance?</p>
  
  <p><strong>Terraform code below:</strong></p>
  
  <pre><code> provider "aws" {
    region = "${var.location}"
  }
  
  resource "aws_instance" "ins1_ec2" {
    ami           = "${var.ami}"
    instance_type = "${var.inst_type}"
  
    tags = {
      Name = "cluster"
    }
    provisioner "remote-exec" {
      inline = [
        "hostnamectl set-hostname centos-76-1",
      ]
    }
  }
  
  resource "aws_eip" "ins1_eip" {
    instance = "${aws_instance.ins1_ec2.id}"
    vpc      = false
  }
  
  resource "aws_instance" "ins2_ec2" {
    ami           = "${var.ami}"
    instance_type = "${var.inst_type}"
  
   provisioner "remote-exec" {
      inline = [
        "hostnamectl set-hostname centos-76-2",
      ]
    }
  
    tags = {
      Name = "cluster"
    }
  }
  
  resource "aws_eip" "ins2_eip" {
    instance = "${aws_instance.ins2_ec2.id}"
    vpc      = false
  }
  </code></pre>
  
  <p>It <strong>errors out</strong> with the below message:</p>
  
  <pre><code>* aws_instance.ins2_ec2: timeout - last error: ssh: handshake failed: agent: failed to list keys
  * aws_instance.ins1_ec2: timeout - last error: ssh: handshake failed: agent: failed to list keys
  </code></pre>
  
  <p>I have a pem file on my laptop which I can get it on my AWS Build server, so I can use key_name in EC2 instance creation? The pem file name as "test.pem" which I have is the private key?</p>
  
  <p>What I don't know is how to login to VM, with key_name (test.pem) which I already have or with username/password. There does not seem to be a provision to create username and password in aws_instance block.</p>
  
  <p>Terraform EC2 instance documentation is at the link below:
  <a href="https://www.terraform.io/docs/providers/aws/r/instance.html" rel="nofollow noreferrer">https://www.terraform.io/docs/providers/aws/r/instance.html</a></p>