1 00:00:00,130 --> 00:00:03,040 ‫Now let's talk about AWS AppSync 2 00:00:03,040 --> 00:00:04,800 ‫and AppSync from an exam perspective, 3 00:00:04,800 --> 00:00:06,410 ‫there's two angles to it. 4 00:00:06,410 --> 00:00:08,650 ‫The first one is that it's a managed service 5 00:00:08,650 --> 00:00:10,710 ‫that we uses GraphQL. 6 00:00:10,710 --> 00:00:14,370 ‫So if she wants to build a GraphQL API on AWS, 7 00:00:14,370 --> 00:00:16,570 ‫look no further than AppSync. 8 00:00:16,570 --> 00:00:17,920 ‫What does GraphQL? 9 00:00:17,920 --> 00:00:20,340 ‫Well, GraphQL makes it easy for applications 10 00:00:20,340 --> 00:00:24,470 ‫to get exactly the data they need it's a new style of API. 11 00:00:24,470 --> 00:00:26,717 ‫The idea is that you just ask for the fields you want 12 00:00:26,717 --> 00:00:28,970 ‫and GraphQL returns just that's. 13 00:00:28,970 --> 00:00:31,630 ‫The idea with GraphQL though is that you can combine data 14 00:00:31,630 --> 00:00:33,810 ‫from one or more sources into a graph, 15 00:00:33,810 --> 00:00:36,490 ‫so that means that the data sets behind GraphQL, 16 00:00:36,490 --> 00:00:38,380 ‫can include NoSQL data stores, 17 00:00:38,380 --> 00:00:41,130 ‫Relational databases, HTTP APIs, 18 00:00:41,130 --> 00:00:42,910 ‫and they're all combined together. 19 00:00:42,910 --> 00:00:47,300 ‫GraphQL in AppSync has direct integrations with DynamoDB, 20 00:00:47,300 --> 00:00:49,850 ‫Aurora, OpenSearch and other sources 21 00:00:49,850 --> 00:00:52,560 ‫and you can get any data from anywhere 22 00:00:52,560 --> 00:00:56,563 ‫if you want to with Lambda to extend the pattern. 23 00:00:57,570 --> 00:01:01,610 ‫The second angle for using AppSync in AWS, 24 00:01:01,610 --> 00:01:05,440 ‫is to have real time WebSockets integration 25 00:01:05,440 --> 00:01:07,300 ‫or MQTT on WebSockets. 26 00:01:07,300 --> 00:01:08,780 ‫The idea is that if you're building 27 00:01:08,780 --> 00:01:12,570 ‫a real time application that needs to access a data feel, 28 00:01:12,570 --> 00:01:14,800 ‫you have many ways, but one of these ways 29 00:01:14,800 --> 00:01:16,700 ‫is AppSync with a WebSockets. 30 00:01:16,700 --> 00:01:19,230 ‫You could also use an application on the balancer 31 00:01:19,230 --> 00:01:22,720 ‫or the API gateway, but AppSync is one of these options. 32 00:01:22,720 --> 00:01:25,050 ‫Then if you have a mobile application 33 00:01:25,050 --> 00:01:27,010 ‫and you want you to have local data access 34 00:01:27,010 --> 00:01:28,890 ‫and data synchronization, 35 00:01:28,890 --> 00:01:31,360 ‫AppSync is also a replacement for something we've seen 36 00:01:31,360 --> 00:01:33,460 ‫that was outdated called cookie to sync. 37 00:01:33,460 --> 00:01:35,560 ‫So this can come up in the exam as well. 38 00:01:35,560 --> 00:01:37,300 ‫Finally, to get started with AppSync, 39 00:01:37,300 --> 00:01:39,790 ‫you just need to upload one GraphQL schema 40 00:01:39,790 --> 00:01:41,720 ‫and We'll see this in the hands on. 41 00:01:41,720 --> 00:01:44,670 ‫So, in a diagram we have AppSync in the middle, 42 00:01:44,670 --> 00:01:45,510 ‫and to get start with AppSync, 43 00:01:45,510 --> 00:01:48,390 ‫you need to create a GraphSQL schema. 44 00:01:48,390 --> 00:01:49,550 ‫So we upload the schema 45 00:01:49,550 --> 00:01:51,660 ‫and this is what a schema may look like. 46 00:01:51,660 --> 00:01:54,507 ‫And then you have a client and the client will say, 47 00:01:54,507 --> 00:01:57,930 ‫"Hey, I want you to do this query on AppSync?" 48 00:01:57,930 --> 00:01:59,750 ‫And you're specifying, for example, 49 00:01:59,750 --> 00:02:02,620 ‫in this research, the name of the human 50 00:02:02,620 --> 00:02:04,210 ‫and then the fact you want its name, 51 00:02:04,210 --> 00:02:07,070 ‫the fact that we want to know which movies it appears in 52 00:02:07,070 --> 00:02:08,140 ‫and the Starships. 53 00:02:08,140 --> 00:02:11,500 ‫And then AppSync will run its own resolver, 54 00:02:11,500 --> 00:02:13,880 ‫so this is the way, this is the magic of GraphQL. 55 00:02:13,880 --> 00:02:16,620 ‫It works with resolvers and one of these results resolver 56 00:02:16,620 --> 00:02:20,110 ‫may be DynamoDB so that means fetch the data from DynamoDB. 57 00:02:20,110 --> 00:02:24,170 ‫And then AppSync knows how to automatically return 58 00:02:24,170 --> 00:02:26,700 ‫the data in JSON form to the clients 59 00:02:26,700 --> 00:02:30,970 ‫to comply exactly with the exact query that was asked. 60 00:02:30,970 --> 00:02:33,760 ‫And as we can see, it is a very JSON. 61 00:02:33,760 --> 00:02:36,030 ‫But with GraphQL you can ask for any fields 62 00:02:36,030 --> 00:02:38,590 ‫and it will be returned automatically by AppSync. 63 00:02:38,590 --> 00:02:40,820 ‫So that's the general idea, obviously going into an exam, 64 00:02:40,820 --> 00:02:44,530 ‫you do not know how to write a Schema or a query and so on. 65 00:02:44,530 --> 00:02:45,830 ‫Just need you to know the high level, 66 00:02:45,830 --> 00:02:47,730 ‫but I want to show you the behind the scenes. 67 00:02:47,730 --> 00:02:50,720 ‫So at a high level AppSync has integrations 68 00:02:50,720 --> 00:02:52,910 ‫for your web applications, your mobile apps 69 00:02:52,910 --> 00:02:54,510 ‫that all use GraphQL, 70 00:02:54,510 --> 00:02:56,360 ‫but also anything that's going to be Real-time. 71 00:02:56,360 --> 00:02:59,260 ‫So it could be a Real-time dashboard, for example, 72 00:02:59,260 --> 00:03:03,110 ‫or any application that needs offline data synchronization 73 00:03:03,110 --> 00:03:05,540 ‫and a replacement for convene to sync. 74 00:03:05,540 --> 00:03:08,270 ‫For AppSync at its core you have GraphQL schema, 75 00:03:08,270 --> 00:03:11,480 ‫you upload and resolvers to tell how to fetch data. 76 00:03:11,480 --> 00:03:13,570 ‫For these resolvers we have direct integration 77 00:03:13,570 --> 00:03:16,750 ‫with DynamoDB, Aurora, OpenSearch 78 00:03:16,750 --> 00:03:19,570 ‫or anything you want through a Lambda function 79 00:03:19,570 --> 00:03:22,730 ‫or an already existing public HTTP endpoints 80 00:03:22,730 --> 00:03:24,890 ‫with the HTTP integration. 81 00:03:24,890 --> 00:03:25,930 ‫And if you're an into log, 82 00:03:25,930 --> 00:03:27,550 ‫anything that was happening in AppSync, 83 00:03:27,550 --> 00:03:29,280 ‫it is integrated with CloudWatch Metrics 84 00:03:29,280 --> 00:03:32,500 ‫and CloudWatch logs to get this information. 85 00:03:32,500 --> 00:03:34,960 ‫Finally, because we're creating an API in AWS, 86 00:03:34,960 --> 00:03:36,720 ‫we need to talk about security. 87 00:03:36,720 --> 00:03:38,900 ‫So there's four ways you can authorize applications 88 00:03:38,900 --> 00:03:42,460 ‫to interact with your AppSync GraphQL API. 89 00:03:42,460 --> 00:03:44,110 ‫The first one is with API_KEY, 90 00:03:44,110 --> 00:03:45,600 ‫so you generate these keys 91 00:03:45,600 --> 00:03:49,050 ‫just like for the API gateway and give them to users. 92 00:03:49,050 --> 00:03:53,180 ‫The second one is use AWS_IAM to allow IAM users roles 93 00:03:53,180 --> 00:03:55,420 ‫or across account access to your absent API, 94 00:03:55,420 --> 00:03:57,040 ‫which is also very similar 95 00:03:57,040 --> 00:03:59,470 ‫to what we saw for the API gateway. 96 00:03:59,470 --> 00:04:00,920 ‫Then we have OPENID_CONNECT 97 00:04:00,920 --> 00:04:02,760 ‫if you wanted to have an integration 98 00:04:02,760 --> 00:04:04,730 ‫with an OpenID Connect provider 99 00:04:04,730 --> 00:04:08,980 ‫and a JSONWeb Token and finally AMAZON_COGNITO_USER_POOL 100 00:04:08,980 --> 00:04:11,250 ‫to integrate with already existing User pools, 101 00:04:11,250 --> 00:04:14,230 ‫you upgraded in Cognito and through Cognito User pools, 102 00:04:14,230 --> 00:04:15,740 ‫then you can federate through 103 00:04:15,740 --> 00:04:18,440 ‫other social login providers for example. 104 00:04:18,440 --> 00:04:20,800 ‫Finally, if you want you to get HTTPs security 105 00:04:20,800 --> 00:04:22,670 ‫on AppSync with a custom domain, 106 00:04:22,670 --> 00:04:25,110 ‫the recommended solution is used CloudFront 107 00:04:25,110 --> 00:04:26,690 ‫in front of AppSync. 108 00:04:26,690 --> 00:04:28,560 ‫So that's it for this theory lecture 109 00:04:28,560 --> 00:04:30,560 ‫we gonnaa hands on to get some practice.