Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically rotate AppSync API key

CloudFormation provides an AWS::AppSync::ApiKey resource type for creating an AppSync API key in a CloudFormation stack. The API key will expire. Is there a simple way to define a rotation schedule within CloudFormation? I don't see anything, but it seems like such an obvious use case that I'm not sure what good the AWS::AppSync::ApiKey resource type is without it.

Currently I have a lambda that runs on a schedule to generate a new key and store it in SecretsManager. This works, but it's an extra step, and I have to run the lambda manually the first time. I am open to alternatives.

like image 560
Thom Smith Avatar asked Oct 18 '25 15:10

Thom Smith


1 Answers

You don’t want to create an AWS::AppSync::ApiKey. Instead make a AWS::SecretsManager::Secret and a AWS::SecretsManager::RotationSchedule. The RotationSchedule will let you use a lambda to automatically rotate the ApiKey and store it in the Secret.

Ultimately, the AWS::AppSync::ApiKey is of little practical use for you because you will need to deal with the expiration.

like image 67
Joey Kilpatrick Avatar answered Oct 21 '25 14:10

Joey Kilpatrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!