Reputation: 942
I want one of my endpoints to only be available to a single api key. For all others, I want to reject it.
I have been looking around and it seems that you can do this by IAM account or IP address but I can't find anything about API Key. Is this possible?
Upvotes: 1
Views: 2414
Reputation: 181
"I can't find anything about API Key. Is this possible?"
Yes it is.
Now your API methods will only execute if the correct X-API-Key header is passed in the request, every other request will get a forbidden status.
Upvotes: 0
Reputation: 1503
Yes you can create an API key and attach it to an API Gateway endpoint.
Firstly create an API key.
AWS console -> API Gateway -> API Key -> Actions -> Create API Key.
Now Import an API key, API Gateway -> API Key -> Import API keys. Type key in format.
In API Gateway Methods(Get/Post) -> In Method request set API Ket Required to true.
Now create an usage plan: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-usage-plans-with-console.html
Deploy the API.
You can also follow: https://datanextsolutions.com/blog/protect-aws-api-gateway-endpoints-using-api-keys/
Upvotes: 2