Search code examples
amazon-web-servicesaws-amplifyaws-appsyncdatastore

Aws AppSync token expiry date


I am using AWS Amplify datastore, which uses an App-sync token. Currently, the token is expired so I changed the expiry date at Appsync / Settings / API keys. But this only allows me to edit the expiry date to a maximum of one year from today.

Is there any way to set the token expiry date to forever or to more than 1 year? My client doesn't want to have to change the expiry date again.


Solution

  • AppSync API key docs: API keys are configurable for up to 365 days, and you can extend an existing expiration date for up to another 365 days from that day.

    You can extend the expiry of an existing key programatically, but if you try to update the expiry (seconds since epoch) beyond one year, you will get the following error: The API key expiration must be set to a value between 1 and 365 days.

    aws appsync update-api-key --api-id xxxxxxxx --id da2-xxxxxxxx --expires 1669880629
    

    You could automate key updates with a lambda triggered by an EventBridge cron schedule rule.