Can Aurora PostgreSQL be used with AWS AppSync?
Asked Answered
C

5

7

I've seen examples of DynamoDB as the data source for AWS AppSync but I'm wondering if Aurora (specifically PostgreSQL) can be used? If yes, what would the resolvers look like for a basic example? Are there any resources that demonstrate doing this for Aurora PostgreSQL or even MySQL?

Cragsman answered 30/1, 2018 at 3:51 Comment(0)
W
6

You can use the AWS Lambda resolver available in AWS AppSync to access Aurora Postgres. The code is similar to how you would access a relational database using any language. For example, you could use node-postgres with NodeJS to implement the Lambda function.

Wash answered 31/1, 2018 at 13:38 Comment(4)
At that point, why not just spin up Graphile in a Lambda? Seems like AppSync isn't adding much value...Fry
I expected aws to provide such an functionality too! Using Graphile, graphql-yoga or apollo-server always means you need to run instances for websockets and requires to scale them. I guess appsyncs is smarter on that. Other than that I agree cazzerLackluster
I guess that now is possible to do it directly without any Lambda. Isn't it? I'm a little confused about how to do it well... :/Shanelleshaner
@Fry Graphpille does not support subscriptions which is a driver for the use of graphql. AppSync also ties into AWS Cognito user pools and makes authentication easier across services.Azotemia
B
8

As of 2023-12-21 this is possible for Postgres in some regions (more regions will be added soon according to AWS support): https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.enabling.modifying.all

It can not. You can use Aurora Serverless as the data source which is driven by Data API (still in beta), this allows you to configure resolvers as database queries. That being said Data API is still very slow and Aurora Serverless has a cold-start of 30sec or so as it needs to run from VPC. I would recommend avoiding production but worth playing around.

You are much better of using Lambdas as resolvers or running HTTP RestFul calls from within the resolvers.

Ignore the comments provided in the answer, no disrespect, but the comments are coming from people who never managed production at scale. The fact you have a fully manage GraphQL service at scale as well as with high-security posture will save you months of maintenance nightmares when your product(s) will reach anything close to 1MIL revenue.

Blunk answered 11/1, 2019 at 18:28 Comment(0)
W
6

You can use the AWS Lambda resolver available in AWS AppSync to access Aurora Postgres. The code is similar to how you would access a relational database using any language. For example, you could use node-postgres with NodeJS to implement the Lambda function.

Wash answered 31/1, 2018 at 13:38 Comment(4)
At that point, why not just spin up Graphile in a Lambda? Seems like AppSync isn't adding much value...Fry
I expected aws to provide such an functionality too! Using Graphile, graphql-yoga or apollo-server always means you need to run instances for websockets and requires to scale them. I guess appsyncs is smarter on that. Other than that I agree cazzerLackluster
I guess that now is possible to do it directly without any Lambda. Isn't it? I'm a little confused about how to do it well... :/Shanelleshaner
@Fry Graphpille does not support subscriptions which is a driver for the use of graphql. AppSync also ties into AWS Cognito user pools and makes authentication easier across services.Azotemia
B
1

yes this can be done.

Do take a look at this open-source repo that does exactly that: https://github.com/wednesday-solutions/appsync-rds-todo

Bretbretagne answered 12/7, 2021 at 5:1 Comment(1)
Welcome to SO! Don't post links to websites, as it might be broken or taken down in future. Instead, explain the solution.Wellfed
C
0

As of time of writing, yes but only if it is a Serverless Aurora RDS cluster set to Postgres compatibility. The reason for this is it's the only RDS instance type that supports the Data API. Other RDS instances would have to be configured as a different data source type, most commonly Lambda.

Cite answered 17/7, 2021 at 0:33 Comment(0)
S
0

2023-12-21; It would seem our wait is coming to an end!

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.enabling.modifying.all

We can now use Aurora Serverless v2 (Postgres only though) as an RDS resolver in AppSync.

Please note that only a few regions are supported ATM, but AWS is soon adding to all "major" regions!

Sloatman answered 3/1 at 14:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.