Code Monkey home page Code Monkey logo

aws-appsync-refarch-microservices's Introduction

AWS AppSync Microservices-Access-Layer Reference Architecture

solution_overview

The AWS AppSync Serverless GraphQL microservice-access-layer reference architecture showcases AWS AppSync as a single interface to access and combine data from multiple microservices running in different environments :

  • UserService: RESTful API built using Amazon API Gateway and AWS Lambda
  • OrderService: GraphQL API on different AWS AppSync endpoint
  • PaymentService: Containerized service running inside an isolated VPC with no internet access

The sample app is based on a very simple webstore where users can login, and interact with different services.

Quicklinks

Getting Started

One-Click Deploy with the Amplify Console

  1. Prerequisites
  • AWS Account with appropriate permissions to create the related resources

  • AWS CLI with output configured as JSON (pip install awscli --upgrade --user)

  • Install Docker

  • If using Windows, you'll need the Windows Subsystem for Linux (WSL)

  • Create new Amazon Elastic Container Registry (Amazon ECR) (in the same region where amplify app will be deployed) and push payment application to container registry.

    git clone [email protected]:<username>/appsync-refarch-microserviceaccesslayer.git
    
    
    cd appsync-refarch-microserviceaccesslayer/paymentapp
    REPO=$(aws ecr create-repository --repository-name paymentapp --image-tag-mutability IMMUTABLE  --output text --query repository.repositoryUri)
    
    echo '# get-login'
    $(aws ecr get-login --no-include-email)
    
    echo '# repo'
    echo ${REPO}
    
    echo '# build docker image'
    docker build . -t python/paymentapp:v1
    
    echo '# tag this app as version 1'
    docker tag python/paymentapp:v1 ${REPO}:v1
    
    echo '# docker push'
    docker push ${REPO}:v1
    
  1. Click the button to load the AWS Amplify Console. Amplify Console will build and deploy your backend and frontend in a single workflow. the end to end deployment should take around 20 minutes:

Deploy to Amplify Console

  1. Connect your source code from a Git repository (select GitHub if you are cloning this sample), authorize AWS Amplify to connect to this reppository and select a branch.

Add Repository

  1. Create new environment, branch and create an IAM role (with necessary permissions)

Configure Build

Note: If you use any other branch than master, make sure to update resource path in resolver mapping template ./amplify/backend/api/StoreApi/resolvers/Query.getUserInfo.req.vtl. You can read more about configuring HTTP Resolver for AWS AppSync here

  1. Wait for the build, deployment and verification steps
  2. Access your app from the hosted site generated by the Amplify Console(https://master.xxxxxxxx.amplifyapp.com)

Setup local environment

  1. Prerequisites
  1. You have already cloned the repo in previous step. Change directory to application root and install dependencies
cd appsync-refarch-microserviceaccesslayer && npm install
  1. Select your app in amplify console. All Apps -> aws-appsync-refarch-microservices -> Backend Environment -> (extend) Edit backend at the bottom.

connect_local_to_cloud_backend

  1. Paste this command into your terminal at the root of your repo (when prompted accept defaults for runtime and source path)
amplify pull --appId <app-id-from-console> --envName <env-name>

? Do you want to use an AWS profile? Yes
? Please choose the profile you want to use default
Amplify AppID found: xxxxxx1234sd. Amplify App name is: aws-appsync-refarch-microservices}
Backend environment master found in Amplify Console app: aws-appsync-refarch-microservices
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path:  src
? Distribution Directory Path: build
? Build Command:  npm run-script build
? Start Command: npm run-script start

? Do you plan on modifying this backend? Yes

Successfully pulled backend environment master from the cloud.
Run 'amplify pull' to sync upstream changes.

  1. Start and work on your front end locally. This will connect to the backend deployed in AWS.
npm start

Clean up

To clean up the project, you can simply use;

amplify delete

aws-appsync-refarch-microservices's People

Contributors

amazon-auto avatar fmmasood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.