我试图使用node.js的aws-sdk包更新lambda函数中的代码。因此,我编写了以下脚本以进行部署:
问题在于当我运行脚本时,出现了以下错误:
我尝试从我的电脑以及 CircleCI 部署 zip 文件,我还尝试使用 AWS CLI,但结果都一样。在 zip 文件和 config.json 文件中我都拥有需要的所有内容。这里可能出了什么问题?
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./config.json');
var lambda = new AWS.Lambda();
var params = {
FunctionName: 'FunctionName',
ZipFile: 'fileb://deploy_package.zip'
}
lambda.updateFunctionCode(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
问题在于当我运行脚本时,出现了以下错误:
{ InvalidParameterValueException: Could not unzip uploaded file. Please check your file, then try to upload again.
at Object.extractError (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\protocol\json.js:48:27)
at Request.extractError (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\protocol\rest_json.js:52:8)
at Request.callListeners (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\sequential_executor.js:105:20)
at Request.emit (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\sequential_executor.js:77:10)
at Request.emit (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request.<anonymous> (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\request.js:38:9)
at Request.<anonymous> (C:\Users\jaarnold\Desktop\AlexaSkills\circleCI\node_modules\aws-sdk\lib\request.js:685:12)
message: 'Could not unzip uploaded file. Please check your file, then try to upload again.',
code: 'InvalidParameterValueException',
time: 2018-06-18T15:09:12.212Z,
requestId: '8ec20526-7309-11e8-aa20-4fb186ac4f30',
statusCode: 400,
retryable: false,
retryDelay: 65.40106275377198 } 'InvalidParameterValueException: Could not unzip uploaded file. Please check your file, then try to upload again.\n at Object.extractError (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\protocol\\json.js:48:27)\n at Request.extractError (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\protocol\\rest_json.js:52:8)\n at Request.callListeners (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\sequential_executor.js:105:20)\n at Request.emit (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\sequential_executor.js:77:10)\n at Request.emit (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\request.js:683:14)\n at Request.transition (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\request.js:22:10)\n at AcceptorStateMachine.runTo (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\state_machine.js:14:12)\n at C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\state_machine.js:26:10\n at Request.<anonymous> (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\request.js:38:9)\n at Request.<anonymous> (C:\\Users\\jaarnold\\Desktop\\AlexaSkills\\circleCI\\node_modules\\aws-sdk\\lib\\request.js:685:12)'
我尝试从我的电脑以及 CircleCI 部署 zip 文件,我还尝试使用 AWS CLI,但结果都一样。在 zip 文件和 config.json 文件中我都拥有需要的所有内容。这里可能出了什么问题?
ZipFile
应该是这样的。请参考此处https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionCode-property - Vaisakh PS