Is it possible to Store AWS API gateway API keys in secret manager and rotate them

Viewed 2530

I want to create multiple API keys and distribute among the customers, Once I create an API key and attach it to usage plan I want to save it to secrets manager, Can secret manager apply the rotation policy to the API keys in API gateway or we need to develop our own mechanism for it? I see it can apply rotation policy to AWS database credentials but didn't see the same for AWS API keys.

1 Answers

There is not a solution like RDS where you simply enter credentials and it does it for you, however, there is a native solution supported by Secrets Manager that I believe will service your purpose.

Secrets Manager has support for a Lambda Rotation, whereby it will invoke a Lambda of your choosing with that Lambda performing its required tasks then returning the new key back to be stored in Secrets Manager.

So your solution would look similar to this

Secrets Manager -> Invoke Lambda -> Create new key and retire old key(s) -> Return new key to secrets manager
Related