如何使用Ask CLI设置lambda函数环境变量?我尝试使用AWS控制台设置它们,但是这样做之后,当我尝试运行ask deploy
时出现此错误:
[Error]: Lambda update failed. Lambda ARN: arn:aws:lambda:us-east-1:608870357221:function:ask-custom-talk_stem-default
The Revision Id provided does not match the latest Revision Id. Call the GetFunction/GetAlias API to retrieve the latest Revision Id
答案 0 :(得分:0)
您好尝试使用--force命令吗?
询问部署--force
答案 1 :(得分:0)
我发现的唯一解决方案是通过AWS控制台更新变量,并使用AWS CLI手动获取函数的信息,并更新本地修订ID以匹配AWS上实时存在的修订ID。这是我的脚本:
const path = require('path');
const { readFileSync, writeFileSync } = require('fs');
const execa = require('execa');
const skillRoot = path.join(__dirname, '..');
const functionRoot = path.join(skillRoot, 'lambda', 'custom');
const askConfigPath = path.join(skillRoot, '.ask', 'config');
const askConfig = JSON.parse(readFileSync(askConfigPath, 'utf8'));
const { functionName } = askConfig.deploy_settings.default.resources.lambda[0];
async function main() {
console.log('Downloading function info from AWS');
const result = await execa('aws', ['lambda', 'get-function', '--function-name', functionName]);
const functionInfo = JSON.parse(result.stdout);
const revisionId = functionInfo.Configuration.RevisionId;
console.log('Downloading function contents from AWS');
await execa('ask', ['lambda', 'download', '--function', functionName], { cwd: functionRoot, stdio: 'inherit' });
console.log('Updating skill\'s revisionId');
askConfig.deploy_settings.default.resources.lambda[0].revisionId = revisionId;
writeFileSync(askConfigPath, JSON.stringify(askConfig, null, 2));
console.log('Done');
}
main();