Unable to import ec2.KeyPair
See original GitHub issueI’m following this document to import an EC2 key pair on my AWS account. However, I failed to import.
The error message I encountered is
error: aws:ec2/keyPair:KeyPair resource 'my_key_pair' has a problem: Missing required argument: The argument "public_key" is required, but no definition was found.. Examine values at 'KeyPair.PublicKey'.
Steps to reproduce
- Run
pulumi import aws:ec2/keyPair:KeyPair my_key my_key_pair
.
Expected: I expect to see the key pair being imported without any error. Actual: The following error message will be displayed.
Previewing import (my_stack):
Type Name Plan Info
+ pulumi:pulumi:Stack my_infrastructure-my_stack create 1 error
= └─ aws:ec2:KeyPair my_key import 2 errors
Diagnostics:
pulumi:pulumi:Stack (my_infrastructure-my_stack):
error: preview failed
aws:ec2:KeyPair (my_key):
error: aws:ec2/keyPair:KeyPair resource 'my_key' has a problem: Missing required argument: The argument "public_key" is required, but no definition was found.. Examine values at 'KeyPair.PublicKey'.
error: Preview failed: one or more inputs failed to validate
The official document also says
When importing an existing key pair the public key material may be in any format supported by AWS.
But where can I provide the public key while importing?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Terraform fails to import key pair with Amazon EC2
The error is telling you that the keypair already exists in your AWS account but Terraform has no knowledge of it in its...
Read more >Cannot import EC2 keypair (Length exceeds maximum) via ...
1 Answer 1 ... You are trying to import the private ssh key file. You should be importing the public ssh key file...
Read more >Unable to import ec2.KeyPair · Issue #2008 - GitHub
I'm following this document to import an EC2 key pair on my AWS account. However, I failed to import. error: aws:ec2/keyPair:KeyPair resource ' ......
Read more >import-key-pair — AWS CLI 1.27.27 Command Reference
Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ec2 ......
Read more >How To Change AWS EC2 Key Pair - ClayDesk E-Learning Blog
Instructions From AWS EC2 Support · Change pem login · go to your EC2 Console · Under NETWORK & SECURITY, click on Key...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi folks
unfortunately, the Go SDK doesn’t return the Key material in the API calls therefore, we are not going to be able to do much here. Maybe you could do something regarding ignoreChanges?
This is actually pointed out in the Terraform provider docs as well in their import:
Sorry for this
Paul
This looks like it’s probably that the KeyPair Read function isn’t returning the publicKey attribute. That will be a bug in aws, not the engine. Re-open and moving.