0
votes

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

enter image description here

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.

1
hey were you able to figure out the IAM permissions to do this?foboi1122
the project where this is relevant is on hiatus for the time being so no unfortunately @foboi1122notacorn

1 Answers

1
votes

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.