AWS CDK - 无法增加 Lambda 超时

fun*_*per 5 aws-lambda aws-cdk

我的 lambda 函数需要更多时间来执行,因此当我增加它时

    const postReader_NewPost = new lambda.Function(this, 'PostReader_NewPost', {
      code: lambda.Code.fromAsset('lambda'),
      runtime: lambda.Runtime.PYTHON_2_7,
      handler: 'PostReader_NewPost.handler',
      timeout: Duration.seconds(300),
      description: "",
      environment: {
        "DB_TABLE_NAME": table.tableName,
        "SNS_TOPIC": topic.topicArn
      },
      role:role,
    });
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Type 'import("c:/Users/myusername/Documents/GitHub/cdk_polly_website/node_modules/@aws-cdk/core/lib/duration").Duration' is not assignable to type 'import("c:/Users/myusername/Documents/GitHub/cdk_polly_website/node_modules/@aws-cdk/aws-dynamodb/node_modules/@aws-cdk/core/lib/duration").Duration'.
  Types have separate declarations of a private property 'amount'.ts(2322)
function.d.ts(68, 14): The expected type comes from property 'timeout' which is declared here on type 'FunctionProps'
Run Code Online (Sandbox Code Playgroud)

我已经宣布在班级中名列前茅

import { Duration } from '@aws-cdk/core';
Run Code Online (Sandbox Code Playgroud)

我的 package.json 有以下依赖项

"dependencies": {
    "@aws-cdk/aws-apigateway": "^1.88.0",
    "@aws-cdk/aws-dynamodb": "^1.88.0",
    "@aws-cdk/aws-iam": "^1.88.0",
    "@aws-cdk/aws-lambda": "^1.88.0",
    "@aws-cdk/aws-lambda-event-sources": "^1.88.0",
    "@aws-cdk/aws-sns": "^1.88.0",
    "@aws-cdk/aws-sns-subscriptions": "^1.88.0",
    "@aws-cdk/core": "1.88.0",
    "source-map-support": "^0.5.16"
  }
Run Code Online (Sandbox Code Playgroud)

感谢帮助。谢谢

uri*_*rot 5

这种方式总是对我有用: aws-examples

导入 core,然后使用 Duration as core.Duration

我不确定它是否有帮助,但看起来您的核心导入是通过这种方式从 aws-dynamodb 获取的。

如果这能解决问题,我想调查一下原因。