https://pulumi.com logo
Title
p

prehistoric-beach-79855

02/09/2022, 8:19 PM
Hello all, I am trying to import a key pair resource with: key=pulumi_aws.ec2.KeyPair.get(“myKeyPairs”, id=‘key-00789edf16bef11xx’) but pulumi up is giving: “error: Preview failed: resource ‘key-00789edf16bef11xx’ does not exist”. While I can see this Key pair in console > EC2 > Key pairs, under ID column. Am I missing something?
l

little-cartoon-10569

02/09/2022, 8:26 PM
Yes 😉
According to the documention (https://www.pulumi.com/registry/packages/aws/api-docs/ec2/keypair/#import), the import ID for key pairs is the name.
That's the first column, not the last column.
p

prehistoric-beach-79855

02/09/2022, 9:06 PM
🙂 Thanks tenwit. I still don’t know how you understood this from the document. The doc is very confusing. To me,name is dealt differently from id in this doc. Anyways, no error from pulumi up ! thanks !
l

little-cartoon-10569

02/09/2022, 9:17 PM
At the bottom of the page, the docs are about the import opt:
Key Pairs can be imported using the key_name, e.g.,
pulumi import aws:ec2/keyPair:KeyPair deployer deployer-key
The docs are migrated from Terraform, so the name of the property doesn't always match up exactly, but
key_name
is pretty clear.
p

prehistoric-beach-79855

02/09/2022, 9:39 PM
Thanks. “migrated from Terraform” is something I should consider. I always have issues with pulumi docs. 🙏