How to make aws appsync api with existing api endpoint URL? - amazon-web-services

I am new to aws appsync api. Can anyone guide me for this question?
My Case:
I have one URL of RESTAPI endpoint which returns me JSON. Now I want to convert that RESTAPI to aws appsync api using that URL. How can I do that?

AppSync recently added a Rest API data source as an option and you can use this to map your rest api to a graphql interface.

You can use an AWS Lambda resolver to convert the REST API response to GraphQL in AppSync. The tutorial should help you get familiar with Lambda resolvers.

Related

AWS API Gateway + Swagger + Oauth

I am trying to create a new API using
AWS API Gateway (backed by an AWS Lambda)
Swagger UI
Authentication (OAUTH2 with Okta)
I can create a new service with Pythong + Flask + Swagger and host a docker container, which I can develop, but I'm trying to keep it serverless and use the combination of technologies in my list above.
Any help would be greatly appreciated!
I'm assuming you want to know more about the OAuth part using Okta. You'll have to create a Lambda authorizer that will perform the introspection of the token from Okta.
For the serverless API, you'll have to break your service into functions. An approach is to have one function for each RESTful resource+method:
GET /books/{id} -> getBookFunction
PUT /books/{id} -> updateBookFunction
DELETE /books/{id} -> deleteBookFunction
Lastly, if you have a well-defined Swagger file. You can use it to create your API in API Gateway. You may also use x-amazon-apigateway-* in your Swagger file and define your resource backend to refer to a Lambda function's ARN. Documentation can be found here
Yes, you're right, the question is more around how to integrate Oauth2 (Okta) with a swagger UI using AWS API Gateway.
API Gateway 2.0 already provide the ability to inspect the JWT token from Okta, so no need to create a custom Lambda there.
I'm not sure how to get this ability with redirects configured in a Swagger UI, and have the user login using the implicit/authorization-code Grant-Type and let the user interact with the swagger page.

Use HTTP API with AWS Amplify

I have the "new" HTTP API with a DynamoDB and lambda, I want to provide support for my app to the macOS computers. Is it possible to use the HTTP API Gateway with Amplify? I only see an option for GraphQL and REST
Thaks

Create an api in api gateway to invoke a lambda function

I am working on a project and trying to use API Gateway to invoke a lambda function. The lambda function is used to update a DynamoDB item. The DynamoDB table is used to keep a running count of visitors to a web page. I need to create an API to invoke the lambda function but I'm not sure how to create the API. Any assistance is appreciated.
General steps would be:
Create AWS_PROXY integration between API Gateway and your Lambda function. The example of this is in the AWS tutorials: Set up Lambda proxy integrations in API Gatewa and in Tutorial: Build a REST API with HTTP proxy integration
Add/amend execution role to your function allowing it to access DynamoDB. This is exemplified in the AWS tutorial: Using AWS Lambda with Amazon DynamoDB.
Test the API. It can be done directly in API gateway console, or using external tools such as curl or Postman.
I figured out my issue. In my lamdba function, I needed to change the output to a JSON object. Once I made the change, I was able to get my API working. Here is a link to the fix.

Do I have to use AppSync for apollo graphql in lambda?

I'd like to use apollo graphql in a lambda and I found AppSync is for graphql and API Gateway is for REST. Do I have to use AppSync for that?
I also find out a library apollo-server-lambda which can be used with serverless but I don't want to use serverless because all my infrastructure code is written in Terraform. I don't want to bring another IaC library in my application.
So is there a way to use API Gateway with apollo graphql in lambda? If yes, how should I declare API Gateway route for that?
Not really. You can just use the API gateway, Lambda, and Apollo Server. Install the npm library apollo-server-lambda and Import the required modules.
The current version of Apollo Server Lambda: 2.17.0
You can create a GraphQL handler using the function createHandler provided by Apollo server Lambda.
I am not sure about how it is done using Terraform but you can just declare a route to your handler function via the API gateway.
Make sure your GET and POST requests route to the same handler.
Refer to this documentation for more details: https://www.apollographql.com/docs/apollo-server/deployment/lambda/

Integrating AWS AppSync (+ Cognito) Schema with Graphene django on lambda

I've an AWS AppSync GraphQL endpoint with some DynamoDB tables and it is integrated with Cognito.
I've also developed a django application with graphql endpoint (graphene) and cognito integration that is deployed with zappa to a lambda function.
What is the best way to combine those two graphql endpoints, so that i can query them from one endpoint?
1- Appsync forwards requests to lambda with resolvers? (any examples?)
2- Intercept calls from api gateway and forward them to appsync? (less likely)
Thanks,
Alp