sam-goodwin / cdk3

CDK Construct Library for web3.
Apache License 2.0
11 stars 1 forks source link

feat: generate an Ethereum Wallet in a Custom Resource and store in KMS. #2

Closed sam-goodwin closed 3 years ago

sam-goodwin commented 3 years ago

Fixes #1

This change introduces a new Construct, Wallet, which generates an Ethereum Wallet and securely stores it in an AWS Secret encrypted with an AWS KMS Encryption Key. Access is minimized so that only explicitly authorized IAM Principals can read or write the Secret Data.

Usage

To create a new wallet:

const wallet = new cdk3.Wallet(this, "Wallet");

To access the public key and address Resource Properties:

wallet.publicKey;
wallet.address;

By default, the KMS Key and AWS Secret Resources have generated names. To help with organization, you can set the walletName so that those Resources are named according to the convention, ${walletName}-<prefix>. For example: my-wallet-key and my-wallet-secret.

new cdk3.Wallet(this, "Wallet", {
  walletName: "my-wallet",
});

To use an existing KMS Key to encrypt the AWS Secret (instead of generating a new one), set the encryptionKey property.

new cdk3.Wallet(this, "Wallet", {
  encryptionKey: myKey,
});