简体   繁体   English

使用Ask CLI设置lambda环境变量?

[英]Setting lambda environmental variable using ask CLI?

How can I use the Ask CLI to set lambda function environmental variables? 如何使用Ask CLI设置lambda函数环境变量? I tried setting them using the AWS console, but after I do that I get this error when I try to run ask deploy : 我尝试使用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

Hello have you tried using --force command? 您好您是否尝试使用--force命令?

ask deploy --force 要求部署-强制

The only solution I've found is to update the variables through the AWS console and manually fetch the function's info using the AWS CLI and update the local revision id to match the revision id that's live on AWS. 我找到的唯一解决方案是通过AWS控制台更新变量,并使用AWS CLI手动获取函数的信息,并更新本地修订ID以匹配AWS上实时存在的修订ID。 Here is my script: 这是我的脚本:

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM