# .pem file after creating key pair

**URL:** <https://discuss.hashicorp.com/t/pem-file-after-creating-key-pair/20646>\
**Category:** Terraform\
**Created:** [February 6, 2021, 6:37pm UTC](https://discuss.hashicorp.com/t/pem-file-after-creating-key-pair/20646 "2021-02-06T18:37:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emarburg](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/emarburg/32/17042_2.png) [@Emarburg](https://discuss.hashicorp.com/u/Emarburg)\
**Post date:** [February 6, 2021, 6:37pm UTC](https://discuss.hashicorp.com/t/pem-file-after-creating-key-pair/20646/1 "2021-02-06T18:37:29Z")

</div>

I have been learning how to use Terraform with AWS, I have been able to create an ec2, security group, and add it to a key pair. I am also able to run commands within my instance as well. I have now been able to create a key pair as well, but how can I get the .pem file after I create it?

---

<div class="post-metadata">

**Author:** ![Ruman1996](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Ruman1996](https://discuss.hashicorp.com/u/Ruman1996)\
**Post date:** [February 8, 2021, 3:25pm UTC](https://discuss.hashicorp.com/t/pem-file-after-creating-key-pair/20646/2 "2021-02-08T15:25:24Z")

</div>

@Emarburg How did u create a key pair?? In terraform when you create a key pair you need to pass public key, which you’ll already have and that will be your pem.  
Terraform doesn’t give you key, you’ll be passing in resource block of aws\_key\_pair.  
Reference:[https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key\_pair](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_pair)
