AWS CDK 常见问题列表

264 阅读1分钟

1. terminal (TTY) is not attached so we are unable to get a confirmation from the user

场景:在windows上通过cygwin执行cdk deploy时,提示上面的错误。目前还没找到合适的解决方案,但是使用的workaround是通过windows自带的CMD命令行执行同样的命令可以运行。

2. Uploaded file must be a non-empty zip

场景:使用cdk deploy部署lambda时,提示上面的问题 root cause: lambda必须返回JSON格式,我最初的形式是返回普通文本(headers: { "Content-Type": "text/plain" })

错误

exports.handler = async function(event) {
    console.log("request:", JSON.stringify(event, undefined, 2));
    return {
      statusCode: 200,
      headers: { "Content-Type": "text/plain" },
      body: `Hello, CDK! You've hit ${event.path}\n`
    };
  };

正确

exports.handler = async function(event) {
    console.log("request:", JSON.stringify(event, undefined, 2));
    return {
      statusCode: 200,
      headers: { "Content-Type": "text/json" },
      body: `Hello, CDK! You've hit ${event.path}\n`
    };
  };