https://pulumi.com logo
#aws
Title
# aws
p

purple-mouse-61376

02/01/2021, 12:57 AM
Hey everyone, does anyone know if there's a way to create an ec2 KeyPair without specifying the public key using pulumi, similar to how you would in the AWS CLI or AWS console? It's currently required for the the pulumi_aws.ec2.KeyPair object to take in a public_key. https://www.pulumi.com/docs/reference/pkg/aws/ec2/keypair/
l

little-cartoon-10569

02/01/2021, 1:13 AM
It isn't possible. If the cli or console allows it, it's because they create the key in the background for you and just hide that bit. Creating a key in Pulumi is trivial. One line:
Copy code
const tlsKey = new tls.PrivateKey(name, { algorithm: "RSA" });
An EC2 KeyPair is a simple wrapper around a public key. There must be a public key to wrap, in order to have a key pair. It is an odd name though, since it isn't a pair of keys. It's a single key, the public half of a public/private key pair.
❤️ 1
p

purple-mouse-61376

02/01/2021, 2:39 AM
Okay I'll give it a go thanks a lot! 😄
l

little-cartoon-10569

02/01/2021, 2:48 AM
👍 You'll need to export the key's private pem value to decode the auto-generated password for the default user (.\Administrator or similar). You might not need this if you join the machine to a Windows domain, or some other authentication service.
2 Views