1
00:00:00,090 --> 00:00:05,160
In this video, we are going to subscribe and unsubscribe from topic on Amazon.

2
00:00:05,200 --> 00:00:08,660
Since using SDK libraries.

3
00:00:08,670 --> 00:00:16,800
So in this example, we will use Node.js application and SDK libraries to perform list subscription,

4
00:00:16,800 --> 00:00:20,700
subscribe, command and subscribe command and confirm subscriptions.

5
00:00:21,030 --> 00:00:27,150
So if you go to documentation, you can see that we will use SNS Client Library.

6
00:00:27,420 --> 00:00:30,570
I would like to show which commands we are going to use.

7
00:00:30,570 --> 00:00:32,910
You can see the commands that we are going to use.

8
00:00:32,940 --> 00:00:38,850
Basically we will subscribe command to subscribe to topic and after that we will confirm the subscription

9
00:00:38,850 --> 00:00:39,510
command.

10
00:00:39,510 --> 00:00:43,050
And after that we can list subscriptions by topic command.

11
00:00:43,050 --> 00:00:46,050
And lastly, we will unsubscribe to command.

12
00:00:46,050 --> 00:00:49,620
So these are the four commands that we are going to use when performing.

13
00:00:49,650 --> 00:00:53,190
Subscribe unsubscribe from the topic on Amazon Sans.

14
00:00:53,250 --> 00:00:59,670
So if you go to documentation, you can go to SNS, client SDK documentation and you can go to subscribe

15
00:00:59,670 --> 00:01:06,300
command and see the example usage and see the example input of the subscriber command that is required

16
00:01:06,300 --> 00:01:10,860
to topic Aaron and other protocol attributes and so on.

17
00:01:11,010 --> 00:01:12,630
So let's get started.

18
00:01:12,630 --> 00:01:19,950
First of all, when we are subscribing a topic, we need to think about the subscriber way we are going

19
00:01:19,950 --> 00:01:21,450
to use email.

20
00:01:21,450 --> 00:01:27,670
So that's why I got a temporary email for subscribing an SNS topic and make sure that you have created

21
00:01:27,680 --> 00:01:30,750
a new topic on the SNS and get a run of the topic.

22
00:01:30,750 --> 00:01:33,600
So we will subscribe an endpoint to Amazon.

23
00:01:33,690 --> 00:01:41,750
So if the endpoint type is HTTP or email or if the endpoint type is a topic are not in the same account,

24
00:01:41,790 --> 00:01:46,410
the endpoint owner must run the confirmed subscription action to confirm the subscription.

25
00:01:46,410 --> 00:01:48,570
So we will follow the email.

26
00:01:48,580 --> 00:01:51,030
So that's why we have to confirm the subscription.

27
00:01:51,300 --> 00:01:56,730
So how we can subscribing an email of this to the topic, we will create an object containing the protocol

28
00:01:56,730 --> 00:02:01,860
parameter to specify the email protocol and the topic arm for the topic to subscribe.

29
00:02:01,860 --> 00:02:04,740
And the email address is the message endpoint.

30
00:02:04,740 --> 00:02:10,560
So we will pass the parameter to the subscribe command method of the SNS client class and we can use

31
00:02:10,560 --> 00:02:15,570
the Subscribe method to subscribe several different endpoints to Amazon sans topic.

32
00:02:15,810 --> 00:02:18,420
So let's get started for that purpose.

33
00:02:18,450 --> 00:02:20,130
Please open the OR.

34
00:02:20,130 --> 00:02:25,620
We just do code and we will follow the subscribe command in here.

35
00:02:25,890 --> 00:02:33,060
If you scroll down you can see that I have created the subscribe topic that JS file, which is basically

36
00:02:33,060 --> 00:02:36,600
perform the same operations that we have explained.

37
00:02:36,600 --> 00:02:42,840
So as you can see that this time we will use the subscribe command and the parameters are differentiate.

38
00:02:42,840 --> 00:02:49,950
You can see the protocol is an email and topic n is that we have created in the last video and the endpoint

39
00:02:49,950 --> 00:02:52,710
is our email of this.

40
00:02:52,710 --> 00:03:00,660
I can get the temporary email if you go to temp mail and copy this mail and go back to our application,

41
00:03:00,870 --> 00:03:08,400
you can paste and print as a temporary email that we see how we can proceed and subscribe to topic.

42
00:03:08,400 --> 00:03:11,430
And after that the rest of the command is the same.

43
00:03:11,580 --> 00:03:14,520
So as you can see that we will run the subscribe topic.

44
00:03:14,520 --> 00:03:24,390
Now, in order to do that, I'm going to run the node command, not subscribe topic that is hit enter.

45
00:03:25,610 --> 00:03:33,500
So as you can see that we have successfully subscribed to the topic and the status is pending confirmation.

46
00:03:33,500 --> 00:03:36,070
So that means it is required a confirmation.

47
00:03:36,080 --> 00:03:42,200
So basically we will confirm the subscription to defining the parameters, including the topic and the

48
00:03:42,200 --> 00:03:42,710
token.

49
00:03:42,710 --> 00:03:48,420
So that means we need to get the token of the subscription mail.

50
00:03:48,440 --> 00:03:56,030
If you go back to our mail address and if you open the mail that comes from the notification subscription

51
00:03:56,030 --> 00:03:56,720
confirmation.

52
00:03:56,720 --> 00:03:58,610
So I don't see any token information.

53
00:03:58,610 --> 00:04:03,260
So that's why I click the confirm subscription to confirm our operation.

54
00:04:03,260 --> 00:04:08,840
Yes, you can see that the subscription is confirmed and you can see the subscription ID in here.

55
00:04:08,840 --> 00:04:13,640
You can copy this subscription ID to use these ID for the upcoming actions.

56
00:04:13,640 --> 00:04:14,330
Okay.

57
00:04:14,330 --> 00:04:20,000
Now we have performed the confirmed subscription, but I would like to show you how we can compare subscription

58
00:04:20,000 --> 00:04:22,640
with using the libraries.

59
00:04:22,640 --> 00:04:29,000
If you come to subscribe, confirm as it is required to token information and paste the topic, earn

60
00:04:29,000 --> 00:04:32,210
and authenticate the own unsubscribe users.

61
00:04:32,210 --> 00:04:35,330
It is basically confirm operation for the subscription.

62
00:04:35,330 --> 00:04:42,080
Since we have subscribed this, since we have confirmed the subscription successfully, we can listing

63
00:04:42,080 --> 00:04:44,150
the subscription for that purpose.

64
00:04:44,150 --> 00:04:47,210
I'm going to write a list subscription command.

65
00:04:47,210 --> 00:04:53,030
If you come to in here, we have created subscription list and this is only required for the topic run

66
00:04:53,030 --> 00:04:59,390
and we will pass this topic a run to the list subscription by Topic Command, which we will listing

67
00:04:59,390 --> 00:05:03,170
to subscriptions for the particular command for that purpose.

68
00:05:03,170 --> 00:05:07,010
Let me run this note command and pacing the subscriber list.

69
00:05:07,100 --> 00:05:08,900
Subscriber list.

70
00:05:10,450 --> 00:05:11,260
Hit Enter.

71
00:05:12,420 --> 00:05:15,390
And make sure that we have subscript and point.

72
00:05:15,420 --> 00:05:20,800
You can see the our email address and this is the topic around protocol is email.

73
00:05:20,820 --> 00:05:23,190
So the subscription is ready for now.

74
00:05:23,190 --> 00:05:27,210
And also we can check from the our SNS environment.

75
00:05:27,210 --> 00:05:30,360
If you go to topics, open the topic and scroll down.

76
00:05:30,360 --> 00:05:34,110
You can see the confirmed subscription in here.

77
00:05:34,110 --> 00:05:36,890
This is the email address and protocol is email.

78
00:05:36,900 --> 00:05:43,180
So we have successful subscribe, confirm and listing subscription from the Our Node.js application.

79
00:05:43,200 --> 00:05:46,230
Now the last thing is publish the command.

80
00:05:46,230 --> 00:05:54,120
I'm going to publish command to our topic and see the message will be subscribed from the our email

81
00:05:54,120 --> 00:05:54,750
address.

82
00:05:54,840 --> 00:05:57,990
As you remember that in the last video we have published the topic.

83
00:05:57,990 --> 00:06:03,600
So that's why I'm going to use the same publish topic JavaScript file to run this.

84
00:06:03,600 --> 00:06:10,230
We can run the node command and run the publish topic, the JS file, make sure that your topic a run

85
00:06:10,230 --> 00:06:13,080
is the same that we create in the section.

86
00:06:13,080 --> 00:06:16,140
So hit enter and publish the message.

87
00:06:16,140 --> 00:06:19,710
So as you can see that the message ID comes in here successfully.

88
00:06:19,710 --> 00:06:26,700
So that means we have successfully published a message to the our topic and this message should be subscribed

89
00:06:26,700 --> 00:06:30,090
from the our subscriber services that we see.

90
00:06:30,090 --> 00:06:34,200
The subscriber services are is the email of our application.

91
00:06:34,200 --> 00:06:41,040
If you go back to our email and see the incoming message, you can see the notification message comes

92
00:06:41,040 --> 00:06:42,480
from the our topic.

93
00:06:42,480 --> 00:06:47,400
If you open these messages message, you can see the detail of the our message.

94
00:06:47,400 --> 00:06:50,550
That is the example publish command message.

95
00:06:50,790 --> 00:06:52,320
Okay, very good.

96
00:06:52,350 --> 00:07:00,240
We basically subscribe and publish topic to the message and get message from our email address.

97
00:07:00,240 --> 00:07:05,160
And now the last thing that we can do is unsubscribe from a topic.

98
00:07:05,160 --> 00:07:09,480
To do that, we are going to use unsubscribe topic to JS file.

99
00:07:09,480 --> 00:07:15,930
If you come here and see that it is required us from the topic area that we are going to use for the

100
00:07:15,930 --> 00:07:22,800
unsubscribe operations is you remember that in the OR when we are subscribed information the subscription

101
00:07:22,800 --> 00:07:28,560
we have a subscription ID, you can copy these here and this is the subscription again or you can come

102
00:07:28,560 --> 00:07:32,220
here and go to the subscription and get the error from in here.

103
00:07:32,250 --> 00:07:38,730
These are the same error and we have to pass the subscription again to our unsubscribe operation.

104
00:07:38,730 --> 00:07:41,850
I'm pasting this unsubscribe subscription.

105
00:07:41,850 --> 00:07:47,940
I ran into the parameters of the unsubscribe command and after that we are going to run these.

106
00:07:49,110 --> 00:07:52,040
Well, just model for the unsubscribing operation.

107
00:07:52,050 --> 00:07:56,820
You can see that I'm going to run node unsubscribe topic that just hit the enter.

108
00:07:57,270 --> 00:08:00,360
So now we have successful unsubscribe from the topic.

109
00:08:00,390 --> 00:08:06,150
If you go to the our main environment, go to the topics, open the topic.

110
00:08:06,180 --> 00:08:08,640
You can see that we have no subscription now.

111
00:08:08,700 --> 00:08:14,640
So as you can see that we have successfully subscribed and unsubscribe from the Amazon since topic.
