Use an API Key in API Gateway
You can use an API key in API Gateway to enable an API's methods. When you enable an API key, callers must supply it as part of the call.
Use an API Key with the API Gateway Console
To enable an API key with the API Gateway console, follow these instructions:
Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.
Choose the GET method under a resource of your choosing.
Choose the Method Request box
If API Key Required is set to false, choose the pencil icon next to it. From the drop-down menu list, choose true. Finally, choose the check-mark icon to save the setting.
NoteThe steps above configures the API Gateway to enforce using API key. Otherwise, the API key created following the instructions below will not be used.
In the secondary navigation bar, in the first list next to the console home button, choose API Keys.
Choose Create API Key.
For Name, type a name for the API key entry.
(Optional) For Description, type a description for the API key entry.
To enable the API key, select Enabled.
Choose Save. Make a note of the key displayed in API key.
For API Stage Association, for Select API, choose the name of the API.
For Select stage, choose the name of the stage.
Choose Add, and then choose Save.
Callers must now add to each call a custom header named
x-api-key, along with the value of the API key. For example, if the API key value is
bkayZOMvuy8aZOhIgxq94K9Oe7Y70Hw55, the custom header would be as follows:
In addition to, or instead of, enabling an API key, you can restrict access to certain IAM users only. For instructions, see Configure How a User Calls an API Method.