Run amplify add function and go thru the manual configuration and add access to other resources. Add API here.
Run amplify update api if you have a project already setup and configure IAM as an additional auth mode.
Add the authorization as following to your type definition:
type Something
@model
@auth(
rules: [
{ allow: private, provider: iam }
]
) {
id: ID!
something: String
}
This allows Lambda to fetch from this type.
- Open the terminal in the
amplify/backend/function/(nameOfYourFunction)/srcdirectory in your newly created Lambda function. - Run
npm install appsync-client graphql-tag
Change the code as you find in this gist's JavaScript file.
When you are done setting up your Lambda function to your desired result run amplify push to push your Lambda function to the AWS Cloud.


Thanks for the example!
I've used HTTPS requests using API Key authentication before, which is not the recommended way for production apps though. So switched to IAM authentication now using your example 👍
Only thing I've done differently is that I used https://www.npmjs.com/package/appsync-client library as it is more lightweight and does not require
reactto be installed as dependency.