Search code examples
amazon-web-servicesaws-lambdadevopsaws-amplifyaws-appsync

AWS Amplify Appsync change default authorization mode form API KEY to IAM


In my React app all users are enabled to use a feature that makes use of an API (GraphQL) to mutate data in DB. My React app is hosted and served using AWS Amplify and my API is on AWS Appsync. Previously I used an API KEY to authenticate my app to my API, however, now I would like to change authentication method from API KEY to IAM. I have changed the Default authorization mode in the AWS Appsync Console (see attached image) and done amplify push and amplify codegen, however when I test my app in both development and production environment I get status code 401 (sometimes 403) from my API whenever I try to call it, what am I missing?

I haven't added any additional configuration on the app side, not sure where and how to add the appropriate credentials.

enter image description here


Solution

  • Changing directly in the console will not reflect in other environments with amplify push also it's not recommended.

    Try using amplify update api with AWS CLI,

    enter image description here

    and do amplify push, it will update the auth config.