Want to create pem key to terraform created ec2 instance

I have created an ec2 instance using terraform code and now my question is how can I get .pem key into my local, to SSH with that terraform generated instance.

The SSH key being used (if any) is set via the key_name argument of the aws_instance resource. If you want to create a new SSH key pair you can use the aws_key_pair resource, which accepts a public key in one of three formats - see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair

1 Like