1 00:00:00,210 --> 00:00:01,890 ‫So let's create a function 2 00:00:01,890 --> 00:00:06,180 ‫and I will call this one lambda-demo-url. 3 00:00:06,180 --> 00:00:09,240 ‫And then we can choose Python 3.9 4 00:00:09,240 --> 00:00:11,583 ‫and then we can create this function. 5 00:00:13,410 --> 00:00:16,680 ‫So now the function is created, I can just click on Test 6 00:00:16,680 --> 00:00:18,240 ‫and then we have a new Test Event. 7 00:00:18,240 --> 00:00:22,350 ‫We save this, we add a name, test, and Save. 8 00:00:22,350 --> 00:00:25,140 ‫And as you can see, if we test this function right now, 9 00:00:25,140 --> 00:00:27,540 ‫the response is status code 200, 10 00:00:27,540 --> 00:00:29,880 ‫body, Hello from Lambda. 11 00:00:29,880 --> 00:00:30,713 ‫So this is good. 12 00:00:30,713 --> 00:00:32,130 ‫This is exactly what we want. 13 00:00:32,130 --> 00:00:34,320 ‫This returns on HTTP-like response. 14 00:00:34,320 --> 00:00:37,200 ‫And what we want to do, is to now publish this. 15 00:00:37,200 --> 00:00:39,810 ‫So we're going to publish this new version. 16 00:00:39,810 --> 00:00:42,930 ‫I'll call this one version 1, so we have version 1. 17 00:00:42,930 --> 00:00:46,230 ‫And now what we should do is that we create an alias 18 00:00:46,230 --> 00:00:47,400 ‫and we create this alias, 19 00:00:47,400 --> 00:00:51,120 ‫and I'll call this one, dev and let's save this. 20 00:00:51,120 --> 00:00:54,000 ‫So dev points to version 1. 21 00:00:54,000 --> 00:00:56,460 ‫And now I'm going to scroll down. 22 00:00:56,460 --> 00:00:59,190 ‫And as you can see here, Function URL is empty. 23 00:00:59,190 --> 00:01:00,030 ‫And on the left-hand side, 24 00:01:00,030 --> 00:01:02,070 ‫there is Function URL that you can select 25 00:01:02,070 --> 00:01:04,500 ‫and you click on Create Function URL. 26 00:01:04,500 --> 00:01:06,990 ‫Here, we specify the authentication type. 27 00:01:06,990 --> 00:01:09,180 ‫So we have IAM or NONE. 28 00:01:09,180 --> 00:01:11,190 ‫So we'll use NONE and we'll need to make sure 29 00:01:11,190 --> 00:01:13,620 ‫that we have the proper resource policy. 30 00:01:13,620 --> 00:01:14,850 ‫And as you can see, 31 00:01:14,850 --> 00:01:16,860 ‫there is this, that gets automatically created, 32 00:01:16,860 --> 00:01:20,302 ‫which allows anyone to access our Lambda Function URL 33 00:01:20,302 --> 00:01:23,040 ‫of AuthType, NONE, which is good. 34 00:01:23,040 --> 00:01:24,900 ‫And then also, if you wanted to, 35 00:01:24,900 --> 00:01:28,140 ‫we could configure CORS, Cross-Origin Resource Sharing, 36 00:01:28,140 --> 00:01:31,110 ‫right here, to say which origins we want to allow, 37 00:01:31,110 --> 00:01:33,120 ‫which headers we want to expose, and so on. 38 00:01:33,120 --> 00:01:36,030 ‫And this is CORS specific configuration, 39 00:01:36,030 --> 00:01:37,800 ‫but we won't need it right now. 40 00:01:37,800 --> 00:01:38,730 ‫So we're good to go. 41 00:01:38,730 --> 00:01:40,950 ‫We have this new Resource Policy 42 00:01:40,950 --> 00:01:42,930 ‫that gets attached to our function, 43 00:01:42,930 --> 00:01:44,628 ‫and now we have a Function URL 44 00:01:44,628 --> 00:01:48,120 ‫and this will remain the exact same URL forever, 45 00:01:48,120 --> 00:01:50,070 ‫for this alias, dev. 46 00:01:50,070 --> 00:01:53,220 ‫So if I open a new tab and then paste this in, 47 00:01:53,220 --> 00:01:56,100 ‫as you can see, I get the response, Hello from Lambda. 48 00:01:56,100 --> 00:01:57,720 ‫And the fancy thing you see right here 49 00:01:57,720 --> 00:02:00,120 ‫is just my web browser displaying some extra stuff. 50 00:02:00,120 --> 00:02:02,310 ‫But as you can see, it says Hello from Lambda. 51 00:02:02,310 --> 00:02:03,780 ‫And so that worked. 52 00:02:03,780 --> 00:02:07,110 ‫And so we were able to access our Lambda Function publicly, 53 00:02:07,110 --> 00:02:08,760 ‫through a URL. 54 00:02:08,760 --> 00:02:11,400 ‫Other things to note is that if I, for example, 55 00:02:11,400 --> 00:02:13,260 ‫go back to my Lambda function, 56 00:02:13,260 --> 00:02:15,450 ‫so I go back to my Lambda Function 57 00:02:15,450 --> 00:02:19,140 ‫and I'm going to look at Aliases right here. 58 00:02:19,140 --> 00:02:24,140 ‫So I am on version 1 and if I click on version 1 59 00:02:24,450 --> 00:02:26,760 ‫and I try to go to Function URL, as you can see, 60 00:02:26,760 --> 00:02:28,540 ‫it says you can only add a Function URL 61 00:02:28,540 --> 00:02:32,190 ‫to unpublished function versions or an alias. 62 00:02:32,190 --> 00:02:36,210 ‫So we can go to the unpublished version, which is latest. 63 00:02:36,210 --> 00:02:38,550 ‫And in latest, I can also, if I wanted to, 64 00:02:38,550 --> 00:02:40,560 ‫create a Function URL, 65 00:02:40,560 --> 00:02:44,250 ‫which would allow people to access my latest Lambda version. 66 00:02:44,250 --> 00:02:46,470 ‫Okay, so we've seen how Functions URL work. 67 00:02:46,470 --> 00:02:49,533 ‫I hope you liked it and I will see you in the next lecture.