Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

fix warning [DeprecationWarning: The Buffer() and new Buffer()] #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion javascript/cloudwatch-alarm-to-slack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ exports.handler = (event, context, callback) => {
// Container reuse, simply process the event with the key in memory
processEvent(event, callback);
} else if (kmsEncryptedHookUrl && kmsEncryptedHookUrl !== '<kmsEncryptedHookUrl>') {
const encryptedBuf = new Buffer(kmsEncryptedHookUrl, 'base64');
let encryptedBuf;
if (Buffer.from && Buffer.from !== Uint8Array.from) {
encryptedBuf = Buffer.from(kmsEncryptedHookUrl, 'base64'); // Node.js >= 8
} else {
if (typeof kmsEncryptedHookUrl === 'number') {
throw new Error('The "kmsEncryptedHookUrl" argument must be not of type number.');
}
encryptedBuf = new Buffer(kmsEncryptedHookUrl, 'base64'); // Node.js < 8
}
const cipherText = { CiphertextBlob: encryptedBuf };

const kms = new AWS.KMS();
Expand Down