title: aws-cdk - ApiGateway with Cognito authorizer for a Lambda proxy endpoint
body: <p>I'm having issues setting up a, API Gateway with a lambda proxy secured by a Cognito userpool.
  I am using aws-cdk 0.34.0 in typescript.</p>
  
  <p>The setup I am after is an API Gateway with a single resource that is a proxy for a lambda function. This single endpoint needs to be secured by a Cognito user pool.</p>
  
  <p>The code I am trying is below.</p>
  
  <p>However when I run it I get the following error...</p>
  
  <pre><code>apiDeployment (Deployment2E842E9E) No integration defined for method (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 64f4e3bb-9107-11e9-84f1-999724493159)
      new Deployment (/home/circleci/aws/node_modules/@aws-cdk/aws-apigateway/lib/deployment.ts:69:21)
  </code></pre>
  
  <p>My Typescript code is below</p>
  
  <pre class="lang-js prettyprint-override"><code>    const backendLambda = new lambda.Function(
        this,
        "CampManager-backendLambda",
        {
          code: new lambda.AssetCode("../server/", AssetPackaging.ZipDirectory),
          handler: "src/index.js",
          timeout: 1000,
          runtime: lambda.Runtime.NodeJS10x
        }
      );
  
      const backendApi = new api.RestApi(this, "CampManager-backendApi");
  
      const userPool = new cognito.UserPool(this, "CampManager-userPool", {
        autoVerifiedAttributes: [],
        poolName: "CampManager-userPool",
        signInType: cognito.SignInType.Username,
        usernameAliasAttributes: [
          cognito.UserPoolAttribute.Email,
          cognito.UserPoolAttribute.PhoneNumber
        ]
      });
  
      const cognitoAuthorizer = new api.CfnAuthorizerV2(
        this,
        "CampManager-authorizer",
        {
          apiId: backendApi.restApiId,
          authorizerType: api.AuthorizationType.Cognito,
          identitySource: ["Authorisation"],
          authorizerUri: userPool.userPoolProviderUrl,
          name: "Cognito"
        }
      );
  
      backendApi.root.addProxy({
        defaultIntegration: new api.LambdaIntegration(backendLambda),
        defaultMethodOptions: {
          authorizationType: api.AuthorizationType.Cognito,
          authorizerId: cognitoAuthorizer.authorizerId,
          operationName: "Proxy"
        }
      });
  
      const apiDeployment = new api.Deployment(
        this,
        "CampManager-apiDeployment",
        {
          api: backendApi,
          description: "Camp Manager Deployment"
        }
      );
  
      const apiStage = new api.Stage(this, "CampManager-apiStage", {
        deployment: apiDeployment
      });
  </code></pre>