SlideShare a Scribd company logo
1 of 42
GraphQL AppSync 101
Agenda
Plan
What is AppSync?
What can you use it for?
What is it made of?
AWS AppSync types
Subscriptions
Security
Monitoring and logging
Pricing
Demo - existing data sources
Final thoughts
How to prototype really fast
2
What is AppSync?
AWS service that enables developers to easily build products
based on GraphQL.
Out of the box it supports many AWS products including:
● data storages
● lambdas
● cloud security
1
3
What can you use it for?2
4
What can you use it for?
Use cases:
◦ Exposing GraphQL API
◦ Real-time interaction applications
▫ Chats
▫ Collaboration
▫ News feed etc.
5
What is made of?3
6
Processing
7
Engine for:
◦ Security
◦ Processing requests
◦ Subscriptions
◦ Batch processes
Black box for developer.
GraphQL Proxy
8
GraphQL schema describing API contract
Schema
9
Types
◦ ID
◦ String
◦ Int
◦ Float
◦ Boolean
◦ AWSDate
◦ AWSTime
◦ AWSDateTime
◦ AWSTimestamp
◦ AWSEmail - Valid RFC 822
◦ AWSJSON - Valid RFC 8259
◦ AWSURL - Valid URL
◦ AWSPhone - Valid phone number (no spec in docs)
◦ AWSIPAddress - Valid IPv4 or IPv6
10
Types
AppSync supports interfaces and unions.
The caveat here is that you have to do is to append
‘__typename’ for type resolution
#foreach ($result in $context.result)
## Extract type name from the id field.
#set( $typeName = $result.id.split("-")[0] )
#set( $ignore = $result.put("__typename", $typeName))
#end
$util.toJson($context.result)
11
Data Sources
DynamoDB
AWS NoSQL
Elasticsearch
Search engine
Lambda
AWS Lambda function
RDS
Aurora - Relational Database
from AWS
HTTP
Any root http endpoint
None
Internal logic
12
Usually in GraphQL:
Responsible for serving requested data by field.
In AppSync:
Transforming request to data source request
and mapping data source response.
Resolvers
13
Unit resolver performs single operation on data
source.
It can also be a batch operation. But not for all
data sources. Supports DynamoDB and
Lambda.
Unit resolver
14
Allows executing
multiple operations
against one or more
data sources.
Composed of a list of
functions. Each
function is executed
in sequence and can
execute a single
operation on a data
source.
Pipeline resolver
15
Example use cases
◦ Load and transform fields based on the
requested format
◦ Custom roles setup application
Pipeline resolver
16
◦ $ctx.stash
◦ $ctx.prev.result
◦ #return(data: Object) - breaks mapping template
with data
◦ $util.error - breaks execution with error
◦ $util.appendError - marks error without
interruption
Pipeline utilities
17
Functions are single operations for redundant
logic on the GraphQL Proxy as a part of
pipeline resolvers.
It can be our customer role check from previous
section
Functions
18
#set($validMinPrice =
$util.matches("d{1,3}[,.]?(d{1,2})?",$ctx.args.minPrice))
#if (!$validMinPrice)
$util.error("Provided price input is not valid.")
#end
{
"version": "2018-05-29",
"statements": [
"select * from Pets where price > :MIN"
],
"variableMap": {
":MIN": $ctx.args.minPrice
}
}
Functions
19
Testing and debugging resolvers
20
Subscription at scale for datasources not
supporting this feature.
AWS takes heavy-lifting and after successful
mutation it pushes notification to all subscribers
for you.
Subscriptions
21
Security4
22
Security
Cognito/OpenID
AWS auth service
supporting
standards like
◦ OAuth 2.0
◦ SAML 2.0
◦ OpenID Connect
OpenID Docs
IAM
For other AWS
services and users,
permissions per
resource / field
API KEY
Constant key sent
over x-api-key
header
23
Cognito
24
Cognito items access
25
type Query {
posts:[Post!]!
@aws_auth(cognito_groups: ["Bloggers", "Readers"])
}
type Mutation {
addPost(id:ID!, title:String!):Post!
@aws_auth(cognito_groups: ["Bloggers"])
}
Access per resource
IAM
26
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"appsync:GraphQL"
],
"Resource": [
"arn:aws:appsync:us-west-2:123456789012:apis/YourGraphQLApiId/types/Query/fields/<Field-1>",
"arn:aws:appsync:us-west-2:123456789012:apis/YourGraphQLApiId/types/Query/fields/<Field-2>",
"arn:aws:appsync:us-west-2:123456789012:apis/YourGraphQLApiId/types/Mutation/fields/<Field-1>",
"arn:aws:appsync:us-west-
2:123456789012:apis/YourGraphQLApiId/types/Subscription/fields/<Field-1>"
]
}
]
}
Access per resource
Monitoring and Logging5
27
We have 3 metrics:
◦ 4xx
◦ 5xx
◦ Latency - processing in ms
Monitoring
28
◦ Request level
▫ Request and response HTTP headers
▫ GraphQL query
▫ Execution summary
▫ GraphQL subscriptions
◦ Field level
▫ Generated Request Mapping with source
and arguments for each field
▫ The transformed Response Mapping for
each field, which includes the data as a
result of resolving that field
▫ Tracing information for each field
Logging
29
There are 3 logging levels available:
◦ NONE - No field-level logs are captured
◦ ERROR - Logs fields that are in error
◦ ALL - The following information is logged for all
fields in the query:
▫ Field-level tracing information
▫ Request/response functions that got
resolved for each field
Logging levels
30
Pricing6
31
CRUD
◦ 250k FREE
◦ $4 per million Query and Data Modification
Operations
+
Data transfer fee charged at EC2 data
transfer rates
COSTS BY AWS DOCS
32
Real-time updates
◦ 250k FREE
◦ 600k connection minutes FREE
◦ $2 per million Real-time updates
Which are priced per 5kb payload of data
delivered. For example, an 8-KB payload is
metered as two real-time updates.
◦ $0.08 per million minutes of connection to
the AWS AppSync service
COSTS BY AWS DOCS
33
◦ 2500 monthly active real-time app users
▫ 25 hours monthly / user
▫ 1000 sent & received events monthly / user
◦ Total cost
▫ Requests - sent messages:
2500 x 1000 x 4$/1M = 10$
▫ Connectivity:
2500 x 1500 x 0.08$ = 0.3$
▫ Data transfer:
1KB x 2.5M = 2.5 MKB = 2.4GB x 0.09$ = 0.21$
▫ Real-time updates:
2500 x 1000 x 2$/1M = 5$
▫ Total:
15.51$
Pricing example
34
Demo7
35
Our case
Routes on Elasticsearch -> Take a look
Price service on API Gateway -> Take a look
Airports on DynamoDB -> Take a look
36
Thumbnail URL generator -> Take a look
Demo - subscriptions8
37
Final thoughts9
38
Pros:
◦ Subscriptions
◦ Fast prototyping
◦ Nice tool for quickly mocking GraphQL at scale
◦ Serverless
Cons:
◦ VTL example from doc
◦ Testing
◦ Any middleware
Logging levels
39
How to prototype really fast?10
40
docs
CREDITS
Special thanks to all the people who made and
released these awesome resources for free:
◦ Presentation template by SlidesCarnival
◦ Photographs by Unsplash
41
Thanks!
ANY QUESTIONS?
42

More Related Content

What's hot

Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22
Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22
Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22GreeceJS
 
Cloud Abstraction Libraries: Implementation and Comparison
Cloud Abstraction Libraries: Implementation and ComparisonCloud Abstraction Libraries: Implementation and Comparison
Cloud Abstraction Libraries: Implementation and ComparisonUdit Agarwal
 
Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...
Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...
Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...HostedbyConfluent
 
The Magic of LINE 購物 Testing
The Magic of LINE 購物 TestingThe Magic of LINE 購物 Testing
The Magic of LINE 購物 TestingLINE Corporation
 
An experiment with AWS Lambda
An experiment with AWS LambdaAn experiment with AWS Lambda
An experiment with AWS LambdaDaniel Vaughan
 
Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...
Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...
Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...Flink Forward
 
Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...
Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...
Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...Flink Forward
 
Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...
Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...
Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...Flink Forward
 
Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...
Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...
Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...Flink Forward
 
KliqMap 1.0 english v4
KliqMap 1.0 english v4KliqMap 1.0 english v4
KliqMap 1.0 english v4apunto_sc
 
GraphQL, Redux, and React
GraphQL, Redux, and ReactGraphQL, Redux, and React
GraphQL, Redux, and ReactKeon Kim
 
Uber Business Metrics Generation and Management Through Apache Flink
Uber Business Metrics Generation and Management Through Apache FlinkUber Business Metrics Generation and Management Through Apache Flink
Uber Business Metrics Generation and Management Through Apache FlinkWenrui Meng
 
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...Flink Forward
 
All Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZAll Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZconfluent
 
ksqlDB Workshop
ksqlDB WorkshopksqlDB Workshop
ksqlDB Workshopconfluent
 
Productionize spark structured streaming
Productionize spark structured streamingProductionize spark structured streaming
Productionize spark structured streamingIvan Kosianenko
 
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
 Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ... Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...AWS Chicago
 
KliqPlan Overview
KliqPlan OverviewKliqPlan Overview
KliqPlan OverviewKT-Labs
 

What's hot (20)

Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22
Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22
Migrating from Monolithic to Serverless (Kostas Katsikas) - GreeceJS #22
 
Cloud Abstraction Libraries: Implementation and Comparison
Cloud Abstraction Libraries: Implementation and ComparisonCloud Abstraction Libraries: Implementation and Comparison
Cloud Abstraction Libraries: Implementation and Comparison
 
Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...
Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...
Live Event Debugging With ksqlDB at Reddit | Hannah Hagen and Paul Kiernan, R...
 
The Magic of LINE 購物 Testing
The Magic of LINE 購物 TestingThe Magic of LINE 購物 Testing
The Magic of LINE 購物 Testing
 
An experiment with AWS Lambda
An experiment with AWS LambdaAn experiment with AWS Lambda
An experiment with AWS Lambda
 
Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...
Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...
Flink Forward Berlin 2018: Ravi Suhag & Sumanth Nakshatrithaya - "Managing Fl...
 
Elasticsearch @ Keboola
Elasticsearch @ KeboolaElasticsearch @ Keboola
Elasticsearch @ Keboola
 
Lambda architecture
Lambda architectureLambda architecture
Lambda architecture
 
Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...
Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...
Flink Forward Berlin 2018: Brian Wolfe - "Upshot: distributed tracing using F...
 
Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...
Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...
Flink Forward Berlin 2017: Mihail Vieru - A Materialization Engine for Data I...
 
Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...
Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...
Flink Forward Berlin 2017: Gyula Fora - Building and operating large-scale st...
 
KliqMap 1.0 english v4
KliqMap 1.0 english v4KliqMap 1.0 english v4
KliqMap 1.0 english v4
 
GraphQL, Redux, and React
GraphQL, Redux, and ReactGraphQL, Redux, and React
GraphQL, Redux, and React
 
Uber Business Metrics Generation and Management Through Apache Flink
Uber Business Metrics Generation and Management Through Apache FlinkUber Business Metrics Generation and Management Through Apache Flink
Uber Business Metrics Generation and Management Through Apache Flink
 
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...Running Flink in Production:  The good, The bad and The in Between - Lakshmi ...
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
 
All Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZAll Streams Ahead! ksqlDB Workshop ANZ
All Streams Ahead! ksqlDB Workshop ANZ
 
ksqlDB Workshop
ksqlDB WorkshopksqlDB Workshop
ksqlDB Workshop
 
Productionize spark structured streaming
Productionize spark structured streamingProductionize spark structured streaming
Productionize spark structured streaming
 
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
 Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ... Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
 
KliqPlan Overview
KliqPlan OverviewKliqPlan Overview
KliqPlan Overview
 

Similar to Serverless GraphQL. AppSync 101

Phil Basford - machine learning at scale with aws sage maker
Phil Basford - machine learning at scale with aws sage makerPhil Basford - machine learning at scale with aws sage maker
Phil Basford - machine learning at scale with aws sage makerAWSCOMSUM
 
Machine learning at scale with aws sage maker
Machine learning at scale with aws sage makerMachine learning at scale with aws sage maker
Machine learning at scale with aws sage makerPhilipBasford
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextPrateek Maheshwari
 
Bridge Your Kafka Streams to Azure Webinar
Bridge Your Kafka Streams to Azure WebinarBridge Your Kafka Streams to Azure Webinar
Bridge Your Kafka Streams to Azure Webinarconfluent
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...HostedbyConfluent
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingBravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingYaroslav Tkachenko
 
Serverless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMServerless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMRightScale
 
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드confluent
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...MSDEVMTL
 
A talk on AWS AppSync
A talk on AWS AppSyncA talk on AWS AppSync
A talk on AWS AppSyncRyan Jones
 
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D..."Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...Vadym Kazulkin
 
BDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
BDA403 How Netflix Monitors Applications in Real-time with Amazon KinesisBDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
BDA403 How Netflix Monitors Applications in Real-time with Amazon KinesisAmazon Web Services
 
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialMongoDB
 
Spring Cloud and Netflix OSS overview v1
Spring Cloud and Netflix OSS overview v1Spring Cloud and Netflix OSS overview v1
Spring Cloud and Netflix OSS overview v1Dmitry Skaredov
 
APAC ksqlDB Workshop
APAC ksqlDB WorkshopAPAC ksqlDB Workshop
APAC ksqlDB Workshopconfluent
 
Amazon Web Services User Group Sydney - March 2018
Amazon Web Services User Group Sydney - March 2018Amazon Web Services User Group Sydney - March 2018
Amazon Web Services User Group Sydney - March 2018PolarSeven Pty Ltd
 
Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018Amazon Web Services
 
Event Driven Microservices
Event Driven MicroservicesEvent Driven Microservices
Event Driven MicroservicesFabrizio Fortino
 
Serverless Streaming Architectures and Algorithms for the Enterprise
Serverless Streaming Architectures and Algorithms for the EnterpriseServerless Streaming Architectures and Algorithms for the Enterprise
Serverless Streaming Architectures and Algorithms for the EnterpriseArun Kejariwal
 

Similar to Serverless GraphQL. AppSync 101 (20)

Phil Basford - machine learning at scale with aws sage maker
Phil Basford - machine learning at scale with aws sage makerPhil Basford - machine learning at scale with aws sage maker
Phil Basford - machine learning at scale with aws sage maker
 
Machine learning at scale with aws sage maker
Machine learning at scale with aws sage makerMachine learning at scale with aws sage maker
Machine learning at scale with aws sage maker
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
 
Bridge Your Kafka Streams to Azure Webinar
Bridge Your Kafka Streams to Azure WebinarBridge Your Kafka Streams to Azure Webinar
Bridge Your Kafka Streams to Azure Webinar
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingBravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
 
Serverless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMServerless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBM
 
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
 
A talk on AWS AppSync
A talk on AWS AppSyncA talk on AWS AppSync
A talk on AWS AppSync
 
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D..."Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
 
BDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
BDA403 How Netflix Monitors Applications in Real-time with Amazon KinesisBDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
BDA403 How Netflix Monitors Applications in Real-time with Amazon Kinesis
 
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
 
Spring Cloud and Netflix OSS overview v1
Spring Cloud and Netflix OSS overview v1Spring Cloud and Netflix OSS overview v1
Spring Cloud and Netflix OSS overview v1
 
APAC ksqlDB Workshop
APAC ksqlDB WorkshopAPAC ksqlDB Workshop
APAC ksqlDB Workshop
 
Amazon Web Services User Group Sydney - March 2018
Amazon Web Services User Group Sydney - March 2018Amazon Web Services User Group Sydney - March 2018
Amazon Web Services User Group Sydney - March 2018
 
Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018Intro To Serverless Application Architecture: Collision 2018
Intro To Serverless Application Architecture: Collision 2018
 
Top conf serverlezz
Top conf   serverlezzTop conf   serverlezz
Top conf serverlezz
 
Event Driven Microservices
Event Driven MicroservicesEvent Driven Microservices
Event Driven Microservices
 
Serverless Streaming Architectures and Algorithms for the Enterprise
Serverless Streaming Architectures and Algorithms for the EnterpriseServerless Streaming Architectures and Algorithms for the Enterprise
Serverless Streaming Architectures and Algorithms for the Enterprise
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Serverless GraphQL. AppSync 101

  • 2. Agenda Plan What is AppSync? What can you use it for? What is it made of? AWS AppSync types Subscriptions Security Monitoring and logging Pricing Demo - existing data sources Final thoughts How to prototype really fast 2
  • 3. What is AppSync? AWS service that enables developers to easily build products based on GraphQL. Out of the box it supports many AWS products including: ● data storages ● lambdas ● cloud security 1 3
  • 4. What can you use it for?2 4
  • 5. What can you use it for? Use cases: ◦ Exposing GraphQL API ◦ Real-time interaction applications ▫ Chats ▫ Collaboration ▫ News feed etc. 5
  • 6. What is made of?3 6
  • 8. Engine for: ◦ Security ◦ Processing requests ◦ Subscriptions ◦ Batch processes Black box for developer. GraphQL Proxy 8
  • 9. GraphQL schema describing API contract Schema 9
  • 10. Types ◦ ID ◦ String ◦ Int ◦ Float ◦ Boolean ◦ AWSDate ◦ AWSTime ◦ AWSDateTime ◦ AWSTimestamp ◦ AWSEmail - Valid RFC 822 ◦ AWSJSON - Valid RFC 8259 ◦ AWSURL - Valid URL ◦ AWSPhone - Valid phone number (no spec in docs) ◦ AWSIPAddress - Valid IPv4 or IPv6 10
  • 11. Types AppSync supports interfaces and unions. The caveat here is that you have to do is to append ‘__typename’ for type resolution #foreach ($result in $context.result) ## Extract type name from the id field. #set( $typeName = $result.id.split("-")[0] ) #set( $ignore = $result.put("__typename", $typeName)) #end $util.toJson($context.result) 11
  • 12. Data Sources DynamoDB AWS NoSQL Elasticsearch Search engine Lambda AWS Lambda function RDS Aurora - Relational Database from AWS HTTP Any root http endpoint None Internal logic 12
  • 13. Usually in GraphQL: Responsible for serving requested data by field. In AppSync: Transforming request to data source request and mapping data source response. Resolvers 13
  • 14. Unit resolver performs single operation on data source. It can also be a batch operation. But not for all data sources. Supports DynamoDB and Lambda. Unit resolver 14
  • 15. Allows executing multiple operations against one or more data sources. Composed of a list of functions. Each function is executed in sequence and can execute a single operation on a data source. Pipeline resolver 15
  • 16. Example use cases ◦ Load and transform fields based on the requested format ◦ Custom roles setup application Pipeline resolver 16
  • 17. ◦ $ctx.stash ◦ $ctx.prev.result ◦ #return(data: Object) - breaks mapping template with data ◦ $util.error - breaks execution with error ◦ $util.appendError - marks error without interruption Pipeline utilities 17
  • 18. Functions are single operations for redundant logic on the GraphQL Proxy as a part of pipeline resolvers. It can be our customer role check from previous section Functions 18
  • 19. #set($validMinPrice = $util.matches("d{1,3}[,.]?(d{1,2})?",$ctx.args.minPrice)) #if (!$validMinPrice) $util.error("Provided price input is not valid.") #end { "version": "2018-05-29", "statements": [ "select * from Pets where price > :MIN" ], "variableMap": { ":MIN": $ctx.args.minPrice } } Functions 19
  • 20. Testing and debugging resolvers 20
  • 21. Subscription at scale for datasources not supporting this feature. AWS takes heavy-lifting and after successful mutation it pushes notification to all subscribers for you. Subscriptions 21
  • 23. Security Cognito/OpenID AWS auth service supporting standards like ◦ OAuth 2.0 ◦ SAML 2.0 ◦ OpenID Connect OpenID Docs IAM For other AWS services and users, permissions per resource / field API KEY Constant key sent over x-api-key header 23
  • 25. Cognito items access 25 type Query { posts:[Post!]! @aws_auth(cognito_groups: ["Bloggers", "Readers"]) } type Mutation { addPost(id:ID!, title:String!):Post! @aws_auth(cognito_groups: ["Bloggers"]) } Access per resource
  • 26. IAM 26 { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "appsync:GraphQL" ], "Resource": [ "arn:aws:appsync:us-west-2:123456789012:apis/YourGraphQLApiId/types/Query/fields/<Field-1>", "arn:aws:appsync:us-west-2:123456789012:apis/YourGraphQLApiId/types/Query/fields/<Field-2>", "arn:aws:appsync:us-west-2:123456789012:apis/YourGraphQLApiId/types/Mutation/fields/<Field-1>", "arn:aws:appsync:us-west- 2:123456789012:apis/YourGraphQLApiId/types/Subscription/fields/<Field-1>" ] } ] } Access per resource
  • 28. We have 3 metrics: ◦ 4xx ◦ 5xx ◦ Latency - processing in ms Monitoring 28
  • 29. ◦ Request level ▫ Request and response HTTP headers ▫ GraphQL query ▫ Execution summary ▫ GraphQL subscriptions ◦ Field level ▫ Generated Request Mapping with source and arguments for each field ▫ The transformed Response Mapping for each field, which includes the data as a result of resolving that field ▫ Tracing information for each field Logging 29
  • 30. There are 3 logging levels available: ◦ NONE - No field-level logs are captured ◦ ERROR - Logs fields that are in error ◦ ALL - The following information is logged for all fields in the query: ▫ Field-level tracing information ▫ Request/response functions that got resolved for each field Logging levels 30
  • 32. CRUD ◦ 250k FREE ◦ $4 per million Query and Data Modification Operations + Data transfer fee charged at EC2 data transfer rates COSTS BY AWS DOCS 32
  • 33. Real-time updates ◦ 250k FREE ◦ 600k connection minutes FREE ◦ $2 per million Real-time updates Which are priced per 5kb payload of data delivered. For example, an 8-KB payload is metered as two real-time updates. ◦ $0.08 per million minutes of connection to the AWS AppSync service COSTS BY AWS DOCS 33
  • 34. ◦ 2500 monthly active real-time app users ▫ 25 hours monthly / user ▫ 1000 sent & received events monthly / user ◦ Total cost ▫ Requests - sent messages: 2500 x 1000 x 4$/1M = 10$ ▫ Connectivity: 2500 x 1500 x 0.08$ = 0.3$ ▫ Data transfer: 1KB x 2.5M = 2.5 MKB = 2.4GB x 0.09$ = 0.21$ ▫ Real-time updates: 2500 x 1000 x 2$/1M = 5$ ▫ Total: 15.51$ Pricing example 34
  • 36. Our case Routes on Elasticsearch -> Take a look Price service on API Gateway -> Take a look Airports on DynamoDB -> Take a look 36 Thumbnail URL generator -> Take a look
  • 39. Pros: ◦ Subscriptions ◦ Fast prototyping ◦ Nice tool for quickly mocking GraphQL at scale ◦ Serverless Cons: ◦ VTL example from doc ◦ Testing ◦ Any middleware Logging levels 39
  • 40. How to prototype really fast?10 40 docs
  • 41. CREDITS Special thanks to all the people who made and released these awesome resources for free: ◦ Presentation template by SlidesCarnival ◦ Photographs by Unsplash 41