This repository contains code written in the AWS Cloud Development Kit (CDK)

Overview

AWS AppSync Multi Region Deployment

This repository contains code written in the AWS Cloud Development Kit (CDK) which launches infrastructure across two different regions to demonstrate using AWS AppSync in a multi-region setup.

By default, AWS AppSync endpoints only trigger GraphQL subscriptions in response to data mutations received on that same endpoint. This means that if data is changed by any other source or endpoint, as it is the case of multi-Region deployment, then AppSync is not aware of this change and the subscription will not be triggered. To address this, you can use AWS Lambda functions and Amazon DynamoDB Streams to enable subscriptions to work globally across Regions.

This pre-built AWS CDK solution extends AWS AppSync, enabling global applications with GraphQL subscriptions, and can be deployed to your AWS environment for testing purposes.

Global Serverless Infrastructure

Pre-Requisites

AWS Cloud9 Environment

AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser.

AWS Cloud9 contains a collection of tools that let you code, build, run, test, debug, and release software in the cloud using your internet browser. The IDE offers support for python, pip, AWS CLI, and provides easy access to AWS resources through Identity and Access Management (IAM) user credentials. The IDE includes a terminal with sudo privileges to the managed instance that is hosting your development environment. This makes it easy for you to quickly run commands and directly access AWS services.

Create an AWS Cloud9 environment:

  1. Open the AWS Cloud9 console in the Ireland region (eu-west-1).
  2. Choose Create Environment or open the link.
  3. For Name, enter myDevEnv.
  4. Choose Next step
  5. For Cost-saving setting, choose After four hours.
  6. Select Create a new no-ingress EC2 instance for environment (access via Systems Manager).
  7. Leave the remaining parameters to the default.
  8. Choose Next Step.
  9. Choose Create Environment.
  10. It will start the creation of the Cloud9 environment.

This Cloud 9 environment will come pre installed with the following tools, which are required to launch the infrastructure:

  • AWS CLI
  • Node JS
  • Python v3
  • Pip

AWS CDK Toolkit

The toolkit is a command-line utility which allows you to work with CDK apps. To install the toolkit, run the following command:

npm install -g aws-cdk

Launch the Infrastructure

To launch the infrastructure that is detailed in the CDK stacks, first clone this repository onto the cloud9 machine:

git clone gi[email protected]:aws-samples/aws-appsync-multi-region-deployment.git

Then we can run the setup.sh script, which will launch the two CDK stacks.

cd aws-appsync-multi-region-deployment
bash setup.sh

This script will perform the following tasks automatically:

  1. Setup the Lambda functions by installing the required Node modules and compressing into a .zip package.
  2. Install the required CDK packages and modules
  3. Boostrap both CDK stacks
  4. Launch the primary region CDK stack
  5. Retrieve the ARN of the Global Table stream
  6. Launch the seciondary region CDK stack

Whilst this script is running, it will require your confirmation before infrastructure is launched in your account. On two occasions you will be prompted to type y and press the return key.

Test the Solution

To test the solution, we will open a subscription to AWS AppSync in the Ireland region, and insert some data via a mutation to AWS AppSync in the Sydney region.

  1. Open the AWS AppSync Console in Ireland in one browser window.
  2. In a separate browser window, open the AWS AppSync Console in Sydney
  3. In the Ireland region, open the GraphQL API titled "IrelandGQLSchema" by clicking on its title. Then click on the 'Queries' tab on the menu on the left.
  4. In the Sydney region, open the GraphQL API titled "SydneyGQLSchema" by clicking on its title. Then click on the 'Queries' tab on the menu on the left.
  5. In the Ireland region, enter the following query into the query window and click the play button to open a subscription to the Ireland AppSync endpoint:
subscription MySubscription {
  onCreateItemsModel {
    id
    item
  }
}
  1. In the Sydney region, enter the following mutation into the Query window and click the play button to send the data to the Sydney AppSync endpoint:
mutation MyMutation {
  createItemsModel(input: {id: "Item001", item: "MyItem"}) {
    id
    item
  }
}
  1. In the Ireland region, where you have a subscription open, observe the new data being received by the client. This data has travelled from your client, to the AWS AppSync endpoint in Sydney, into the backend DynamoDB Global Table, replicated to Sydney, triggered the Lambda function in Sydney which notified the AWS AppSync endpoint in Sydney to the new data, which in turn delivered it to the client subscribed to it.

Clean up

To clean up the infrastructure launched, execute the following commands from your cloud9 environment:

cd globalserverless
cdk destroy
cd ../globalserverlesssecondregion
cdk destroy

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Owner
AWS Samples
AWS Samples
Python based Algo trading bot for Nifty / Banknifty futures and options

Fully automated Alice Blue Algo Trading with Python on NSE and MCX for Nifty / Crude / Banknifty futures and options , absolutely FREE ! This algo tra

Rajesh Sivadasan 49 Dec 31, 2022
Pybt: a BaoTa panel python sdk

About Pybt is a BaoTa panel python sdk. Pybt 是一个宝塔面板API的Python版本sdk封装库。 公司很多服务器都装了宝塔面板,通过宝塔来部署、安装、维护一些服务,服务器的数量上以后,导致了维护的不方便,这个时候就想使用宝塔提供的API来开发一个运维平台

Adam Zhang 9 Dec 05, 2022
Free Game Download Client

XGames Free Game Download Client В проекте была использована библиотека igruha а также PyQt5 WARN ⚠️ Возможно потребуется скачать и установить vc_redi

LORD_CODE 3 Jun 25, 2022
An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. This is Also The Source Code of The Bot Which is Being Used In @SafoTheBot Group! ❤️

Telegram Video Player Bot (Beta) An Telegram Bot By @AsmSafone To Stream Videos in Telegram Voice Chat. Special Features Supports Live Streaming From

SAF ONE 206 Jan 03, 2023
A Telegram Bot Written In Python

TelegraphUploader A Telegram Bot Written In Python DEPLOY Local Machine Clone the repository Install requirements: pip3 install -r requirements.txt e

Wahyusaputra 2 Dec 29, 2021
A Bot To Find Telegram User ID Easily

Telegram ID Bot 🤖 A Bot To Find Telegram User ID Easily Made with Python3 (C) @BXBotz Copyright permission under MIT License License - https://githu

MuFaz-TG 6 Nov 21, 2022
An unofficial python wrapper for the comdirect API for private consumers.

An unofficial python wrapper for the comdirect API for private consumers.

Alexander Knittel 18 Nov 30, 2022
Primeira etapa do processo seletivo para a bolsa de migração de conteúdo de Design de Software.

- Este processo já foi concluído. Obrigado pelo seu interesse! Processo Seletivo para a bolsa de migração de conteúdo de Design de Software Primeirame

Toshi Kurauchi 1 Feb 21, 2022
A simple MTProto-based bot that can download various types of media (>10MB) on a local storage

TG Media Downloader Bot 🤖 A telegram bot based on Pyrogram that downloads on a local storage the following media files: animation, audio, document, p

Alessio Tudisco 11 Nov 01, 2022
Discord spam bots with multiple account support and more

Discord spam bots with multiple account support and more. PLEASE READ EVERYTHING BEFORE WRITING AN ISSUE!! Server Messages Text Image Dm Messages Text

Mr. Nobody 6 Sep 14, 2022
Zendesk Ticket Viewer is a lightweight commandline client for fetching and displaying tickets from a Zendesk account provided by the user

Zendesk Ticket Viewer is a lightweight commandline client for fetching and displaying tickets from a Zendesk account provided by the user.

Parthesh Soni 1 Jan 24, 2022
⚡ Yuriko Robot ⚡ - A Powerful, Smart And Simple Group Manager Written with AioGram , Pyrogram and Telethon

⚡ Yuriko Robot ⚡ - A Powerful, Smart And Simple Group Manager Written with AioGram , Pyrogram and Telethon

Øғғɪᴄɪᴀʟ Ⱡᴏɢ [₳ғᴋ] 1 Apr 01, 2022
A Rich renderable for viewing Multiple Sequence Alignments in the terminal.

rich-msa A simple module to render colorful Multiple Sequence Alignment with rich in the terminal. 🔧 Installing Install the rich-msa package directly

Martin Larralde 64 Dec 04, 2022
Project glow is an open source bot worked on by many people to create a good and safe moderation bot for all

Project Glow Greetings, I see you have stumbled upon project glow. Project glow is an open source bot worked on by many people to create a good and sa

Glowstikk 24 Sep 29, 2022
Trabalho N1 para a materia Tecnicas de Progamação da Anhembi Morumbi

Projeto da Anhembi Morumbi - Tecnicas de Programação. RPG de Console (CMD) Trabalho proposto pelo professor André Santana, na materia Tecnicas de Prog

Leonardo Silva M de Barros 3 Sep 12, 2021
A Superfast SMS & Call bomber for Linux And Termux

PSKR_BOMBER 💣 📱 💀 A Superfast SMS & Call bomber for Linux And Termux ! Disclaimer This tool is for educational purposes only ! Don't use this to ta

1 Dec 20, 2021
A thin Python Wrapper for the Dark Sky (formerly forecast.io) weather API

Dark Sky Wrapper This is a wrapper for the Dark Sky (formerly forecast.io) API. It allows you to get the weather for any location, now, in the past, o

Ze'ev Gilovitz 414 Nov 16, 2022
Code done for/during the course

Serverless Course Autumn 2021 - Code This repository contains a set of examples developed during, but not limited to the live coding sessions. Lesson

Alexandru Burlacu 4 Dec 21, 2021
a list of disposable and temporary email address domains

List of disposable email domains This repo contains a list of disposable and temporary email address domains often used to register dummy users in ord

1.6k Jan 08, 2023
An Open Source ALL-In-One Telegram RoBot, that can do lot of things.

URL Uploader Bot An Open Source ALL-In-One Telegram RoBot, that can do lot of things. My Features Installation The Easy Way You can also tap the Deplo

NT BOTS 1 Oct 23, 2021