Implementing kind of whitelist (no authentication token) URL for rest-documentation in a API Gateway with CDK?

0

Hey there. I have deployed an API Gateway with CDK. It looks similar to this. I only left out the part that describes the restLambda.

....
    const myLambdaRestApi = new myLambdaRestApi (this, 'MyApiRest', {
      handler: restLambda,
      defaultMethodOptions: { apiKeyRequired: true },
      proxy: true,
      minCompressionSize: Size.bytes(0),
    });

    const usagePlan = myLambdaRestApi .addUsagePlan('UsagePlan', {
      name: 'MyApiUsagePlan',
    });

    usagePlan.addApiStage({
      stage: myLambdaRestApi .deploymentStage,
    });

    const apiKey = myLambdaRestApi .addApiKey('ApiKey');
    usagePlan.addApiStage;
    usagePlan.addApiKey(apiKey);
...

Generally, we always want to have the "API Key Required" set to true. Therefore

defaultMethodOptions: { apiKeyRequired: true }

is also set in the cdk. If we switch this to false, we are able to get to our REST documentation. However, if I set only one of the ANY methods to "apiKeyRequired: true", I get a

{"message": "Forbidden"}

again when I call the documentation. Enter image description here

Since our REST documentation is accessible at the address https://123456789.execute-api.eu-central-1.amazonaws.com/prod/rest/docs, I tried to expand the following methods and resources in the webconsole but I just can't get through: Enter image description here With this changes in the console, I got this response when I try to access the docu url:

{"statusCode":500,"body":"","isBase64Encoded":false}"

I am grateful for any advice, link or anything else that brings me closer to the goal.

Greeting dralgon

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions