How to use existing dynamo db with AWS Amplify and graphql
Asked Answered
V

2

6

We have existing database in dynamodb for our application. For one of our new React app, we want to use AWS Amplify and we are trying to use the existing tables.

I created a skeleton project and went to backend AWS AppSync console -> Data Sources and map the existing table to it. And I added that table definition to my schema.graphql in my react app. When I do an amplify push, I see it creating a new table in dynamodb, rather than pointing to the existing db.

I also tried to map one of the tables in AppSync Console, and did amplify pull from local project, assuming that will add the definition of the table in my local schema.graphql but that did not happen either. It did not pull down the details of the newly mapped data source from backend app sync console.

My existing db has lot of data and is shared with other applications as well. I do not want to create a new table.

Can you pls suggest how to accomplish this?

Also we have existing lamdba functions which we would want to leverage into this new Amplify project as well. Could you pls suggest pointers for this as well.

Any help is much appreciated!

Virendra answered 3/1, 2021 at 18:43 Comment(2)
Every get a fix for this? I'm having this issue tooPhan
Me too. I have the same situation and need to use the existing dynamodb tableGamber
M
1

Line 22 in the file below shows how the table name is constructed when the graphql.schema transformer runs; that is - the name is derived from the GraphQLAPI ID and this seems to be a one way process.

TableName: joinWithEnv('-', [SyncResourceIDs.syncTableName, Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId')]),

https://github.com/aws-amplify/amplify-cli/blob/e1e07b245db0963c4655e646c53e7615febe2930/packages/graphql-transformer-core/src/util/syncUtils.ts

The only option then would be to try and patch the resulting CFN script.

Mauceri answered 9/1, 2021 at 12:32 Comment(0)
H
1

You can use amplify import storage to import existing DynamoDB tables or S3 buckets.

more here: https://docs.amplify.aws/cli/storage/import/

Also look at Re-use existing AppSync GraphQL API - it might help with reusing lambda functions, if they are wrapped by an API.

Homogamy answered 30/9, 2021 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.