1 00:00:07,046 --> 00:00:09,241 - All right, so let's run through a use case 2 00:00:09,241 --> 00:00:12,731 of image processing with AWS Lambda. 3 00:00:12,731 --> 00:00:15,007 In this scenario, we're going to have 4 00:00:15,007 --> 00:00:18,785 our mobile application users upload images, 5 00:00:18,785 --> 00:00:21,309 and have those images be processed 6 00:00:21,309 --> 00:00:23,707 into various size thumbnails. 7 00:00:23,707 --> 00:00:27,448 Now, I think we all know that the Internet loves cats. 8 00:00:27,448 --> 00:00:30,135 In this case, we have an application 9 00:00:30,135 --> 00:00:33,468 dedicated to uploading pictures of cats. 10 00:00:34,406 --> 00:00:36,368 The first thing that we need to do 11 00:00:36,368 --> 00:00:39,051 is enable our mobile application 12 00:00:39,051 --> 00:00:42,580 to have direct access to an Amazon service, 13 00:00:42,580 --> 00:00:46,074 such as the Amazon Simple Storage Service. 14 00:00:46,074 --> 00:00:48,427 Now, by doing this, by uploading directly 15 00:00:48,427 --> 00:00:50,908 to an Amazon service, 16 00:00:50,908 --> 00:00:54,893 that enables us to bypass our backend API 17 00:00:54,893 --> 00:00:58,560 and it can help reduce the load on that API. 18 00:01:00,100 --> 00:01:01,521 The first thing that we're going to do 19 00:01:01,521 --> 00:01:04,123 is leverage the Amazon Cognito service, 20 00:01:04,123 --> 00:01:08,761 which, in turn, can interact with major login providers 21 00:01:08,761 --> 00:01:10,344 like Facebook and Twitter 22 00:01:10,344 --> 00:01:15,056 in order to have our user login with those services. 23 00:01:15,056 --> 00:01:17,420 By leveraging Amazon Cognito, 24 00:01:17,420 --> 00:01:20,750 we don't have to worry about the details of logging in 25 00:01:20,750 --> 00:01:24,000 with Facebook versus Twitter versus Google and so on. 26 00:01:24,000 --> 00:01:28,167 All we do is ask Amazon Cognito to handle that stuff for us. 27 00:01:29,560 --> 00:01:31,431 The first step is that the user will log in 28 00:01:31,431 --> 00:01:32,936 with Facebook or Twitter, 29 00:01:32,936 --> 00:01:35,417 Amazon Cognito handles the details 30 00:01:35,417 --> 00:01:39,442 and returns temporary credentials, as we've talked about, 31 00:01:39,442 --> 00:01:42,734 back to our mobile application. 32 00:01:42,734 --> 00:01:44,807 Now, again, those temporary credentials 33 00:01:44,807 --> 00:01:48,950 will only live for perhaps 15 minutes, so once they expire, 34 00:01:48,950 --> 00:01:51,269 we don't have to worry about rotating them, 35 00:01:51,269 --> 00:01:54,114 we don't have to worry about embedding credentials 36 00:01:54,114 --> 00:01:56,553 into our application. 37 00:01:56,553 --> 00:01:59,519 Once our application has those temporary credentials, 38 00:01:59,519 --> 00:02:01,871 we can then upload directly 39 00:02:01,871 --> 00:02:05,404 to an Amazon Simple Storage Service bucket. 40 00:02:05,404 --> 00:02:08,124 From there, once the image lands in that bucket, 41 00:02:08,124 --> 00:02:11,614 an event will be fired that we can tie 42 00:02:11,614 --> 00:02:13,531 into a Lambda function, 43 00:02:14,375 --> 00:02:18,542 and the Lambda function can be invoked by that event. 44 00:02:19,817 --> 00:02:23,984 Details about that image will be delivered to the function. 45 00:02:25,057 --> 00:02:28,995 The function can then download the image 46 00:02:28,995 --> 00:02:30,947 from that S3 bucket, 47 00:02:30,947 --> 00:02:34,363 process it into various size thumbnails 48 00:02:34,363 --> 00:02:36,602 for different size devices, 49 00:02:36,602 --> 00:02:38,631 and then store the processed images 50 00:02:38,631 --> 00:02:42,939 in yet another Simple Storage Service bucket. 51 00:02:42,939 --> 00:02:46,032 From there, this particular bucket would be used 52 00:02:46,032 --> 00:02:49,079 as what we call a distribution origin 53 00:02:49,079 --> 00:02:52,008 for the Amazon CloudFront service, 54 00:02:52,008 --> 00:02:56,237 Amazon CloudFront being our content delivery network. 55 00:02:56,237 --> 00:03:01,062 From there, those images will be served from edge locations 56 00:03:01,062 --> 00:03:03,621 out to the other millions of devices 57 00:03:03,621 --> 00:03:04,674 out there on the Internet 58 00:03:04,674 --> 00:03:08,007 that are viewing these pictures of cats. 59 00:03:09,730 --> 00:03:12,163 You can see here, by doing this, 60 00:03:12,163 --> 00:03:15,698 we don't have any infrastructure to maintain. 61 00:03:15,698 --> 00:03:17,993 We don't have EC2 instances that we need 62 00:03:17,993 --> 00:03:21,083 to launch and manage and create. 63 00:03:21,083 --> 00:03:23,442 We don't have, really, even an API 64 00:03:23,442 --> 00:03:24,947 that we have to worry about. 65 00:03:24,947 --> 00:03:26,447 In this particular example, 66 00:03:26,447 --> 00:03:29,614 we're leveraging services that are already 67 00:03:29,614 --> 00:03:33,434 inherently highly available and fall tolerant. 68 00:03:33,434 --> 00:03:37,170 For application developers, leveraging services like this 69 00:03:37,170 --> 00:03:41,337 can really ease development and speed our time to market. 70 00:03:42,457 --> 00:03:43,960 Now, as we go forward, 71 00:03:43,960 --> 00:03:46,601 we will see some of these use cases in demos 72 00:03:46,601 --> 00:03:48,390 that are introducing services 73 00:03:48,390 --> 00:03:50,054 that we haven't yet talked about, 74 00:03:50,054 --> 00:03:53,952 but the point here is to spur your imagination. 75 00:03:53,952 --> 00:03:56,755 I want you to start thinking of the possibilities 76 00:03:56,755 --> 00:04:00,735 of things that can be done within Amazon Web Services. 77 00:04:00,735 --> 00:04:02,764 I want you to start to see 78 00:04:02,764 --> 00:04:05,772 just how flexible all of these services are 79 00:04:05,772 --> 00:04:08,533 and how they can interact and play with each other 80 00:04:08,533 --> 00:04:12,768 to achieve just about anything you can imagine. 81 00:04:12,768 --> 00:04:15,289 Again, this is image processing 82 00:04:15,289 --> 00:04:19,025 with leveraging Amazon Simple Storage Service, 83 00:04:19,025 --> 00:04:21,858 Amazon CloudFront, and AWS Lambda.