How do I encrypt an aws-cdk-lamdba environment variable using KMS?

Viewed 694
export class CdkStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    const func = new lambda.Function(this, 'TestLambda', {
        runtime: lambda.Runtime.NODEJS_10_X,
        handler: 'index.handler',
        code: lambda.Code.fromAsset(path.join(__dirname, 'resources\\lambda')),
        role: exeRole,
        environment: {
          "KEY_PHRASE": cipherText,//**I want to be able to encrypt this value using KMS**
        }
    });
  }
}

as the code snippet shows, I want to encrypt an environment variable KEY_PHRASE , is @aws-sdk/client-kms the one that I should look into? or is there a CDK lamdba native way of handling of this?

1 Answers
Related