https://pulumi.com logo
Title
f

flaky-flower-13459

02/14/2021, 12:25 PM
Hi everyone who's watching, is this a place where I can get some community support for something pulumi-aws related? if so, please help, I'm trying to import a keypair into pulumi:
pulumi import aws:ec2/keyPair:KeyPair deployer deployer-key
as documented here: https://www.pulumi.com/docs/reference/pkg/aws/ec2/keypair/#import but it fails with:
Diagnostics:
  pulumi:pulumi:Stack (myproject_name-mystackname_dev):
    error: preview failed

  aws:ec2:KeyPair (dev_keypair):
    error: aws:ec2/keyPair:KeyPair resource 'dev_keypair' has a problem: Required attribute is not set
    error: Preview failed: one or more inputs failed to validate
The key pair already exists in aws, and I'm using a provider to import
pulumi -C .\pulumi\myproject\ -s mystackname_dev--provider provider-us-west-2=urn:pulumi:mystackname_dev::myproject::pulumi:providers:aws::provider-us-west-2 import aws:ec2/keyPair:KeyPair dev_keypair dev_keypair
(the provider also already exists)
the provider is used in order to support multiple regions on the same stack, so it only has { region: 'us-west-2' } as config arg
pulumi v2.20.0
Also, adding verbosity and debug output, doesn't give any insights..
l

little-cartoon-10569

02/14/2021, 7:49 PM
Have you already written some code? Since it's failing on the preview, rather than the import, that implies to me that you've already defined the keypair in code, without the mandatory publicKey parameter.
You could either remove the code and use
pulumi import
, or update the code with the correct publicKey and add the import opt.
f

flaky-flower-13459

02/15/2021, 9:32 AM
I did write some code, but unrelated to keypairs, I commented out index.js completely but it still failed
also I tried raw, without using a provider parameter, just the default project provider and region
Still Errors out, I guess I can create the keypair myself and add the import opt, but that's still a workaround
also there are no keypair resources existing in the stack
ah... even using import is bugged? I added
import: dev_keypair
to the pulumi options on the resource, but now it says my public-key is mis-matched with the resource that already exists in AWS, Although I confirmed the saved (MD5) fingerprint in AWS console, matches exactly the same fingerprint I generated locally using the private\public key files
the public hey is in
ssh-rsa
form, do I need to convert it to
-----BEGIN PUBLIC KEY-----
form?
l

little-cartoon-10569

02/16/2021, 8:38 PM
You might try switching to a different project and running Pulumi import from there? That will ignore your current code and state, and should correctly generate code. Then you can put that code in the correct project.
You should also export your state and look through it for the keypair, in case Pulumi got confused and it's actually in there. You can use
pulumi state delete <urn>
to delete the "wrong" keypair from the state. You should probably do that before adding the code you get from
pulumi import
.