aws-cdk-examples icon indicating copy to clipboard operation
aws-cdk-examples copied to clipboard

cognito-api-lambda is proxied even though proxy=false in source

Open LosAlamosAl opened this issue 4 years ago • 3 comments
trafficstars

:bug: Bug Report

What is the problem?

When I compile this TypeScript example as specified in README, and I examine the API in the console, the lambda is proxied even though the source contains proxy=false. I am having the exact same issue with my code (see my comment below) and landed on this example which I attempted to use to see what my error is.

Reproduction Steps

Clone a clean repo, install cdk , etc. as README describes. All runs OK. Run cdk deploy, runs OK. Check API in the console and the GET method on the HELLO resource still shows Lambda Proxy Integration checked (and Integration Response box is disabled).

Verbose Log

Normal output from install, build, and deploy steps.

Environment

  • CDK CLI Version: 1.87.1
  • Example: cognito-api-lambda
  • Example Version: Stable
  • OS: OSX Mojave (10.14.5)
  • Language: TypeScript

Other information

None

LosAlamosAl avatar Jan 31 '21 21:01 LosAlamosAl

Looks like a link to a Slack post is not a good idea. For context, here is the post on my code that is exhibiting the same issue as in your example. I am completely open to the possibility that the example is correct and I misunderstand the expected behavior.

I must be missing something really simple. I can’t get CDK to make a LambdaRestApi non-proxy. See the following code snippet:

    // One lambda function to rule them all.
    const everythingHandler = new lambda.Function(this, “CyMaxEverythingHandler”, {
        runtime: lambda.Runtime.NODEJS_12_X,
        code: lambda.Code.fromAsset(“resources”),
        handler: “everything.main”
      });

    const api = new apigateway.LambdaRestApi(this, “cy-max-cdk-single-lambda-api”, {
      restApiName: “CY Max CDK Single Lambda API”,
      description: “CDK version of Max AWS demo app (step 0, single lambda)“,
      handler: everythingHandler,
      endpointTypes: [EndpointType.REGIONAL],
      proxy: false
    });

    api.root.addMethod(‘GET’);
    api.root.addMethod(‘POST’);

This code runs and calls my lambda function fine. It too runs as it should and returns (knowingly) something that is not in the format required by a proxy lambda (and so fails in API Gateway). If I check the console, the API is still proxied! If I set proxy: true then cdk deploy fails (as it should) because methods are defined. OTOH, if I comment out the addMethod calls (with proxy: false) then cdk deploy again fails (as it should) because I don’t have methods set. What gives? I don’t know CloudFormation, but if I grep the output of cdk synth I see AWS_PROXY even when proxy: false.

LosAlamosAl avatar Jan 31 '21 21:01 LosAlamosAl

A little more "help" if I may (for what it's worth).

If I set proxy=true, and grep cdk.out/tree.json I see AWS_PROXY as integration type on both ANY methods (along with the assorted {proxy+} resources).

If I set proxy=false and define a couple of methods on the root, I still see an integration type of AWS_PROXY on those two methods (though there are no {proxy+} resources).

If I look at the CDK source (and I've only skimmed it), shouldn't the integration type be ANY for a non-proxy integration?

I suspect that this is a minor bug in the implementation of CDK, and not this example. But, I'd like a verification from one of you experts before I submit over there.

@NGL321

LosAlamosAl avatar Feb 02 '21 22:02 LosAlamosAl

FYI, I've opened an issue on the aws-cdk repo. I might close this issue after you've had a chance to review it. I can always reopen if needed.

@NGL321

LosAlamosAl avatar Feb 13 '21 01:02 LosAlamosAl

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Dec 28 '24 22:12 github-actions[bot]