in typescript/api-swagger-lambda/index.ts [10:36]
constructor(scope: App, id: string) {
super(scope, id);
const getItem = new Function(this, 'GetItem', {
functionName: "GetItem",
runtime: Runtime.NODEJS_14_X,
code: Code.fromAsset(path.join(__dirname, './lambda')),
handler: 'index.handler'
});
getItem.grantInvoke(new ServicePrincipal('apigateway.amazonaws.com'));
const updateLambdaId = getItem.node.defaultChild as CfnFunction;
updateLambdaId.overrideLogicalId('GetItem');
const asset = new Asset(this, 'SwaggerAsset', {
path: './swagger/swagger.yaml'
});
const data = Fn.transform('AWS::Include', {'Location': asset.s3ObjectUrl});
const swaggerDefinition = AssetApiDefinition.fromInline(data);
new SpecRestApi(this, 'item-api', {
apiDefinition: swaggerDefinition
});
}