AmplifyでGraphQL(AppSync) APIキーの有効期限を更新する


Amplifyで設定したデフォルトのGraphQL APIキーの有効期限は7日間です。
Amplifyプロジェクト作成後いつの間にか7日間経過してしまい、GraphQL APIリクエストが拒否され、以下のようなエラーレスポンスが返ってくるようになりました。

  "errors" : [ {
    "errorType" : "UnauthorizedException",
    "message" : "You are not authorized to make this call."
  } ]

有効期限はamplify api updateで更新できます(amplify update apiもおそらく同じ挙動)。
最後にamplify pushをお忘れなく。

$ amplify api update
? Select from one of the below mentioned services: GraphQL

General information
- Name: basic
- API endpoint:

Authorization modes
- Default: API key expiring Sun May 29 2022 21:00:00 GMT+0900 (GMT+09:00): da2-xxx

Conflict detection (required for DataStore)
- Disabled

? Select a setting to edit Authorization modes
? Choose the default authorization type for the API API key
✔ Enter a description for the API key: · 
✔ After how many days from now the API key should expire (1-365): · 10
? Configure additional auth types? No

⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules, review:

✅ GraphQL schema compiled successfully.

Edit your schema at /xx/xx/aws/amplify/react-amplified/amplify/backend/api/basic/schema.graphql or place .graphql files in a directory at /xx/xx/aws/amplify/react-amplified/amplify/backend/api/basic/schema
✅ Successfully updated resource

$ amplify push