aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 1.5 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const path=require("path"),lambda=require("../../../aws-lambda"),core_1=require("../../../core"),lib_1=require("../../lib"),app=new core_1.App,stack=new core_1.Stack(app,"RequestAuthorizerInteg"),authorizerFn=new lambda.Function(stack,"MyAuthorizerFunction",{runtime:lambda.Runtime.NODEJS_14_X,handler:"index.handler",code:lambda.AssetCode.fromAsset(path.join(__dirname,"integ.request-authorizer.handler"))}),restapi=new lib_1.RestApi(stack,"MyRestApi",{cloudWatchRole:!0}),authorizer=new lib_1.RequestAuthorizer(stack,"MyAuthorizer",{handler:authorizerFn,identitySources:[lib_1.IdentitySource.header("Authorization"),lib_1.IdentitySource.queryString("allow")]}),secondAuthorizer=new lib_1.RequestAuthorizer(stack,"MySecondAuthorizer",{handler:authorizerFn,identitySources:[lib_1.IdentitySource.header("Authorization"),lib_1.IdentitySource.queryString("allow")]});restapi.root.addMethod("ANY",new lib_1.MockIntegration({integrationResponses:[{statusCode:"200"}],passthroughBehavior:lib_1.PassthroughBehavior.NEVER,requestTemplates:{"application/json":'{ "statusCode": 200 }'}}),{methodResponses:[{statusCode:"200"}],authorizer}),restapi.root.resourceForPath("auth").addMethod("ANY",new lib_1.MockIntegration({integrationResponses:[{statusCode:"200"}],passthroughBehavior:lib_1.PassthroughBehavior.NEVER,requestTemplates:{"application/json":'{ "statusCode": 200 }'}}),{methodResponses:[{statusCode:"200"}],authorizer:secondAuthorizer});