1 00:00:06,870 --> 00:00:08,120 - Now, let's review a demo 2 00:00:08,120 --> 00:00:10,473 of stopping and terminating EC2 instances. 3 00:00:12,440 --> 00:00:17,440 Now, from the EC2 dashboard we can go to Instances 4 00:00:17,690 --> 00:00:21,023 and you'll see we have the Linux instance 5 00:00:21,023 --> 00:00:22,420 that we created earlier, 6 00:00:22,420 --> 00:00:25,800 we have a Windows instance that we launched earlier 7 00:00:25,800 --> 00:00:29,100 and then I took the liberty of duplicating 8 00:00:29,100 --> 00:00:32,920 a Linux instance just so we had something to terminate. 9 00:00:32,920 --> 00:00:37,490 So, if we were to look at the actions that we can take, 10 00:00:37,490 --> 00:00:41,790 we can start an instance, stop an instance, 11 00:00:41,790 --> 00:00:43,420 we can do stop, hibernate, 12 00:00:43,420 --> 00:00:45,230 we can reboot and we can terminate. 13 00:00:45,230 --> 00:00:50,140 So, in many cases rebooting may be, 14 00:00:50,140 --> 00:00:51,430 you know, a viable option. 15 00:00:51,430 --> 00:00:54,050 It may be appropriate for that particular application 16 00:00:54,050 --> 00:00:55,950 in that particular scenario. 17 00:00:55,950 --> 00:00:57,930 And so, you can do that right here from the console 18 00:00:57,930 --> 00:01:00,250 just simply cause that machine to reboot 19 00:01:00,250 --> 00:01:01,310 and perhaps, you know, 20 00:01:01,310 --> 00:01:03,680 there's an issue that could be resolved 21 00:01:03,680 --> 00:01:05,790 by simply rebooting the machine 22 00:01:05,790 --> 00:01:07,250 or perhaps you're doing something 23 00:01:07,250 --> 00:01:10,700 with a machine that just requires rebooting 24 00:01:10,700 --> 00:01:13,337 like you know, maybe installing something in Windows 25 00:01:13,337 --> 00:01:15,050 and you can do that. 26 00:01:15,050 --> 00:01:18,560 Otherwise, rebooting simply, 27 00:01:18,560 --> 00:01:19,970 like the machine doesn't go away 28 00:01:19,970 --> 00:01:21,220 and come back it's there 29 00:01:21,220 --> 00:01:23,060 but it's just like a machine on your desk, 30 00:01:23,060 --> 00:01:24,500 if you hit the reboot button 31 00:01:24,500 --> 00:01:27,460 or you go to your you know, start menu or whatever 32 00:01:27,460 --> 00:01:30,410 and you just say reboot, that's essentially what it's doing, 33 00:01:30,410 --> 00:01:32,670 the instance doesn't go anywhere. 34 00:01:32,670 --> 00:01:36,100 Now, in other cases, we may decide you know what, 35 00:01:36,100 --> 00:01:38,300 we don't actually need this machine anymore. 36 00:01:39,350 --> 00:01:40,680 So, we could just say terminate. 37 00:01:40,680 --> 00:01:43,150 If we were to terminate then it will say, 38 00:01:43,150 --> 00:01:44,859 are you sure you want to terminate. 39 00:01:44,859 --> 00:01:47,390 These will be gone, right. 40 00:01:47,390 --> 00:01:50,490 Any storage on any local volumes will be gone, 41 00:01:50,490 --> 00:01:53,533 the EBS volume that's attached will also be deleted. 42 00:01:54,540 --> 00:01:56,770 And of course this one says, 43 00:01:56,770 --> 00:01:59,870 it has termination protection and will not be terminated. 44 00:01:59,870 --> 00:02:01,930 So, before I can terminate it, 45 00:02:01,930 --> 00:02:06,320 I have to go to Instance Settings, 46 00:02:06,320 --> 00:02:08,333 Change Termination Protection, 47 00:02:09,500 --> 00:02:11,540 and say Yes, Disable. 48 00:02:11,540 --> 00:02:13,440 Right, so, it's a safety mechanism, 49 00:02:13,440 --> 00:02:16,570 I'm going to go ahead now that I've disabled that. 50 00:02:16,570 --> 00:02:19,930 Now, I can say Terminate. 51 00:02:19,930 --> 00:02:23,050 And it says this is an EBS-backed instance, 52 00:02:23,050 --> 00:02:24,680 meaning that the root volume 53 00:02:24,680 --> 00:02:26,440 is backed by an EBS volume 54 00:02:26,440 --> 00:02:29,220 and that volume will also be deleted. 55 00:02:29,220 --> 00:02:30,730 Are you sure you wanna do that? 56 00:02:30,730 --> 00:02:32,870 Yes, let's go ahead and terminate that instance. 57 00:02:32,870 --> 00:02:35,620 And so, then it goes into a shutting down state 58 00:02:35,620 --> 00:02:38,410 and then it will go into a terminated state. 59 00:02:38,410 --> 00:02:42,380 And so, that ID we will never see again 60 00:02:43,260 --> 00:02:45,490 because that instance now that we've terminated 61 00:02:45,490 --> 00:02:48,890 it's completely gone and it's a part of our history. 62 00:02:48,890 --> 00:02:50,840 You'll notice down here that we have an instance 63 00:02:50,840 --> 00:02:52,980 that is currently in a stopped state. 64 00:02:52,980 --> 00:02:56,120 Which means that it's not actively running 65 00:02:56,120 --> 00:02:59,120 like the other two are but it still exists. 66 00:02:59,120 --> 00:03:03,140 It hasn't been terminated but it's not running either. 67 00:03:03,140 --> 00:03:07,120 And so, the volume if you scroll down here, 68 00:03:07,120 --> 00:03:10,190 we should see that the root volume still exists, 69 00:03:10,190 --> 00:03:15,190 we still have some type of a EBS root volume 70 00:03:15,433 --> 00:03:17,110 that's still there. 71 00:03:17,110 --> 00:03:20,000 So, we're not paying the hourly fees 72 00:03:20,000 --> 00:03:21,710 for running this machine 73 00:03:21,710 --> 00:03:24,130 but we are paying the monthly storage fees 74 00:03:24,130 --> 00:03:26,240 for that EBS root volume. 75 00:03:26,240 --> 00:03:29,790 And so, there we go that other one is now terminated 76 00:03:29,790 --> 00:03:34,040 and so it will remain here in our console list 77 00:03:34,040 --> 00:03:37,780 for some time and we can also filter out 78 00:03:37,780 --> 00:03:41,800 if we wanted to filter by instance state, 79 00:03:41,800 --> 00:03:42,810 we could say you know what, 80 00:03:42,810 --> 00:03:44,300 I don't want to worry about 81 00:03:44,300 --> 00:03:46,350 those that are currently terminated to stop, 82 00:03:46,350 --> 00:03:48,420 just show me the ones that are running, right. 83 00:03:48,420 --> 00:03:51,790 And so, now we have this Linux instance 84 00:03:51,790 --> 00:03:53,510 and the Windows instance. 85 00:03:53,510 --> 00:03:58,510 So, let's go ahead and stop our Linux machine. 86 00:04:00,320 --> 00:04:01,340 Now, before we do that, 87 00:04:01,340 --> 00:04:02,690 I just wanna point out the difference 88 00:04:02,690 --> 00:04:04,420 between Stop and Stop-Hibernate. 89 00:04:04,420 --> 00:04:07,850 Stop-Hibernate is currently not available 90 00:04:07,850 --> 00:04:10,240 simply because we need to enable that ability 91 00:04:10,240 --> 00:04:12,060 when we launch the instance. 92 00:04:12,060 --> 00:04:13,581 If you don't enable that ability 93 00:04:13,581 --> 00:04:17,370 at the time you launch it then it's just not available. 94 00:04:17,370 --> 00:04:18,203 Right. 95 00:04:18,203 --> 00:04:20,300 So, we did not opt into that at the time 96 00:04:20,300 --> 00:04:24,140 we launched the instance but what that means is again, 97 00:04:24,140 --> 00:04:27,660 stopping it just means that it still exists 98 00:04:27,660 --> 00:04:31,075 but we can get it back, we can restart it, right. 99 00:04:31,075 --> 00:04:33,770 But Stop-Hibernate, 100 00:04:33,770 --> 00:04:35,460 the critical difference between Stop 101 00:04:35,460 --> 00:04:37,550 and Stop-Hibernate is that Hibernate 102 00:04:37,550 --> 00:04:40,860 maintains the contents of memory. 103 00:04:40,860 --> 00:04:44,420 So, when you stop it and then restart it again, 104 00:04:44,420 --> 00:04:46,540 whatever was in RAM gets put back 105 00:04:46,540 --> 00:04:48,610 and so the machine can immediately pick up 106 00:04:48,610 --> 00:04:50,640 where it left off rather than having to wait 107 00:04:50,640 --> 00:04:53,410 for you know, processes to start 108 00:04:53,410 --> 00:04:55,380 and pull information off of disk. 109 00:04:55,380 --> 00:04:56,750 So, let's go ahead and stop it 110 00:04:56,750 --> 00:04:59,100 and you'll notice here it's saying that any data 111 00:04:59,100 --> 00:05:00,980 on the ephemeral storage will be lost. 112 00:05:00,980 --> 00:05:03,700 This instance doesn't really have an ephemeral storage 113 00:05:03,700 --> 00:05:04,610 but if we did, 114 00:05:04,610 --> 00:05:07,340 if we had storage that came with the instance, 115 00:05:07,340 --> 00:05:09,610 not an EBS volume but a volume 116 00:05:09,610 --> 00:05:12,063 that was an intrinsic part of the instance 117 00:05:12,063 --> 00:05:16,520 and any data on that would be ephemeral and would be lost. 118 00:05:16,520 --> 00:05:18,610 So, I'll go ahead and stop that 119 00:05:18,610 --> 00:05:20,400 and then it goes into a stopping state 120 00:05:20,400 --> 00:05:24,380 and any time the state ends in i-n-g, 121 00:05:24,380 --> 00:05:26,870 like we're still paying for this instance. 122 00:05:26,870 --> 00:05:31,430 The second it is within the stopping state, 123 00:05:31,430 --> 00:05:32,840 we're still paying for it. 124 00:05:32,840 --> 00:05:36,340 So, again, any instance state that ends in i-n-g, 125 00:05:36,340 --> 00:05:37,600 we are paying for. 126 00:05:37,600 --> 00:05:39,870 So, as soon as it goes into a stopped state 127 00:05:39,870 --> 00:05:41,503 or a terminated state 128 00:05:41,503 --> 00:05:44,270 then that's when we stop paying for it. 129 00:05:44,270 --> 00:05:45,300 Right, so, now it's stopped, 130 00:05:45,300 --> 00:05:47,460 if I go ahead and clear this filter, 131 00:05:47,460 --> 00:05:49,690 you'll see here that here's the instance 132 00:05:49,690 --> 00:05:51,230 that we just stopped and now 133 00:05:51,230 --> 00:05:54,520 I am no longer paying for those hourly charges. 134 00:05:54,520 --> 00:05:58,440 I have a Windows machine that is still running 135 00:05:58,440 --> 00:06:01,150 and I am paying those hourly charges. 136 00:06:01,150 --> 00:06:04,040 Alright, so, the great thing about stopped instances 137 00:06:04,040 --> 00:06:06,940 is that they're already there. 138 00:06:06,940 --> 00:06:07,820 They're you know, 139 00:06:07,820 --> 00:06:10,540 you have applications are installed and configured 140 00:06:10,540 --> 00:06:12,840 and they're much faster, 141 00:06:12,840 --> 00:06:15,330 generally much faster to become available 142 00:06:15,330 --> 00:06:18,260 than launching an instance from scratch. 143 00:06:18,260 --> 00:06:20,020 So, if I wanted to get this back 144 00:06:20,020 --> 00:06:22,920 and pick up where my application and work left off, 145 00:06:22,920 --> 00:06:27,010 then all I would have to do is say Instance State, Start. 146 00:06:27,010 --> 00:06:29,340 And say, yes start that instance. 147 00:06:29,340 --> 00:06:31,670 And then it goes into a pending state 148 00:06:31,670 --> 00:06:35,220 and now I start to pay those hourly charges again. 149 00:06:35,220 --> 00:06:37,480 And it doesn't take very long at all 150 00:06:37,480 --> 00:06:41,660 for that instance to go from pending to running. 151 00:06:41,660 --> 00:06:43,960 Usually, somewhere around you know, 152 00:06:43,960 --> 00:06:46,590 depending on the whether it's Linux or Windows, 153 00:06:46,590 --> 00:06:48,730 some may take longer than others 154 00:06:48,730 --> 00:06:51,360 but there we go just in less than a minute 155 00:06:51,360 --> 00:06:54,970 it went from a stop state to a running state, alright. 156 00:06:54,970 --> 00:06:56,400 And then like I said earlier 157 00:06:56,400 --> 00:06:58,940 if we determine that we no longer needed these 158 00:06:58,940 --> 00:07:00,950 and we were never going to use them again, 159 00:07:00,950 --> 00:07:02,460 then of course I could go back here 160 00:07:02,460 --> 00:07:06,670 and go to Terminate but these two particular machines 161 00:07:06,670 --> 00:07:10,150 we will continue to use in future demos, right. 162 00:07:10,150 --> 00:07:15,150 So, that is how we can stop, terminate, and start instances.