1 00:00:00,340 --> 00:00:02,360 So let's practice using SNS. 2 00:00:02,360 --> 00:00:05,470 So we're going to go into the simple notification service 3 00:00:05,470 --> 00:00:07,220 and create our first topic. 4 00:00:07,220 --> 00:00:10,370 So I'll just call this my first topic 5 00:00:10,370 --> 00:00:12,560 and then click on the next step. 6 00:00:12,560 --> 00:00:14,980 So we have two options for creating a topic. 7 00:00:14,980 --> 00:00:17,000 It can either be a standard topic 8 00:00:17,000 --> 00:00:17,950 and this will be creating 9 00:00:17,950 --> 00:00:20,160 which is best effort message ordering 10 00:00:20,160 --> 00:00:22,540 at least once message delivery, highest reboot 11 00:00:22,540 --> 00:00:24,310 in terms of publishers per second 12 00:00:24,310 --> 00:00:27,830 and SQS Lambda HTTP, SMS, email 13 00:00:27,830 --> 00:00:29,690 and mobile application endpoints can read 14 00:00:29,690 --> 00:00:32,110 from this SNS topic, or we've seen 15 00:00:32,110 --> 00:00:34,890 that we could create an SNS FIFO topic. 16 00:00:34,890 --> 00:00:38,490 And this is to get a strictly preserved message ordering 17 00:00:38,490 --> 00:00:40,210 exactly once message delivery. 18 00:00:40,210 --> 00:00:42,970 High-throughput up to 300 publishes per second. 19 00:00:42,970 --> 00:00:44,470 And the only thing that can subscribe 20 00:00:44,470 --> 00:00:48,110 to a FIFO SNS topic is an SQS FIFO queue. 21 00:00:48,110 --> 00:00:49,710 In this case, if we are FIFO, we can see 22 00:00:49,710 --> 00:00:53,100 that the name of the topic has to end with dot FIFO. 23 00:00:53,100 --> 00:00:54,880 So we'll just go with standard 24 00:00:54,880 --> 00:00:58,090 and then we'll use my first topic as the name. 25 00:00:58,090 --> 00:01:00,770 We can encrypt the messages in our topic. 26 00:01:00,770 --> 00:01:02,840 We can set up an access policy 27 00:01:02,840 --> 00:01:05,319 and the excess policy is going to define who 28 00:01:05,319 --> 00:01:08,163 and what can right to the SNS topics. 29 00:01:08,163 --> 00:01:10,280 So this is similar to an S3 bucket policy 30 00:01:10,280 --> 00:01:15,280 and this is similar to also an SQS access to policy, okay? 31 00:01:15,800 --> 00:01:17,870 The idea is that with this access policy, for example 32 00:01:17,870 --> 00:01:19,650 we could set up an S3 buckets 33 00:01:19,650 --> 00:01:22,130 to write events into an SNS topic. 34 00:01:22,130 --> 00:01:25,020 And then as SNS topic can send data to SQS and so on. 35 00:01:25,020 --> 00:01:26,670 So the access policy will be needed 36 00:01:26,670 --> 00:01:29,960 to allow the extra buckets to write to our SNS topic. 37 00:01:29,960 --> 00:01:31,150 So for now just use basic 38 00:01:31,150 --> 00:01:33,260 because we don't need to do anything fancy 39 00:01:33,260 --> 00:01:35,980 and then we are not going to set up any of these 40 00:01:35,980 --> 00:01:38,560 and then we'll just click on create topic. 41 00:01:38,560 --> 00:01:40,610 So my first topic is created 42 00:01:40,610 --> 00:01:44,370 and as we can see right now, we have zero subscriptions. 43 00:01:44,370 --> 00:01:46,840 So we need to create our first subscription. 44 00:01:46,840 --> 00:01:49,390 So I'm going to create one and winters sort protocol. 45 00:01:49,390 --> 00:01:52,320 So it could be Kinesis Data Firehose, SQS, 46 00:01:52,320 --> 00:01:57,110 Lambda, email, email, Jason HTTP, HTTPS and SMS, okay? 47 00:01:57,110 --> 00:01:59,310 And you have to remember those going into the exempt 48 00:01:59,310 --> 00:02:02,520 but to make it very simple, we're first going to use email 49 00:02:02,520 --> 00:02:05,260 and actually only going to use email in this hands-on. 50 00:02:05,260 --> 00:02:06,450 Now we need to use an endpoint. 51 00:02:06,450 --> 00:02:07,640 So an email address 52 00:02:07,640 --> 00:02:10,110 I will use stephantheteacher@mailinator.com 53 00:02:13,370 --> 00:02:16,260 And this is just a service for me to get a temporary email. 54 00:02:16,260 --> 00:02:20,430 So if I type Stephantheteacher and press on go, 55 00:02:20,430 --> 00:02:22,040 then I'm getting a public inbox 56 00:02:22,040 --> 00:02:26,040 and that will receive emails from this address, okay? 57 00:02:26,040 --> 00:02:27,840 So we're going to create this. 58 00:02:27,840 --> 00:02:28,910 As we can see right here, 59 00:02:28,910 --> 00:02:32,040 we could set up a subscription filter policy. 60 00:02:32,040 --> 00:02:34,350 This is optional, but with this policy 61 00:02:34,350 --> 00:02:36,940 we could filter the messages that will be sent 62 00:02:36,940 --> 00:02:39,140 to the subscription, which can be really helpful. 63 00:02:39,140 --> 00:02:40,070 If you have many subscribers 64 00:02:40,070 --> 00:02:42,640 there's just needs to get only a subsets of the messages 65 00:02:42,640 --> 00:02:45,560 sent into your sq or your SNS topic 66 00:02:45,560 --> 00:02:47,410 but we will not set it up right now. 67 00:02:47,410 --> 00:02:49,120 So we'll create this subscription 68 00:02:49,120 --> 00:02:53,180 and now we need to validate the subscription. 69 00:02:53,180 --> 00:02:55,930 So as we can see right now, it is pending confirmation. 70 00:02:56,780 --> 00:02:58,740 And so to confirm it, I'm going to go 71 00:02:58,740 --> 00:03:01,080 into my mailinator and I've received an email. 72 00:03:01,080 --> 00:03:03,500 And by clicking on this confirm subscription 73 00:03:03,500 --> 00:03:04,810 I'm going to confirm a subscription. 74 00:03:04,810 --> 00:03:06,070 So here we go. 75 00:03:06,070 --> 00:03:09,340 And now if I refresh this page, what I should be seeing 76 00:03:09,340 --> 00:03:11,820 is that my subscription right here is confirmed. 77 00:03:11,820 --> 00:03:13,060 So this is perfect. 78 00:03:13,060 --> 00:03:14,640 So and again, if I click on my subscription, 79 00:03:14,640 --> 00:03:15,860 I can look at it, 80 00:03:15,860 --> 00:03:18,590 see that is going to send an email to this end point. 81 00:03:18,590 --> 00:03:19,870 And if I wanted to do it 82 00:03:19,870 --> 00:03:22,540 I could have a subscription filter policy 83 00:03:22,540 --> 00:03:23,690 but right now we don't have any 84 00:03:23,690 --> 00:03:26,540 because we want all messages send to my SNS topic 85 00:03:26,540 --> 00:03:29,070 to go there directly into the subscription. 86 00:03:29,070 --> 00:03:30,450 So now let's do a test. 87 00:03:30,450 --> 00:03:32,410 We're going to publish a message. 88 00:03:32,410 --> 00:03:35,540 And I'm going to just enter a message structure. 89 00:03:35,540 --> 00:03:38,300 I'll say hello world which is very common 90 00:03:38,300 --> 00:03:42,870 when we test some services and then publish the message. 91 00:03:42,870 --> 00:03:46,070 So the message has been published into my first topic. 92 00:03:46,070 --> 00:03:47,280 And so what I should be seeing 93 00:03:47,280 --> 00:03:49,320 is that if I go back to my emails 94 00:03:49,320 --> 00:03:51,580 and go to my public messages 95 00:03:51,580 --> 00:03:54,330 so back to my inbox, I should be seeing yes 96 00:03:54,330 --> 00:03:57,310 an AWS notification message coming straight from SNS 97 00:03:57,310 --> 00:03:58,930 saying hello world. 98 00:03:58,930 --> 00:04:01,380 So they're easy, very cool. 99 00:04:01,380 --> 00:04:04,580 And we just show that SNS is working for us. 100 00:04:04,580 --> 00:04:06,520 So this is perfect, we're good to go. 101 00:04:06,520 --> 00:04:09,590 If we wanted to implement the SQS fan-out pattern 102 00:04:09,590 --> 00:04:12,070 we would need to choose SQS and set up 103 00:04:12,070 --> 00:04:15,150 many, many different cues as the receivers 104 00:04:15,150 --> 00:04:17,610 of the subscription for our SNS topic. 105 00:04:17,610 --> 00:04:19,230 So, yep, that's it for SNS. 106 00:04:19,230 --> 00:04:21,899 When you're done, delete the subscription 107 00:04:21,899 --> 00:04:26,050 and then go back to the topic on the left hand side 108 00:04:26,050 --> 00:04:27,600 and then click on delete 109 00:04:27,600 --> 00:04:30,890 to delete the topic by tapping delete me. 110 00:04:30,890 --> 00:04:33,230 And if you go, that's it for SNS 111 00:04:33,230 --> 00:04:36,180 I hope you liked it and I will see you in the next lecture.