create ssh key pair
ssh-keygen -f my-keypair
this creates 2 files my-keypair & my-keypair.pub in the current directory
use puttygen to convert my-keypair to my-keypair.ppk
we'll use my-keypair.pub on EC2 instance
end user/clients will use private key -- my-keypair.ppk
# create EC2 instance via Terraform
# creating test ec2 instance for using ssh keypair made with TF
resource "aws_instance" "mam_test1" {ami = "ami-xxxxxxxx"instance_type = "t2.micro"security_groups =["sg-yyyy" ]associate_public_ip_address =falsesubnet_id = "subnet-zzzzzz"key_name = "my-keypair"tags = {Name = "my_keypair"}}resource "aws_key_pair" "may-keypair" {key_name = "my-keypair"public_key = "${file("my-keypair.pub")}"}output "mam_test1ip" {value=aws_instance.mam_test1.private_ip}
Once the instance is created use the my-keypair.ppk to connect to EC2 instance.
No comments:
Post a Comment