# Resource block key pair is failing with path

**URL:** <https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140>\
**Category:** AWS\
**Created:** [September 10, 2022, 6:36am UTC](https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140 "2022-09-10T06:36:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk8228402](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/sk8228402/32/25064_2.png) [@sk8228402](https://discuss.hashicorp.com/u/sk8228402)\
**Post date:** [September 10, 2022, 6:36am UTC](https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140/1 "2022-09-10T06:36:13Z")

</div>

Resource block is failing with below path, But I have download key value pair correctly in the AWS and provided same path in the below area, but it is giving error. Please help on how to fix this. Thank you

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/1/9/1922386cf86f5debfec55d8e30ee346e25222cf7.png)

---

<div class="post-metadata">

**Author:** ![ramsateesh](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ramsateesh/32/15237_2.png) [@ramsateesh](https://discuss.hashicorp.com/u/ramsateesh)\
**Post date:** [September 10, 2022, 4:08pm UTC](https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140/2 "2022-09-10T16:08:37Z")

</div>

I think your line 219 has to change to: `aws_key_pair.web.id`  
or  
Your resource name has to change from `web` to `wsk1` as shown below:

```auto
resource "aws_key_pair" "wsk1" {
  public_key = file("C:/Users/kumar/downloads/wsk1.pem")
}

```

---

<div class="post-metadata">

**Author:** ![sk8228402](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/sk8228402/32/25064_2.png) [@sk8228402](https://discuss.hashicorp.com/u/sk8228402)\
**Post date:** [September 10, 2022, 4:41pm UTC](https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140/3 "2022-09-10T16:41:23Z")

</div>

Hi Ram Sateesh,

Thank you for the response, looks like what you suggested is working , however I encountered different error now, Do I need to change key length, if yes how?  
I took and pasted whatever machine generated.

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/3/a/3af81b3d93b6b916d6066e8eb20a0bfe2a26d089.png)

---

<div class="post-metadata">

**Author:** ![apparentlymart](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/apparentlymart/32/702_2.png) [@apparentlymart](https://discuss.hashicorp.com/u/apparentlymart)\
**Post date:** [September 12, 2022, 8:59pm UTC](https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140/4 "2022-09-12T20:59:17Z")

</div>

Hi @sk8228402,

The `aws_key_pair` resource registers a _public key_ which your Linux instances will add to [the `authorized_keys` file](http://man.he.net/man5/authorized_keys) for your main user on boot. Public keys are usually given in the OpenSSH public key format, which has a single line of text containing a key type and then base64-encoded key material.

You seem to be providing the contents of a `.pem` file, which is typically used for the _private_ key. You’ve therefore now shared your private key with the remote API and so you should destroy it and generate a new one that hasn’t been compromised. The private key file should not be sent to any other system because it is your secret credential for use only on your current computer.

---

<div class="post-metadata">

**Author:** ![sk8228402](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/sk8228402/32/25064_2.png) [@sk8228402](https://discuss.hashicorp.com/u/sk8228402)\
**Post date:** [September 13, 2022, 6:49am UTC](https://discuss.hashicorp.com/t/resource-block-key-pair-is-failing-with-path/44140/5 "2022-09-13T06:49:36Z")

</div>

Hi Mart,

which one I should choose here while creating new key pair?

 ![image](https://global.discourse-cdn.com/hashicorp/original/3X/c/e/ce289ec844362c3304e20757fdc97719468d7a1d.png)
