KeyPair
Source:
src/AWS/EC2/KeyPair.ts
An EC2 key pair used to grant SSH access to instances launched with its
keyName.
By default Alchemy asks EC2 to generate the key pair and captures the private key (returned only once, at create time) as a secret in state. Pass {@link KeyPairProps.publicKeyMaterial} to import your own public key instead, in which case no private key is stored.
Creating a Key Pair
Section titled “Creating a Key Pair”Generated key pair
const keyPair = yield* AWS.EC2.KeyPair("DeployKey", { keyType: "ed25519",});// keyPair.keyName -> pass to AWS.EC2.Instance({ keyName })// keyPair.privateKey -> Redacted<string> (the PEM private key)Imported public key
const keyPair = yield* AWS.EC2.KeyPair("ImportedKey", { publicKeyMaterial: "ssh-ed25519 AAAAC3Nz... user@host",});