I have an AWS AppSync API that uses IAM roles for authentication. I'm using the Amplify GraphQL client to connect to the AppSync server. The image below describes the steps that need to take place to get the IAM credentials, which I'm assuming Amplify is capable of performing. However, I can't find any documentation on how to set up a working example.
Note that I'm using a Cognito user pool directly for authentication, not an external provider like Google or Facebook.
So far I'm able to authenticate the user and get a JWT Token (step 1):
const Amplify = require('aws-amplify').default
const { Auth } = require('aws-amplify')
Amplify.configure({
Auth: {
region: process.env.AWS_REGION,
userPoolId: process.env.COGNITO_USERPOOL_ID,
userPoolWebClientId: process.env.COGNITO_WEBCLIENT_ID,
},
})
Auth.signin(username, password)
.then((user) => {
const token = user.idToken.jwtToken
// I've got the token - what next?
})
How can I request the IAM credentials from the identity pool (step 2), and use them to access the AppSync API (step 3) using Amplify?
If Amplify isn't able to get the credentials itself, I can use AWS.CognitoIdentityCredentials
to request them using the AWS SDK, however, I can't see a way of passing them to Amplify to authenticate the API requests (refer to this issue I created for more details).