In my project, we create tables in AWS dynamodb based on the user id using AWS lambda (NodeJS).
Once the table is created the lambda function will create a graphql endpoint for that particular table so that the user can get real-time data for that specific table.
Can we create graphql endpoints which will also be seen in AWS appsync from AWS lambda (NodeJs)?
I searched the web but didn't find any tutorial from AWS nor any articles regarding it.
Well to be frank its will be very hard to achieve such functionality but if you still required then yes you can do that using AWS AppSync SDK
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/AppSync.html
From you tags assuming that you are using javascript.
Just my suggestion :- Dont try to do such things as it wont be easy to manage multiple app async and cost will increased x10
Related
Create an endpoint in AWS where data can be sent in a JSON format which can be stored to a data store.
I think i can write a terraform code to create a Amazon API Gateway, lambda fuction to accept json format and store in DS.
What should i do to build a CI CD around this?
Any idea on this..
There are many ways - for an automated way to provision infrastructure during your CI/CD pipeline, use Infrastructure as Code.
You can use Terraform, CloudFormation YAML/JSON, AWS Cloud Development Kit (CDK), Serverless Framework (depending on your data store) etc.
If all you need is a Lambda, API Gateway and a serverless data store like DynamoDB, the quickest way to get set up in my opinion would be the Serverless Framework, however, all are viable solutions.
I am part of a student group that is trying out AWS and trying to build a VERY small basic severless application. We did one of the AWS
tutorials ( https://aws.amazon.com/getting-started/hands-on/build-web-app-s3-lambda-api-gateway-dynamodb/?nc1=h_ls ).
So now we have this web app where we can save names in a DynamoDB. But how can we access the DynamoDB with Lamda/ Frontend (JS) to get elements out of it and display the information? All these services with API Gateway, DynamoDB and Lamda and how they work together is quite confusing. We can't figure out how to use a simple REST API to get elements out of the Database.
Can anyone help us out? Thanks in advance!!
Try using one of the strongly typed AWS APIs to build an application that uses Amazon DynamoDB. There is a Spring based example that builds an application that performs CRUD operations on data located in an Amazon DynamoDB table. This example uses the Enhanced Client that perform data mapping between Java classes and a table.
Map items in DynamoDB tables
Link to the AWS tutorial that uses the Java API V2 is:
Creating the DynamoDB web application item tracker
Likewise, here is a JavaScript example that uses Amazon DynamoDB:
Build an app to submit data to DynamoDB
If you are using the boto3 libraries, they are fairly well documented.
In this case, you probably want to look into the get_item method of the dynamo client.
I'm trying to create an external API using AWS API Gateway that will give users access to data stored in multiple databases. The APIs will mostly be accessed through scripts rather than through a web UI.
Are there any AWS services I can use to manage user access to my API?
I've read a little bit about Amazon Cognito and OAuth 2 but at a glance it seems like those might be more targeted towards cases with a UI for users to interact with. Is there a way to create and manage API keys with AWS?
Thanks in advance for your help!
You can use API Gateway Lambda Authorizer to write your custom login integration. For example a lambda that check in one Database if the user:password (passed as authorization header) exists in table in DynamoDB or SQL.
So I am relatively new to AWS and AWS Amplify helped me write my backend app a lot. I know AWS Amplify does offer a NoSQL database direct connection, but that's connected to DynamoDB, which is also a NoSQL database, but it's not the type of NoSQL database I want. I want document type BSON NoSQL database. I was wondering is there any easy way to connect to AWS DocumentDB or MongoDB using AWS Amplify or do I need to use aws-sdk or something else for that? Thanks
You can create a GraphQL API for Amazon DocumentDB and use this API as your amplify backend application as explained in this documentation.
To create a GraphQL API for Amazon DocumentDB, you can use Lambda resolvers. Please refer to tutorial on using Lambda Resolvers here.
Amazon DocumentDB connection and related queries will be defined in the lambda function.
Is it possible to have business logic on my AppSync's mutation when the datasource is dynamoDB?
I'm fairly new to GraphQL and Appsync. My understanding is when you're using plain GraphQL you can have business logic inside your resolver to validate before updating. How would you achieve the same thing with AWS AppSync when you pass it the GraphQL schema with DynamoDB as the datasource?
In AWS AppSync, you would attach a resolver to the field that is mapped to the DynamoDB DataSource. You can then use the Velocity template to have your custom business logic inside the resolver for any validations.
Please refer to the following documentation on the Resolver Mapping Template programming guide from AWS.
Here is the mapping template reference for DynamoDB resolvers.
According to AWS AppSync's Website: With AppSync, your app can access data in Amazon DynamoDB, trigger AWS Lambda functions, or run Amazon Elasticsearch queries.
You can think of it as a gateway for clients to access different backends (data sources), defined by mapping templates attached to GraphQL fields (resolvers).
AppSync supports DynamoDB and ElasitcSearch queries natively, but if you want to perform business logic you will have to add a AWS Lambda data source and then use AWS SDKs to R/W DynamoDB or anything else such as another API or maybe even an excel file!
Additionally, you can use Apache VTL along with AppSync's available helpers such as $context to help you perform authorization or field data access based on permissions. Keep in mind that your DynamoDB or ES resolver can only perform 1 operation at the end, Apache VTL only helps you build the resolver that will be run by AppSync.
Here are two diagrams that compare a traditional approach vs appsync