iTranslated by AI
re:Invent 2024: The Versatility of AWS AppSync - From GraphQL to AI Integration
Introduction
By transcribing various overseas lectures into Japanese articles, we aim to make high-quality, hidden information more accessible. This project presents the following presentation!
📖 AWS re:Invent 2024 - I didn't know AWS AppSync could do that! (FWM203)
In this video, Principal Product Manager Brice Pellé and Senior Developer Advocate Michael Liendo explain the diverse ways to utilize AWS AppSync. They introduce a wide range of AppSync features with actual demos, including flexible data access via GraphQL, real-time event processing utilizing AppSync Events, and its use as a Generative AI gateway in collaboration with Amazon Bedrock. Notable highlights include Gartner's prediction that corporate GraphQL adoption will rise to 60% by 2027, the simplification of WebSocket communication implementation through AppSync Events, and the expansion of enterprise-grade features like Private APIs and Merge APIs. Through demos of concrete use cases such as chat applications and real-time translation, they showcase practical ways to leverage AppSync.
This article was automatically generated from the video. Please note that there may be typos or incorrect content, so please watch the video for accurate information.
Click on the images to jump to the corresponding scene in the video.
For other transcription articles related to re:Invent 2024, please check this Spreadsheet. Be sure to check it out!
Main Content
Exploring the Possibilities of AWS AppSync: Session Overview
Thank you for joining the FWM 203 session, "I didn't know AWS AppSync could do that!" The fact that you are here suggests you are interested in AppSync and want to learn more. The goal of this session is for us to have a conversation that makes you think, "I didn't know AppSync could do that!" or "I didn't realize AWS AppSync had a solution for the challenges my organization or team is facing."
I am Brice Pellé, Principal Product Manager on the AWS AppSync team. I am joined by my partner, Michael Liendo. "Hello everyone. I am Michael Liendo, a Senior Developer Advocate at AWS. I was originally on the Amplify team, then moved to the AppSync team, and currently serve as a Developer Advocate for the North America region. We have some fantastic content prepared for you today. The title of this talk was my idea. In this session, you will see five demos showing different use cases for AppSync. There will be a point midway where you'll need to take out your smartphones and scan a QR code, but I'm sure you'll have fun with it."
In the agenda, we will look at several topics. First, we will discuss flexible data access through AWS AppSync GraphQL, then move on to real-time events via AppSync Events, and finally, how to use AppSync as an AI gateway for Generative AI backends. Afterward, we will detail the security and operational features we provide to make API handling and management easier.
GraphQL and AWS AppSync Basics: Comparison with REST and Benefits
Now, let's look at GraphQL, especially AppSync GraphQL. Before going into detail, how many of you have used GraphQL before? Quite a few hands. And among those, how many have used AppSync? A bit fewer, but still quite a lot. To establish a basic understanding, I'd like to first explain what GraphQL is.
GraphQL is a query language for APIs. Essentially, it's a specification that allows you to define the functionality and characteristics of an API. You can define a fully typed document that defines the queries, mutations, and subscriptions available in the API. The difference from REST is that in GraphQL, the client makes a single request, which is resolved by the GraphQL API (in this case, AppSync), allowing interaction with multiple data sources in that single request. A key point here is that GraphQL and GraphQL APIs handle a lot of the heavy lifting, meaning less work on the client side. The client can request specific data in a specific format and receive the data in the format they requested.
GraphQL is enhancing API development, and the data supports it. According to Gartner, by 2027, over 60% of enterprises will use GraphQL in production, a significant increase from less than 30% in 2024. GraphQL has been around for quite a while, but according to this forecast, it's still in its relatively early stages. Over the next few years, we expect many companies to start moving in this space and introduce GraphQL into their production environments.
When getting started with GraphQL, there are several choices. You can choose self-hosting to implement your own solution, but that can be a very tedious task.
When thinking about hosting solutions, starting on a small scale is easy, but deploying to production or enterprise environments comes with numerous challenges. Self-managing GraphQL is complex, costly, and tedious, but there is a better way. That's why we introduced AWS AppSync, which allows you to deploy fully serverless and fully managed GraphQL APIs. Being serverless with less code leads to reduced complexity, and it's also completely secure and high-performing. These are top priorities when implementing features. Since AppSync is fully managed, you can get started quickly with less code and trust that your API will scale reliably based on demand.
Integrating AWS AppSync with Existing Infrastructure
Currently, many customers use AppSync GraphQL. This is just a sample of our customers using GraphQL. You can see more detailed case studies on the AWS AppSync online page. When starting with GraphQL, you might think about your existing REST APIs. I view GraphQL as an enhancer that can strengthen REST APIs in various ways. GraphQL is highly compatible with REST, and if you want to add new features to an application currently using REST, you can achieve that by introducing GraphQL alongside the REST API. You can use the Strangler pattern to gradually remove features from the existing REST API and migrate them to the GraphQL API.
Integrating GraphQL and REST APIs
These two technologies can coexist. It is also possible to build GraphQL on top of a REST API, which is a common pattern called Backend for Frontend (BFF). In this pattern, you use AppSync as the BFF for your application. You can implement client-specific user experiences with the AWS AppSync GraphQL API. This allows you to specialize the GraphQL API for very specific purposes while keeping the REST API simple and generic, serving multiple applications. Finally, GraphQL is also excellent for real-time integration with REST APIs. When talking about real-time, many customers using REST implement polling to get real-time notifications. Instead, if you use AppSync and leverage AppSync subscriptions, you can transmit real-time notifications to the API via WebSockets. Implementing this with AppSync eliminates the need for polling, reduces the load on the existing REST API, and enables more efficient, low-latency implementation.
Implementing the BFF Pattern with AWS AppSync and Flexible Data Access
Let's take a closer look at the BFF pattern. Many customers adopt this pattern for various reasons. It's a great choice for frontend teams because they have complete control over their own BFF deployment. The BFF deployment is closely tied to the specific user experience you are trying to achieve in your application. Instead of worrying about interacting with a generic API, you can use something customized specifically for your frontend application and develop at your own pace. On the other hand, REST APIs remain simple and generic, allowing them to evolve independently with a clear focus.
Let's look at a simple example. Suppose we need to implement a weather API for a new application using the API provided by api.weather.gov. The requirements are to retrieve weather information including location, general forecast, and hourly forecast. When using the api.weather.gov API, you cannot achieve this with a single request, but you can by implementing a BFF. First, create an API schema and define a getWeather query. getWeather takes two arguments, coordinates X and Y, and returns a point. This point contains multiple fields, including forecast and hourly, which need to be resolved. You need to link these fields to a data source. The next step is simply to create a data source pointing to the REST API. As you can see, it's very simple—you just define an HTTP endpoint in the console. This data source can be reused in any resolver within the API.
Implementing the BFF Pattern with AWS AppSync and Flexible Data Access (continued)
Implementing the resolver for getWeather is very simple. In the request handler, you just specify that you want to send a GET request to this resource path. You can see that the coordinate arguments X and Y are passed into the request. Once you receive the response, you can extract properties from the HTTP response. One thing to note here is that we are retrieving grid information. And you can see we are doing a simple transformation of the returned data.
Pay attention here to gridId, gridX, and gridY. Using these results from the first request, you can construct a new resource path to perform additional requests for the forecast and hourly fields. These are resolved in a single request handling at the GraphQL API level. Looking at what is happening in X-Ray, you can see that we make one request and there is a getWeather query at the top. This is the first request made by AppSync, but it performs two requests in parallel to resolve the remaining fields and processes everything before returning the data to the client. What would typically require three or more requests from the client can be achieved with a single request using a BFF. This is part of the power that AppSync implementation brings.
Enhancing Data APIs and Pipeline Resolvers
Regarding APIs, I mentioned that AppSync not only enhances REST but also enhances data APIs. One of the current strengths of AppSync is its ability to interact with Amazon Aurora Serverless. With Amazon Aurora using the Data API, you don't need to learn anything new. You simply write SQL in JavaScript. We provide utilities that you can use to write SQL. Here, there is a template string function that allows you to simply write SQL and pass parameters. This is secure because when those parameters are seen, it creates a query string with placeholders and sends those parameters to the placeholders - it is much safer than doing it manually or from the client.
We also support integration with Amazon DynamoDB. I believe this is one of the features we have provided the longest. AppSync and DynamoDB work very well together, making it one of the simplest ways to interact with DynamoDB tables. We also provide utilities for executing queries, updates, and mutations. Therefore, you do not need to learn the slightly complex syntax that DynamoDB suggests. Using our utilities, you can easily execute update operations with simple JavaScript, such as conditionally incrementing a field, which would be slightly cumbersome in normal DynamoDB syntax.
Pipeline Resolvers and Advanced Integration
You can also use Pipeline Resolvers. With Pipeline Resolvers, you can call multiple data sources in order without requiring additional compute. In your GraphQL API, you can call a Pipeline Resolver to call a DynamoDB function and then use the result of that query to build another query for an Aurora database. Here is an example of a Pipeline function. First, it accesses a DynamoDB table to retrieve an item using the ID passed as an argument. After obtaining the result, the second function, executed in sequence, can build an SQL query using the result from DynamoDB. You might want to use a DynamoDB table to retrieve a single item and an Aurora database to execute an arbitrary query. That is also fine; you can combine data sources, and they work very well with AppSync.
Demonstrating a Real-Time Chat App with AWS AppSync
That covers API enhancement, REST enhancement, and data source enhancement with AppSync GraphQL. However, to show its true power and capabilities, I would like to move on to our first demo. I'll pass it over to Michael now. Thanks, Brice. There are a few key points Brice touched on. The true power of AppSync lies in its direct integration capabilities. We've looked at Aurora, DynamoDB, EventBridge, Lambda, and more, and I'd like to show you a demo that serves as a "Hello World" for all of these. The most basic example is a chat app. In addition to standard operations, you also get real-time WebSocket support. Let's take a look. As you can see, this is my amazing chat application.
AppSync can integrate not only on the backend side but also on the frontend side. Amazon Cognito is a perfect use case for integration with AppSync, forming an ecosystem where services work together.
Let's set up an email address along with a password. I'm currently setting up the chat application. We need to create a room. AppSync communicates directly with Amazon DynamoDB to create the room. Let's call it "cool reinvent people." The room has been created, and we've navigated to this URL. You can start by typing a message here.
Several things are happening while I type here. This is an actual deployed chat application. You can chat with me if you access the URL, but I'll explain that later. When I enter a message, I type "hello," send it, and it's saved. If you refresh the page, the message appears immediately. In addition to simple text, you can also save Amazon S3 image IDs and the like. I'm often asked, "Michael, how do you integrate S3 with the API?" It's simple. You just take the S3 key and append it to the AppSync API.
Here is a wonderful image. Let's try importing this. If the internet connection is sufficient, I can send this image. So far, AppSync has communicated with DynamoDB, and that real-time connection has come back to my application. If you access this URL, you can chat with me, and you can use real-time features in addition to create, read, update, and delete operations, all within a single API. This is the least interactive demo of mine, but it's enough as a "Hello World" to get started. A chat app is usually the first step to starting with AppSync. I'll pass it back to Brice. What I like is how easy it is to set up. Usually, you would need to set up the entire infrastructure of AppSync, DynamoDB, and S3, but this alone completes the setup.
Real-Time Experiences with AppSync Events
Now, let's go back to the slides and move on to the next section on real-time experiences using AppSync Events. Many of you here are using AppSync, and you're likely using it to leverage GraphQL. We've been running AppSync for many years, and many customers use it for the benefits of GraphQL. However, many customers choose AppSync specifically because they want to use its subscription capabilities.
Currently, customers use AppSync subscriptions to implement real-time experiences in their APIs. Many customers do this, and for good reason. If we think about the applications we use daily, we can find examples of real-time everywhere. Whether you're a sports fan, online shopping, or in a group chat like Michael just showed, real-time experiences exist everywhere to provide a better experience for customers.
When you check a score on your favorite sports site, you don't want to refresh the page repeatedly to know the situation. When bidding on a product, you shouldn't have to refresh the page to see the latest price updates or if an item is out of stock. As such, real-time experiences are crucial for modern web applications. These are examples of event broadcasting, but they become even more important from a collaboration perspective. When thinking about collaboration where multiple users work together, real-time is even more critical. It is essential to be able to convey relevant information with very low latency. When updating location information for turn-by-turn navigation, low latency is critical, and being able to send the right information to the right person is equally important.
We see real-time experiences everywhere, but actually realizing real-time features is a bit difficult. As I touched upon a little earlier, when using REST APIs, you end up relying on a technique called polling to get real-time updates.
On today's internet, this polling method using REST APIs is a common way to get real-time updates, but it is not truly efficient. Because the client is in a constant loop of updating data, it places a heavy load on the client side. It is also inefficient for REST endpoints—in large-scale implementations where hundreds of applications are polling, it causes a significant load on the backend. This leads to unnecessary resource consumption and poor scalability.
As another option, you can also implement real-time updates using WebSockets. This is a great option in terms of low latency. However, WebSockets only provide semi-persistent connections and do not provide connection management features. This leads to several challenges: How do you track message delivery to multiple recipients? How do you handle tracking multicast or group messages? How do you manage autoscaling? Effectively managing WebSockets involves significant complexity. Furthermore, if you implement this yourself, regardless of the approach, you will need a massive amount of backend code. Thinking about this, you end up spending time on these technical challenges when you should be spending time developing features that are truly important to your end users.
The Solution: AWS AppSync Events
Looking at the options for building real-time experiences in AWS today, there are several choices. You could use Amazon API Gateway WebSockets, which provides a managed WebSocket API, but you have to handle connection management yourself. You could use AWS IoT Core—this is a great service and is suitable for IoT devices. However, if you have web or mobile applications that require authentication modes other than certificates or IAM roles, friction may arise. You would also need knowledge of MQTT and use of the MQTT SDK. Finally, there is AWS AppSync GraphQL. This is a great service—I might be a bit biased as it's my service—but it requires GraphQL knowledge. Sometimes customers don't need the features of GraphQL and are simply looking for the subscription component and managed WebSocket scaling capabilities.
We consistently received requests from customers for a purpose-built Pub/Sub solution for creating real-time experiences. That is why we developed AWS AppSync Events. We believe this is the easiest way to build and scale real-time experiences. AWS AppSync Events provides a fully managed Pub/Sub WebSocket API, allowing you to implement real-time experiences in minutes—or rather, seconds. This reduces operational overhead, improves application performance, and makes it easy to start at a low cost.
AppSync Events: Features and Implementation Examples: Simplicity and Scalability
AppSync Events is fundamentally simple—it is a WebSocket system where publishers push data via HTTP endpoints and subscribers can subscribe to channels via WebSockets. That is all you need to know. No special libraries or complex implementations are required. You can leverage all the previous benefits of AppSync, but all you need to do is configure and use channels. It is so simple that I would like to pause here and have Michael demonstrate the cool features of AppSync Events.
The reason I enjoy my job is that Brice, a Solutions Architect and Project Manager, often brings requirements to me and asks, "Michael, can you build something cool?" and I can answer, "Yes, I can." Let's look at some of the demos listed on this page. First, I have a Chrome extension titled "re:invent/FWM 203." For those of you who want to take out your smartphones and scan the QR code, you need to enter "re:invent/FWM 203." Oh, wow, it is already working! For those who haven't caught up yet, I repeat—it is "re:invent/FWM 203." At this moment, I am not using GraphQL, Amazon API Gateway, or anything else; I am only using AppSync Events.
This is built with WebSockets, so it is realized solely through AppSync Events. Pretty cool, right? All I did was place a publisher in each of your applications. The sites being displayed are on completely different domains, the WebSocket is running inside the Chrome extension, and it is picking up these events and displaying all items on the page.
In a typical polling solution, this would never work. Expecting to display 50 messages, wait 0.5 seconds, and poll again is not realistic. This is the brilliance of AppSync Events in an auction site scenario. Everything works smoothly until the final 5 seconds when everyone tries to place their last bid. It is a perfect use case. This is an example where one client is receiving a large volume of events simultaneously. This is a demo page, but for those who want to see the code later, I should mention that the AppSync code is only about 20 lines. Of course, I created the Chrome extension separately.
We looked at a simple chat, which is very cool. Another use case is a real-time leaderboard. I am on a different domain now, so emojis are no longer displaying. Some of you might have played "Connect Four." I will enter my username—for those who don't know me, I use the name "focusotter" everywhere online. Let's generate a new game code. I will start a new game. I'll take a moment for those who want to scan the QR code and join. Basically, it will be a battle between me and all of you, which is not a very fair fight. Does anyone want to challenge Michael?
However, at the same time, you have to compete with the person next to you to place your tokens first. We have the site and the QR code, so let's start the game. You don't need an API for this. There are good and bad sides to that, but if you refresh the page, everything disappears. However, since this is a Connect Four game, you don't need an API. It is a quick game. Since persistence is not required, we can use the chat application. Thank you to those who typed "hate." Now, let's play the game. If you are not playing, you are in spectator mode. This is the essence of real-time. I am trying to beat all of you in my own game. I think I am going to win.
This is what is happening right now. If someone clicks "New Game," both of our boards will reset. Everything is happening in real-time. We could have refreshed the page, but here you can see the effect of AppSync Events. This is real-time data that does not require a dedicated API. Let's head back. That was an amazing demo. Please give him a round of applause. That really was wonderful. The presentation is not over yet, but that was a very good demo. AppSync Events is functioning in this project and achieving results. It has been a wonderful adventure for me, the AppSync team, and all the engineers.
As you can see, one of the things we really wanted to achieve with AppSync Events is simplicity and scalability. Speaking of simplicity, we want people to be able to get started quickly. You can go to the AppSync console today and create an API with just one click of a button. This is an API you can start operating in the AppSync console immediately, and it is an API capable of supporting hundreds of thousands of connected users right away. Getting started is very simple. You can publish events to channels via HTTP and subscribe to channels via standard WebSockets. It works at any scale. I will show you the default quotas a few pages later, but it is available now, and you can already publish 1 million messages per second without requesting quota increases.
It is available in all approximately 30 regions where AppSync is available, and custom domains, AWS WAF integration, CloudWatch logs, and CloudWatch metrics are ready to use. In other words, integrations with your favorite AWS services are already available.
This allows you to reduce operations. It is very simple, and you don't need to get bogged down in details. You can really focus on business logic and what is most important to your customers. Overall, you can reduce costs because you do not need to manage the service. There is a generous Free Tier, so please feel free to try it out if you are interested. The Free Tier offers 250,000 operations per month, and after that, it is $1 per 1 million API operations.
Leveraging AWS AppSync as an AI Gateway: Integration with Amazon Bedrock
I would like to explain in a little more detail how the AppSync Event API works. Earlier, I mentioned that you can publish via HTTP and subscribe via WebSockets. The key concept you define in AppSync Events is the "Namespace." A Namespace is a logical resource that defines the functionality of channels. To be specific, if you had a Namespace "A," this "A" would be the prefix for all channels created within that Namespace. Channels are temporary and can be created as needed. The Namespace itself is what is persistent. For example, there is a channel path "/A/ABC/DF/XYZ," but you do not need to create this channel path in advance. You or your clients can create it on demand.
Within a Namespace, you can set up publish handlers. If you want to create custom logic to transform data when publishing, AppSync makes that possible. You can create unsubscribe handlers to specify particular authorization rules you want to apply when a client connects. You can also override the default channel authorization. Remember that you can create up to 50 Namespaces by default, but you can create an unlimited number of channels within a single Namespace.
As those who use AppSync know, we support multiple authentication modes, and all of them are supported in AppSync Events: Amazon Cognito User Pools, API keys, AWS Lambda custom authorizer, OpenID Connect, and IAM. This is a wonderful feature because in actual implementations, you do not need to worry about how to support methods. IAM is perfect for publishers hosted in Lambda functions or publishing from EC2 instances. API keys are convenient for development, and Amazon Cognito User Pools are ideal when you want to specifically identify each user connecting to the WebSocket.
To briefly summarize the quotas and pricing: outbound messages are 1 million per second, inbound messages are 10,000 per second, and new connections are 2,000 per second. These are default quotas and are all adjustable, but we believe they are sufficient in scale for getting started. Please try AppSync Events. Go into the AppSync console, try it out, and use the Pub/Sub editor directly in the console. Take a look at the blogs we have published—including my own and several of Michael's—which you can easily find online. It is very easy to get started.
Let's change topics here and talk about Generative AI, because a presentation without mentioning Generative AI is unthinkable now. Generative AI is everywhere, and it is impossible to avoid. There is significant value in Generative AI and LLMs, and they are changing the way we actually work. This is the same for every situation and for our customers. Customers are realizing the benefits of Generative AI and want to seize this opportunity. So, they are asking AWS questions like: "This is great. We have these LLMs and foundation models, but how do we get started? What should we use? How can we proceed quickly and securely?"
This is why AWS created Amazon Bedrock, and I believe this has been a major game changer. You can interact with multiple foundation models, and it provides a great deal of functionality, such as model testing, working in the console, using guardrails, and model customization. It truly is the best way to interact with foundation models.
However, when building applications, customers are still facing several challenges. Thinking about application connectivity, something residing somewhere on the web needs to connect to a model inside a private cloud, and there are several challenges to solve there.
The first challenge is connectivity. When connecting an application to a backend, you must appropriately control access for clients and how models are accessed on the backend. This is extremely important because you want to be able to decouple the frontend and backend. What you absolutely want to avoid is backend credentials leaking in the frontend application. Using credentials to access a Generative AI backend on the client should be avoided. Also, you want to create an abstraction—that is, decoupling—that separates models and prompts from the client.
Another point that many customers are struggling with is flexible request processing. Those who have experience using Large Language Models know that while models return responses quickly in some cases, in many cases it takes a considerable amount of time to return a response. Therefore, you need an API that can handle both synchronous responses and asynchronous requests. Furthermore, for chatbots that take time to respond, it is not an optimal customer experience because many users will not maintain their focus for that long. If it takes more than a few seconds to respond, users tend to leave the page. You need to be able to provide step-by-step updates so users can get immediate feedback that processing is proceeding normally without relying on polling or unnecessary requests.
Another important aspect is being able to provide context information regarding the requester when making requests or calls to models. That is, who is requesting the data, how to identify that user, and how to augment prompts to provide user-relevant responses. The last challenge is the evolution of flexible models. You start with one model, but the situation changes rapidly, and new models appear every week or two or every month. You want to build an API that allows you to switch models and evolve prompts without affecting the client. By keeping prompts on the backend without exposing them to the client, you want to be able to change those prompts without causing major disruptions or impacts to the client.
This is why I believe AWS AppSync is an excellent solution as an AI Gateway, especially as a backend for Amazon Bedrock. It provides an environment where you can safely interact with Amazon Bedrock, provide real-time solutions for long-running workloads, and maintain control over user models and user access. You can combine the excellent features of GraphQL with the functionality provided by models and LLMs.
I have already explained AppSync, but one of the important points is the authentication modes AppSync provides. When building applications, you need to provide various authentication modes, and since they are provided in a ready-to-use state in AppSync, that separation is already realized. In AppSync, you can interact with Bedrock data sources in multiple ways. Using the Amazon Bedrock data source we introduced a few weeks ago, you can connect to Bedrock right now. You can also use an AWS Lambda function as an orchestrator, send requests to the Lambda function to interact with Bedrock, and use this to implement long-running processes. You can also use HTTP endpoint data sources. Many may not know this, but there is a data source called an HTTP data source that you can use to communicate with AWS service APIs. It proxies the request signature, allowing for extremely flexible communication. You can communicate with any AWS service.
This allows you to decouple frontend authentication from backend authentication. What's important here is not only that you can decouple in this way, but also that AWS AppSync can set specific permissions for communicating with Amazon Bedrock. You can set permissions to communicate only with specific models, specific guardrails, or specific prompts for the Amazon Bedrock data source. This is a very powerful feature that allows you to manage how the API interacts with Bedrock.
Also, a trend we see among many customers is the use of AWS AppSync Private API to support AI Gateway implementation. Many enterprise customers are beginning to utilize LLMs and Generative AI, but they do not want to expose those solutions externally. Basically, they are building internal APIs, and by using AWS AppSync Private API, they can keep all of this private within a VPC. By using Private API, you can restrict the API to a VPC, making it an optimal solution for private deployments.
Let's look a bit more closely at calls. You can call Amazon Bedrock models using HTTP resolvers. This is a very simple method when it is known that the response will return in under 30 seconds. As a latest feature, there is a direct integration that allows you to use Bedrock Runtime data sources in AWS AppSync. This is ideal for simple integrations called micro-calls (calls under 10 seconds). There are specific use cases where this is suitable. It allows for better control and can directly interact with the Invoke Model and Invoke Model with Conversation APIs.
I will introduce a simple example using this. My schema has queries and assistant queries, which allow me to send natural language query requests to the backend model and ask it to convert them into actual SQL queries. When sending a request to the assistant, I instruct it to return the SQL results. The SQL results defined here include the SQL string, parameters, and description. What I like is that by mapping this type to AWS JSON format, this becomes the format you can use when calling via the converse API.
This is the request I am executing in my JavaScript resolver. Using the new converse utility, I am interacting directly with the Bedrock Runtime. This is the same type of function seen in other AWS SDKs. Those who have used the converse API in JavaScript or Python SDKs will recognize it as exactly the same thing. I am using Claude 3.5 Haiku. I send messages, specify tool settings, and specify the system as a database assistant. Depending on whether I want an explanation or just an answer, I instruct it to "explain the answer" or "do not explain the answer." When interacting with LLMs, you need to provide very specific instructions.
What kind of results do I get when I send this request? For example, I send a request like, "What was the best-selling product shipped to Las Vegas? Please explain the answer." Thanks to being able to specify the format using the converse API, the result returns in the exact format I requested. This is wonderful—structured output makes the work easier. When building backend APIs, you can also use the invoke model API to interact with models like Amazon Titan. You can use this to perform summaries. Similarly, you can use the invoke model API to create embeddings.
Embeddings are a wonderful feature. This is because if you obtain embeddings, you can perform similarity searches in an Amazon Aurora database. I have already talked about how easily you can integrate with Amazon Aurora, and here you can perform similarity searches using embeddings created from requests to Bedrock. Finally, this is about synchronous patterns. I will introduce how to create long-running calls using AWS AppSync. When a client sends a request to AWS AppSync, an asynchronous call is sent to an AWS Lambda function. This does not have to be a Lambda function; it could be a service like AWS Step Functions. And when this Lambda function interacts with Bedrock's stream API and Bedrock's stream API returns step-by-step updates, the Lambda function sends mutations to the client via AWS AppSync, which in turn triggers a subscription.
Just by using the AppSync API, you can obtain real-time updates for long-running queries running on Bedrock. This is an important pattern. You will participate in many sessions at re:Invent, and you will see these patterns using AppSync. This is very important. Because many customers are becoming able to implement real-time notifications or real-time patterns for long-running queries using Bedrock.
AppSync and AI Fusion: Demo of Real-time Translation and Summarization
Now, let me show you more demos. I'll take over for Michael to show you how it works in practice. In the Emoji Thrower application earlier, we had to specify a Channel ID. I specified it, and you all had to as well. Now that we're in sync, we can exchange messages bidirectionally. This is great. And we can change it to something like /reinvent/some-other-session and deliver messages there too. Of course, you would need to subscribe to that channel as well.
However, as Bree explained, when moving toward long-running tasks or the recent trend of Generative AI, how do we return information to the application? There is direct integration with Amazon Bedrock, which I will show you later. There are also simple use cases. For example, if you want to throw an image into an Amazon S3 bucket in your application and run a Generative AI task. You can use an AWS Lambda function for that, but how do you return the result to the application? If you need real-time data that exceeds the 15 or 30-second timeout, it's a surprisingly difficult challenge. How can we achieve this with the Event API?
So, I'd like to introduce a demo for a groundbreaking startup called "SnapScribe." It's very simple. When you sign in to the application, you can upload a photo, and the processing shown in the architecture diagram earlier is executed. You can reference the photo. Let's use the same image from the architecture diagram I showed earlier. I received a message. This is the first asynchronous event from the Lambda function. And when the processing is complete, the update should appear immediately. Yes, it appeared.
Let's zoom in and take a look. Indeed, the image shows the architecture diagram. What's wonderful about this is that you can run Generative AI tasks in a Lambda function without worrying about processing time. Because, in the end, the result is returned to the application. The frontend application is just listening, not polling. That's SnapScribe, but it gets even better. This is an example of a long-running task. If you want to check the code, as Bree said, it's actually not that difficult. This is the exact code I used to create the application. These are the necessary roles. Basically, here, Claude is doing a lot of the work for Cross-Region inference.
And when connecting data sources, you just go down to the CDK Level 1 Construct. Here is the AppSync API, and here is the Amazon Bedrock runtime. This is the important part. Then you pass the ARN of the role and associate it with the new data source. It doesn't need to be complex, and it's a shame that it was in the past. Now, here is a demo that requires your help. What about short-duration tasks that need results within 12 seconds, rather than long-running tasks that might take 15 minutes?
I would appreciate the last QR code. This application requires a sign-up. I'll continue my explanation while you authenticate with Amazon Cognito and receive a confirmation code. I'm sure it will be worth it. This is a chat app. It feels like we're back at the first chat app. We couldn't actually participate in the first one, which wasn't very interesting. This app is much better. Let's type a message here. I speak English and Spanish. These are the two languages I know. Unfortunately... or rather, fortunately, our world has many wonderful languages. Let's type "hello, everyone. Welcome to re:Invent" and press enter. You may notice that it doesn't appear immediately—it's very fast, but not instant. The reason it doesn't appear instantly is because AppSync is using a Pipeline Resolver to communicate with the Bedrock data source, and that data source is communicating with DynamoDB to save the message to the database.
Thank you, Ellis.
We did it, but I don't know you all very well, and some of you might be more comfortable with other languages. If you speak Spanish, you can switch to Spanish here. I'll keep the default language set to English. Yes, everyone is saying "Ola" and "Cómo estás." There is also Simplified Chinese. You can also switch to Italian. And here is the important point: it's designed to handle any language you enter.
Several things are happening here at the same time. As I mentioned earlier, this is a quick-read task. It's doing a few different processes. You've authenticated with Cognito, and sign-in was required. AppSync integrates directly with this. Also, every time you send a message, a translation occurs, which takes a little time. The message is saved. However, I can use another direct integration with Bedrock to summarize the conversation here. This is a bit scary—I'm trying this part for the first time. Taking all these messages... yes, it worked. Basically, it shows that everyone here is participating in re:Invent. re:Invent is the test. This is the power of Bedrock.
Some of you might be curious about what the code looks like. It's very complex. By complex, I mean this summary code. It's only 15 lines, basically just taking the chat conversation and instructing it to describe what it sees in under 100 words. Just summarize it for me—it doesn't need to be complex. And again, this is because AppSync makes it that easy right now. As a small point to note in your own tests—I'll add a small asterisk here—it's very important to use the right model for the job. Many people use Anthropic's excellent models because they can do anything. However, in this case, as you can see, I am using Titan. Especially regarding summarization, I think it's the best model I've ever used, because it's trained specifically for that.
However, as an application—AppSync is the winner. Thank you all for your comments. No, Falcon. There's no filter for inappropriate language here. But the wonderful thing is that you can prevent it by using Guardrails. What I really like is that in the Resolver integration, you can set a Guardrail config, which actually handles a lot of inappropriate expressions. This isn't shown in this demo, but please use a Guardrail config in actual implementations.
As you can see, there were six demos—real-time AI, long-running tasks, short-running tasks, AppSync, GraphQL, and AppSync without GraphQL. There are many options here. And this is just one service that helps many developers. I might be rushing to a conclusion, but I think you've gained some insights like "I didn't know AppSync could do that." Now, back to the microphone.
AppSync Security and Operational Features: Merge API and Private API
We're almost at the end. Before we finish, there's one more thing I want to talk about. I mentioned I would talk a little about the security and operational aspects. While AppSync GraphQL Events and AppSync as an AI Gateway are wonderful features, the reason we can provide these excellent features and customers can leverage them is because of enhanced security and operational functionality. This is an important point not to be forgotten. One of the things you should know when considering introducing AppSync and evaluating it for your own applications and enterprise is that AppSync is built with security in mind. We provide many excellent security features, which you've seen in the multiple authentication modes and methods of interaction we provide.
For example, in interaction with data sources, you can set permissions to allow, deny, or limit access. These are basic considerations when implementing services including support for Private API, cross-account functionality, and Merged API features. This is the easiest way to start using many features necessary for application growth, share applications with multiple developers, and transition to a production environment. One of the key features we provide is Merge API.
Let's look at this quote from Gartner. They predict that by 2027, 30% of enterprises using GraphQL will be using GraphQL federation. This is an increase from less than 5% in 2024. The concept of GraphQL federation is the embodiment of combining multiple GraphQL APIs into a single API gateway. This is particularly attractive to enterprises. This is because federation allows multiple teams to own different parts of a GraphQL schema without interfering with each other. Each team owns its own API and schema, and these schemas are combined into a single unique API gateway that can be deployed to a production environment.
Our solution for federation is the Merge API. With this Merge API feature, you can combine multiple AppSync GraphQL APIs owned by different teams or different accounts into one integrated GraphQL API. This allows for team-to-team collaboration while each team continues to operate independently. The GraphQL Merge API is very simple—you have your own schema and can create merges using the console or API. It notifies you whether the merge was successful, failed, or if conflicts occurred, and you can resolve those errors using Directives. If you are concerned about a single API becoming too large and connecting to multiple data sources, consider Merged API and check how that federation approach can solve your business challenges.
One last feature I'd like to introduce is Private API. This is a feature widely used by enterprise customers who value privacy and want to keep their APIs private. Cross-account Private API was a feature strongly requested by customers. Customers wanted to create APIs in a central account and share them across multiple accounts. We released this feature just before re:Invent, leveraging AWS Resource Access Manager. This uses the standard AWS approach where you can share an API created in one account with another. A typical use case is organizations where all APIs must be created from a central API or network account due to auditing or security reasons. It's now possible in AppSync, and you can create all your AppSync APIs in a single account and share them with your application accounts using Resource Manager and AWS PrivateLink.
Many people are interested in event-driven architecture, and we support this in various ways. You can use AppSync as part of an event-driven architecture, and the backend can communicate with the frontend using Subscriptions. For example, it's possible to configure it so an Amazon EC2 instance publishes messages to Amazon EventBridge, and an AWS target in EventBridge sends that to AppSync. A similar configuration from frontend to backend is also possible, and as we saw earlier with Models and Amazon Bedrock, you can also realize asynchronous communication from frontend to backend using Subscriptions.
It's almost time to finish, but I hope this presentation was meaningful and interesting for everyone. For those who want to speak with us, we will be staying here for a while, so please reach out. It was truly wonderful to have you attend today's session and to be able to talk with you. Thank you very much.








































































































Discussion