---
title: "Discussion on \"Trigger AppSync Subscriptions with EventBridge targets\" | Hashnode"
description: "Discussion on \"Trigger AppSync Subscriptions with EventBridge targets\". AWS AppSync is a managed graphQL service that comes with built-in websockets so applications can subscribe to real-time updates. Oftentimes, this means something like, \"When someone adds a todo, let any subscriber see the new todo.\"\nBut the actual us..."
url: "https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Trigger AppSync Subscriptions with EventBridge targets](https://blog.focusotter.com/trigger-appsync-subscriptions-with-eventbridge-targets?utm_source=hashnode&utm_medium=feed)

AWS AppSync is a managed graphQL service that comes with built-in websockets so applications can subscribe to real-time updates. Oftentimes, this means something like, "When someone adds a todo, let any subscriber see the new todo." But the actual us...

Mar 4, 2022 · 8 min read · blog.focusotter.com  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#aws-lambda](https://hashnode.com/tag/aws-lambda)
-   [#aws-cdk](https://hashnode.com/tag/aws-cdk)
-   [#serverless](https://hashnode.com/tag/serverless)
-   [#amplifyhashnode](https://hashnode.com/tag/amplifyhashnode)

## Written by

[Michael Liendo](https://hashnode.com/@focusotter)

@focusotter · Midwest, US

  
[View profile](https://hashnode.com/@focusotter)

Fullstack Cloud with TypeScript, React, and AWS CDK

## Responses 4

Markdown supported · ⌘↵ to post

[Andrew Plater](https://hashnode.com/@andrewplater)

[Jun 10, 2024](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/6666a2b61349a82093e65c2e)

Very helpful explanation for what I am trying to do with AWS EventBridge calling a Lambda function and updating subscriptions

[Selva Raj](https://hashnode.com/@t396)

[Oct 28, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/635bb239f278e22d09543dde)

Hello Michael! When we are using IAM update from lambda functions, the subscription query returns only empty data. I have followed your example and below is the subscription return value "onUpdateOrder: {status: null}" from reactJs side.

Please let me know how to solve this issue. Update data is working fine from lambda function. i have confirmed the data with our DynamoDB.

[Selva Raj](https://hashnode.com/@t396)

[Oct 26, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/635911d16bf8ab0eb9832bb0)

Hi Michael!

When we using the IAM update from lambda function the subscription query return the empty data. I have followed the your example. and subscription return value is onUpdateOrder: {status: null} from reactJs side. Please let me know how to solve this issues. update data working fine from lambada function inside. i have confirmed data with Dynamodb side.

[Pepe Medel](https://hashnode.com/@jmedelaldeamx)

[May 18, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/628537fd7b02ca162edaca6d)

Hi [Michael Liendo](https://hashnode.com/@mtliendo)!

I think you have an error in your cdk routine, on line 49:

_rule.addTarget(new targets.LambdaFunction(sampleFuncToAppSync))_ I think the attribute/var that is passed to LambdaFunction should be "coffeeOrderReceivedFunc".

On the other hand, I have not been able to do something almost identical, in my case it is using the eventPattern aws.s3. the trigger is not added inside my lambda function, therefore it is not called when eventbridge detects the event from s3.

I've read a lot about this and am about to conclude that it's not possible to use addTarget on previously created resources from the amplify CLI, or at least not this command. This only works for resources created on the same CDK stack, apparently...

At the end of the Importing existing external resources section in /cdk/v2/guide/resources.html, says:

"Although you can use an external resource anywhere you'd use a similar resource defined in your app, you cannot modify the external resource. For example, calling addToResourcePolicy (Python: add\_to\_resource\_policy) on an external s3.Bucket does nothing."

In your case, has it worked for you?

Thanks a lot and best regards.

[Oscar Nevarez](https://hashnode.com/@onevarez)

[Jul 14, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/628537fd7b02ca162edaca6d#reply-62d02ed2dec7a6eae9b58765)

Hey Pepe, you're right. You can't modify amplify resources through CDK.

I created a Lambda permission within the cloudformation file of my lambda function, referincing my Eventbridge rule created in CDK.

Hope it helps.

[Chris Zirkel](https://hashnode.com/@zirkelc)

[Mar 22, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/6239ef99343ee96c27555c99)

Hi Michael!

I'm using Amplify on the frontend and it provides an API class to make Cognito authenticated requests. What is the recommended approach to make requests in a Node.js Lambda function with IAM? Amplify refers to this: [docs.amplify.aws/lib/graphqlapi/graphql-from-node…](https://docs.amplify.aws/lib/graphqlapi/graphql-from-nodejs/q/platform/js/#signing-a-request-from-lambda)

That looks quite similar to your post. I was wondering if I also could use the official AWS AppSync SDK?

[Michael Liendo](https://hashnode.com/@focusotter)

[Mar 22, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/6239ef99343ee96c27555c99#reply-623a06ac343ee96c27555fbe)

Hey! Yea, Totally doable without much work.

I have a blog post up that shows the code to do so, checkout the “Automatically Creating Users” section here: [blog.focusotter.com/combining-nextjs-aws-amplify-…](https://blog.focusotter.com/combining-nextjs-aws-amplify-and-stripe-to-build-a-catering-app-part-1)

Let me know if that helps and thanks for checking out the post!

[Chris Zirkel](https://hashnode.com/@zirkelc)

[Mar 23, 2022](https://hashnode.com/posts/trigger-appsync-subscriptions-with-eventbridge-targets/6222666eb9cb874b840c75c1/comment/6239ef99343ee96c27555c99#reply-623b20c5e99839749d247c7c)

[Michael Liendo](https://hashnode.com/@mtliendo) it seems like the URL in my first comment got removed, so it was probably not 100% clear what I meant.

The [AWS documentation](https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app.html) for clients accessing GraphQL from the backend (like Lambdas) says:

> To connect to your AWS AppSync GraphQL endpoints from your backend applications (such as AWS Lambda function or Amazon EC2 instances), we recommend using an HTTP client and signing your requests using IAM by following the Authorization and authentication guide. For more information on working with GraphQL in the backend, see GraphQL from NodeJS.

Then it links to the Amplify documentation about [Signing a request from Lambda](https://docs.amplify.aws/lib/graphqlapi/graphql-from-nodejs/q/platform/js/#signing-a-request-from-lambda)

I had some issues accessing my GraphQL API via HTTP and IAM and was wondering if there are other ways to access it from Lambda, for example the official AWS.AppSync SDK?
