Search code examples
amazon-web-servicesswaggeropenapiaws-api-gateway

AWS API Gateway documentation. Mention of an API Key for all methods


We have a Rest-Api in AWS Api Gateway published to Developer Portal. What I want to accomplish is that in Developer portals API documentation there is mentioned need of Api Key for every method. I know that if in API Gateway I open Method request and add x-api-key to required HTTTP request headers. After deploying API Developer portal shows this required header in methods parameters. Which is correct way to get this done? There is tens of endpoints and I don't think that this have to add one by one for methods when whole system relys on Api Key.


Solution

  • I ended up to add that ApiKey header to every method just to be sure it shows up in Developer portal documentation.That way our legacy users will know there is new header to be used with API gateway. I loop through every method and update them with new required header like this:

    aws apigateway update-method --rest-api-id foo --resource-id bar --http-method GET --patch-operations op="add",path="/requestParameters/method.request.header.x-api-key",value="true" --profile myProfile
    

    If someone has better idea please let me know.