lulu88
lulu88

Reputation: 1714

AWS API Gateway make single endpoint publicly available

I have successfully set up multiple API Gateways on AWS and they work perfectly with client API Keys.

Is it possible to make a specific endpoint in an API publicly available, but all other endpoints protected with the client API key required?

Upvotes: 0

Views: 334

Answers (2)

Ashan
Ashan

Reputation: 19758

You can use AWS CloudFront to forward the request to API Gateway for the public endpoint and define the Client API Key in CloudFront headers forwarded to the Origin.

Note: When including API Gateway as a origin to CloudFront you need to do the following.

  • Whitelist header (Except Host Header)
  • Make HTTPS only
  • Make TTL values 0

Upvotes: 1

jackko
jackko

Reputation: 7344

Simply set the apiKeyRequired field to false on whichever Methods you want to open to the public.

This is in the Method Request page in the console. Here is an example using the AWS CLI:

aws apigateway update-method --rest-api-id 1234123412 --resource-id a1b2c3 --http-method GET --patch-operations op="replace",path="/apiKeyRequired",value="false"

Please note that if you remove the requirement for an API Key, any rate limit or quota you have set up on a Usage Plan will not be applied.

Upvotes: 1

Related Questions