Terraform SSH connection to AWS EC2
The instances are created via Terraform, but Terraform can only used existing key pairs. First thing is to create the key pair as explained in the AWS documentation 1 . NOTE: However, if you are not familiar with Terraform, please go through the following blogs before this blog Basic example of creating AWS EC2 with Terraform Creating AWS S3 bucket with Terraform Connect to the EC2 instance, the most important thing is key value pair which is create in the time of the EC2 instance is created. But this is not currently possible in the Terraform. Therefore we need to create the mykey first. For example aws ec2 create-key-pair --key-name mykey --query 'KeyMaterial' --output text > ~/.aws/mykey.pem If you are connecting from the Linux or Mac, because need read permission. chmod 400 ~/.aws/mykey.pem To display aws ec2 describe-key-pairs --key-name mykey To retrieve the public key from the pem file (Optional) ssh-keygen -y -f ~/.aws/mykey.pem Before th...