0

I am trying to build a graphql client to query/mutation on AWS appsync. I come up with the library aws-amplify. My appsync uses IAM authentication method. I created an IAM user in my AWS account and I have the key and secret. But I don't know how to authenticate the amplify to use the iam authentication. I have searched AWS doc and it only mentions using cognito user pool which I don't want.

Below is my code. Is there any way I can specify the IAM credentials in the code?


const config: ResourcesConfig = {
  API: {
    GraphQL: {
      endpoint: 'https://xxx.appsync-api.ap-southeast-2.amazonaws.com/graphql',
      region: 'ap-southeast-2',
      defaultAuthMode: 'iam',
    },
  },
};

Amplify.configure(config);

const client = generateClient();

client.graphql({
  query: gql`
    query getUser($id: ID!) {
      getUser(id: $id) {
        id
        name
      }
    }
  `,
...
});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.