我想从https://docs.aws.amazon.com/cdk/latest/guide/serverless_example.html获取以下示例代码工作,但我得到“类型'函数'的参数不可分配给类型的参数‘IFunction’”错误。
import * as cdk from '@aws-cdk/core';
import * as apigateway from '@aws-cdk/aws-apigateway';
import * as lambda from '@aws-cdk/aws-lambda';
export default class ApiGatewayFunctionStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const handler = new lambda.Function(this, 'WidgetHandler', {
runtime: lambda.Runtime.NODEJS_10_X, // So we can use async in widget.js
code: lambda.Code.fromAsset('resources'),
handler: 'widgets.main',
});
const api = new apigateway.RestApi(this, 'widgets-api', {
restApiName: 'Widget Service',
description: 'This service serves widgets.',
});
const getWidgetsIntegration = new …Run Code Online (Sandbox Code Playgroud)