Improve real -time applications with AWS appsync events Integration Data Source | Amazon Web Services

Today, we announce that the AWS Appsync events now support the integration of data sources for channel names, allowing developers to create more sophisticated applications in real Top. With this new ability, you can assign AWS Lambda, Amazon Dynodb tables, Amazon Aurora database and other data sources with channel names. With AWS Appsync events, you can create rich applications in real time with features such as verification, event transformation and persistent storage of events.

With these new abilities, developers can create sophisticated workflow processing procedures for transformations and filtering events using Lambda functions or save a lot of events on dynamodb using the new Appsync_JS. Integration allows complex interactive flows and shorten the development time and operating overhead. For example, now you can automatically persist into the database without a complicated integration code.

First View of Integration of Data Source

Let’s go through how to set the data source integration using the AWS managing console. First go to the AWS Appsync in console and select the API events (or create a new).

AWS console image

Persistent event data directly on dynamodb

There are several types of data sources integration. In this first example, the life of the Dynamodb table is a data source. I will first need a Dynamodb table so I will go on a dynamodb in the console and create a new table called event-messages. In this example, everything I have to do is create a table with a partition key called id. I can click from here Create a table And accept the default table configuration before I go back to Appsync in the console.

AWS console image for Dynamodb

Back in Appsync console I go back to the API event I set up before, select Data sources from the navigation panel with impact and click on Create data source Button.

AWS console image

After I gave the name of the data source, I will select Amazon Dynamodb from Data source Drop -down menu. This reveals configuration options for dynamodb.

AWS console image

Once my data source is configured, I can implement the operator’s logic. Here is an example of a publishing operator that persists the events of dynamodb:

import * as ddb from '@aws-appsync/utils/dynamodb'
import { util } from '@aws-appsync/utils'

const TABLE = 'events-messages'

export const onPublish = {
  request(ctx) {
    const channel = ctx.info.channel.path
    const timestamp = util.time.nowISO8601()
    return ddb.batchPut({
      tables: {
        (TABLE): ctx.events.map(({id, payload}) => ({
          channel, id, timestamp, ...payload,
        })),
      },
    })
  },
  response(ctx) {
    return ctx.result.data(TABLE).map(({ id, ...payload }) => ({ id, payload }))
  },
}

To add the operator code I go to navigate Nappece where I find a new one default The name space has already created for me. If I click to open the default name space, I will find a button that allows me to add Handler of events Just below the detail configuration.

AWS console image

By clicking on Create event service Brings me to a new dialog where I choose The code with the source As my configuration, and then select the Data Data Source as my Publishing Configuration.

AWS console image

After saving the operator, I can test integration using the built -in test tools in the console. The default values ​​should work here and as you can see below, successful successful in my Dynamodb table.

AWS console image

Here are all my messages captured in Dynamodb!

AWS console image

Errors and Security Processing

New data source integration includes understanding of errors. For synchronous operations, you can return specific error messages that will be recorded in Amazon Cloudwatch while maintaining security by not sensitive backend information to customers. For authorization scenarios, you can implement your own Lambda verification logic to control access to specific channels or messages.

Now available

The APS APSYNC data integration is available today in all AWS regions where the AWS appsync is available. You can start using these new features via the AWS Appsync console, the AWS (CLI) or AWS SDK command line. There is no additional cost of using data sources integration – you only pay for the basic sources you use (such as Lambda or Dynamodb operations) and your existing use of Appsync events.

To learn more about the AWS Appsync and integrate data sources, visit the AWS Appsync Events documentation and start building stronger applications in real time today.

– Micah;


How’s the Blog of news? Take this 1 minute survey!

(This survey is hosted by an external company. AWS processes your information as described in the AWS Privacy Notice. AWS will own data collected via this survey and will not share information with dew survey.)

Leave a Comment