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.