- 最新
- 最多得票
- 最多評論
参考にされた情報を明らかにしておかないと具体的なアドバイスをもらう事は困難かもしれません。
AWS.config.update({ region: 'REGION' });
この部分は実際のリージョンが伏せられているだけで、ソースコードがこの状態のまま動作させているわけではないですよね?
replyありがとうございます。
仰られる通りです、確かにこのままではないのですが、実際のコードと異なるのはこの部分のみです。
東京リージョンで利用しておりますので、実際には
AWS.config.update({ region: 'ap-northeast-1' });
となっております。
参考にしたコードは、環境変数の暗号化を行った際に表示されるコードボタンをクリックして表示される「シークレットスニペットの復号」のコード(下記)になります。
const AWS = require('aws-sdk');
AWS.config.update({ region: 'ap-northeast-1' });
const encrypted = process.env['test'];
let decrypted;
function processEvent(event, context, callback) {
// TODO handle the event here
}
exports.handler = (event, context, callback) => {
if (decrypted) {
processEvent(event, context, callback);
} else {
// Decrypt code should run once and variables stored outside of the
// function handler so that these are decrypted once per container
const kms = new AWS.KMS();
kms.decrypt({ CiphertextBlob: new Buffer(encrypted, 'base64') }, (err, data) => {
if (err) {
console.log('Decrypt error:', err);
return callback(err);
}
decrypted = data.Plaintext.toString('ascii');
processEvent(event, context, callback);
});
}
};
相關內容
- 已提問 1 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 1 年前