AWS Lambdaで環境変数を暗号化して設定したのですが、利用時には当然復号化して利用する必要がありますが、復号化ができず困っております。
どの箇所が間違っているかご教示頂けますでしょうか?
なお、console.log(decrypted)の結果は、暗号化された文字列で、
実行結果はstatusCode 200が返ってくるという状況です。
nodejs
1const AWS = require('aws-sdk'); 2AWS.config.update({ region: 'REGION' }); 3 4//あらかじめ設定している暗号化された環境変数(DB_HOST) 5const encrypted_dbhost = process.env.DB_HOST; 6let decrypted = []; 7 8exports.lambdaHandler = async (event, context, callback) => { 9 10 const kms = new AWS.KMS(); 11 try { 12 const test_data = await kms.decrypt({ CiphertextBlob: new Buffer(encrypted_dbhost, 'base64') }).promise(); 13 decrypted = test_data.Plaintext.toString('ascii'); 14 console.log(decrypted); 15 const response = { 16 statusCode: 200, 17 body: JSON.stringify('Hello from Lambda!'), 18 }; 19 20 return response; 21 }catch(e){ 22 throw e; 23 } 24 25}; 26 27
あなたの回答
tips
プレビュー