Use an existing DynamoDB datasource with Amplify and AppSync

Viewed 1462

I have a working app I made using Amplify (with AppSync API and Cognito). I'd like to make another app which is different, but shares some data with my first project (same product, but different targets, usages and security rules).

Is there a clean way to use Amplify for that new project, telling the GraphQL API to fetch some data in the DynamoDB from my first Amplify project ?

This data will change often and will be heavy - so I'm not too much into any synchronization solution.

I thought about those solutions, but I'm not experienced enough to tell if one of them is good:

  • Not using Amplify but SAM for this new project (but I will lose all the build pipeline provided by Amplify)
  • Using Amplify for the Hosting and the Auth, but configure AppSync with SAM and plug it into my existing DataSource
  • Maybe CloudFormation can be the answer, but I don't see how to interact directly with it within Amplify

Schema

1 Answers

There is an article from Amazon about microservice architectures that might be useful for you https://aws.amazon.com/blogs/mobile/appsync-microservices/

I'm not sure if Amplify supports adding multiple APIs to it, if so, you could add it and then pull only that api on it.

IMO the easiest approach would be just creating a query endpoint to fetch the data from your other datasource, using lambda.

So, in that case you would edit your schema to something like this

query
{
  externalData [ExternalData] @function(name: "getExternalData")
}

Then you need to add the lambda function getExternalData, which will be responsible to query the data as needed.

The article above has more in-depth details about this architecture

Related