Search code examples
amazon-web-servicesamazon-iamaws-appsyncaws-amplify

AWS Amplify AppSync IAM 401


I'm getting GraphQLError: Request failed with status code 401

I followed the automatic configuration instructions from:

https://aws.github.io/aws-amplify/media/api_guide#automated-configuration-with-cli

I tried looking, but there are a lack of resources for IAM. It looks like everything should be setup automatically, and done with the Amplify CLI after I put in the IAM access key and secret.

Is further setup required? Here is my code:

import Amplify, { API, graphqlOperation, Hub } from "aws-amplify";
import aws_config from "../../aws-exports";

Amplify.configure(aws_config);

const ListKeywords = `query ListKeywords {
  listKeyword {
    keyword {
      id
      name
    }
  }
}`;

const loop = async () => {
  const allKeywords = await API.graphql(graphqlOperation(ListKeywords));
}

Could it also be because my GraphQL resolvers are not setup yet for ListKeywords?


Solution

  • I just changed ~/.aws/credentials and now it's working.

    Looks like even if you have project specific configuration via Amplify's command line tools or ~/.awsmobile/aws-config.js, it still relies on ~/.aws