Reputation: 4099
I'm looking at this part of the documentation where AWS offers a path through the UI to create API keys: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html#api-gateway-usage-plan-create-apikey
but is there a way to automate this in AWS? Optimally it would be some sort of http triggered function that returns a newly generated api key, on demand.
Upvotes: 1
Views: 1545
Reputation: 238209
is there a way to automate this in AWS? Optimally it would be some sort of http triggered function that returns a newly generated api key, on demand.
There are several ways you could automate creation of API keys, depending on your requirements.
For example, you could use create-api-key to create a key for a given API. This would be most useful to execute on an EC2 instance or a local workstation.
For an HTTP trigger, you could create new API in API Gateway with AWS_PROXY
integration to a lambda function. The lambda could use create_api_key boto3 method to generate the key and return to the caller.
Yet another way would be to use SSM Automation's action aws:executeAwsApi to trigger the create-api-key
based on some criteria you specify. These criteria could be determined by some CloudWatch Events, for example.
Upvotes: 1