1 00:00:04,960 --> 00:00:20,000 [Music] 2 00:00:20,840 --> 00:00:24,880 good morning and welcome back to devops 3 00:00:23,279 --> 00:00:27,320 uh as a quick bit of housekeeping and a 4 00:00:24,880 --> 00:00:29,279 reminder we are planning lightning talks 5 00:00:27,320 --> 00:00:30,439 this afternoon specifically for Dev oops 6 00:00:29,279 --> 00:00:32,360 separate from the main conference 7 00:00:30,439 --> 00:00:34,520 lightning talks if you would like to 8 00:00:32,360 --> 00:00:36,480 submit to that if you go to the program 9 00:00:34,520 --> 00:00:38,520 on the website and you scroll down a bit 10 00:00:36,480 --> 00:00:40,079 there's a link to Google forms that'll 11 00:00:38,520 --> 00:00:42,600 be closing partway through lunch and 12 00:00:40,079 --> 00:00:44,719 we'll be picking talks then up now 13 00:00:42,600 --> 00:00:47,399 though we have Luke Luke is a senior 14 00:00:44,719 --> 00:00:49,199 software engineer at wsp he's worked in 15 00:00:47,399 --> 00:00:50,600 the industry for seven years and has 16 00:00:49,199 --> 00:00:53,559 spent more time than he would like to 17 00:00:50,600 --> 00:00:55,440 admit debugging Django and python code 18 00:00:53,559 --> 00:00:57,239 Luke was also a long time ago an 19 00:00:55,440 --> 00:00:59,000 Australian representative gymnast 20 00:00:57,239 --> 00:01:02,920 competing at the Commonwealth Games and 21 00:00:59,000 --> 00:01:02,920 World Championships please welcome 22 00:01:05,920 --> 00:01:10,799 Luke all right test is this thing on yep 23 00:01:08,960 --> 00:01:14,439 cool um today we're talking about D 24 00:01:10,799 --> 00:01:18,000 Jango on AWS for Chum change so really 25 00:01:14,439 --> 00:01:21,320 the um the inspiration of this talk is 26 00:01:18,000 --> 00:01:24,960 uh Heroku uh which uh when I first 27 00:01:21,320 --> 00:01:29,000 started out writing python code um was a 28 00:01:24,960 --> 00:01:31,040 real uh Forerunner in making it able to 29 00:01:29,000 --> 00:01:32,759 just deploy python code out there and 30 00:01:31,040 --> 00:01:34,399 get something out for really really 31 00:01:32,759 --> 00:01:36,880 cheap I think things have kind of 32 00:01:34,399 --> 00:01:40,000 changed uh over the years with Heroku 33 00:01:36,880 --> 00:01:44,479 but um the eventual goal is to kind of 34 00:01:40,000 --> 00:01:45,200 somewhat uh build our own Heroku in uh 35 00:01:44,479 --> 00:01:48,240 in 36 00:01:45,200 --> 00:01:50,119 AWS um if you want to play along uh all 37 00:01:48,240 --> 00:01:54,119 the links that I have within this uh 38 00:01:50,119 --> 00:01:56,079 talk are over on my website in the blog 39 00:01:54,119 --> 00:01:57,719 um you can also skip ahead to see the 40 00:01:56,079 --> 00:02:00,719 end of this so you don't have to hear me 41 00:01:57,719 --> 00:02:03,439 R Ramble On for half an hour um my name 42 00:02:00,719 --> 00:02:05,799 is Luke vitovsky well done to anybody 43 00:02:03,439 --> 00:02:08,440 who knows to actually pronounce that 44 00:02:05,799 --> 00:02:11,120 last name but that's okay um yeah I'm a 45 00:02:08,440 --> 00:02:14,000 senior software engineer for wsp and in 46 00:02:11,120 --> 00:02:17,040 my foral life I was a Australian uh 47 00:02:14,000 --> 00:02:18,400 level representative gymnast um if you 48 00:02:17,040 --> 00:02:21,800 want to catch me on any of the socials 49 00:02:18,400 --> 00:02:25,040 Luke we is my handle you know find me 50 00:02:21,800 --> 00:02:27,879 wherever um so first off let's talk 51 00:02:25,040 --> 00:02:30,680 about AWS if you're going to build 52 00:02:27,879 --> 00:02:33,000 something on AWS uh specifically with 53 00:02:30,680 --> 00:02:35,879 Django and python um here's an 54 00:02:33,000 --> 00:02:37,280 Enterprise gra grade stack Enterprise 55 00:02:35,879 --> 00:02:39,760 and inverted commas because this is 56 00:02:37,280 --> 00:02:42,640 about how much I could fit on the page 57 00:02:39,760 --> 00:02:44,319 um ignore all the stupid names and stuff 58 00:02:42,640 --> 00:02:46,040 uh I didn't really have time to draw 59 00:02:44,319 --> 00:02:47,879 pretty pictures about how you would do 60 00:02:46,040 --> 00:02:51,599 it um but this is kind of an 61 00:02:47,879 --> 00:02:53,319 autogenerated uh thing from uh AWS to uh 62 00:02:51,599 --> 00:02:54,280 show you the kind of Stack we're talking 63 00:02:53,319 --> 00:02:56,720 about 64 00:02:54,280 --> 00:03:00,000 here um so that's pretty complicated 65 00:02:56,720 --> 00:03:03,120 it's pretty annoying um there is another 66 00:03:00,000 --> 00:03:06,799 way to represent this and that is in 67 00:03:03,120 --> 00:03:08,519 code um so here's the same thing uh 68 00:03:06,799 --> 00:03:10,159 don't be too worried if you can't fully 69 00:03:08,519 --> 00:03:12,560 understand what's going on here but 70 00:03:10,159 --> 00:03:14,959 essentially all that stuff that we had 71 00:03:12,560 --> 00:03:18,280 over there is now written down in some 72 00:03:14,959 --> 00:03:21,159 nice easy to read inverted commas uh 73 00:03:18,280 --> 00:03:25,080 python code um very logical structured 74 00:03:21,159 --> 00:03:26,040 bang bang bang uh down the page um so 75 00:03:25,080 --> 00:03:27,879 what we're going to do here is we're 76 00:03:26,040 --> 00:03:29,879 going to play a game we're going to 77 00:03:27,879 --> 00:03:31,599 build ajango app but we're not going to 78 00:03:29,879 --> 00:03:34,159 scale it up to Enterprise we're going to 79 00:03:31,599 --> 00:03:35,840 scale it down imagine you got this app 80 00:03:34,159 --> 00:03:38,879 you've built it up and you want to share 81 00:03:35,840 --> 00:03:40,680 it with your friends and family maybe 82 00:03:38,879 --> 00:03:42,319 just one other person your partner you 83 00:03:40,680 --> 00:03:45,319 don't want the world to see it you don't 84 00:03:42,319 --> 00:03:47,680 care about scale you want to scale down 85 00:03:45,319 --> 00:03:49,760 how do you do that in an AWS context 86 00:03:47,680 --> 00:03:52,519 where everything is pushing you to scale 87 00:03:49,760 --> 00:03:55,079 up um so I've built ajango app for my 88 00:03:52,519 --> 00:03:56,680 family I want to host it somewhere um 89 00:03:55,079 --> 00:03:59,439 and I don't want to maintain it I don't 90 00:03:56,680 --> 00:04:02,120 want any pets I don't want to uh bother 91 00:03:59,439 --> 00:04:03,840 with a VPS or anything um I want 92 00:04:02,120 --> 00:04:05,640 something that I can push a button and 93 00:04:03,840 --> 00:04:08,480 it'll spin up and push a button it'll 94 00:04:05,640 --> 00:04:12,000 spin down and it'll largely 95 00:04:08,480 --> 00:04:13,799 self-correct um the rules AWS 96 00:04:12,000 --> 00:04:15,920 exclusively uh there are plenty of 97 00:04:13,799 --> 00:04:18,799 services out there you can use but AWS 98 00:04:15,920 --> 00:04:21,120 is the goriller in the room um and it's 99 00:04:18,799 --> 00:04:22,560 a good learning exercise uh we're going 100 00:04:21,120 --> 00:04:24,040 to use infrastructure as code because 101 00:04:22,560 --> 00:04:26,680 we're in a python conference we're going 102 00:04:24,040 --> 00:04:28,960 to write some python uh to spin up all 103 00:04:26,680 --> 00:04:31,800 these Services uh in this case we're 104 00:04:28,960 --> 00:04:33,560 going to use uh the AWS cdk which is the 105 00:04:31,800 --> 00:04:35,720 cloud development kit I believe there 106 00:04:33,560 --> 00:04:39,840 will be a lot of three Le threel 107 00:04:35,720 --> 00:04:41,120 acronyms in this talk so apologies um if 108 00:04:39,840 --> 00:04:43,320 I get ahead of myself and I don't 109 00:04:41,120 --> 00:04:44,840 explain them all uh another one we're 110 00:04:43,320 --> 00:04:46,639 not going to use any stateful services 111 00:04:44,840 --> 00:04:48,960 like ec2 there's been plenty of other 112 00:04:46,639 --> 00:04:52,080 talks in Pon over the years about how 113 00:04:48,960 --> 00:04:54,440 you can make a ec2 instance really cheap 114 00:04:52,080 --> 00:04:56,680 essentially run it as a VPS that's not 115 00:04:54,440 --> 00:05:00,160 this talk I don't want to run a VPS I 116 00:04:56,680 --> 00:05:02,080 just want to spit the code at AWS and do 117 00:05:00,160 --> 00:05:04,840 it all for me and finally we're going to 118 00:05:02,080 --> 00:05:07,199 use Jango because Jango is an excellent 119 00:05:04,840 --> 00:05:09,520 uh web framework and we love to use it 120 00:05:07,199 --> 00:05:12,360 and we want to deploy it everywhere we 121 00:05:09,520 --> 00:05:14,720 can so um I'm going to have a little bit 122 00:05:12,360 --> 00:05:18,120 of audience uh participation here so 123 00:05:14,720 --> 00:05:22,120 just yell at me what's expensive in AWS 124 00:05:18,120 --> 00:05:24,919 come on tell me datab databases 125 00:05:22,120 --> 00:05:27,720 yes cues 126 00:05:24,919 --> 00:05:30,600 storage yeah yeah 127 00:05:27,720 --> 00:05:34,479 all almost every 128 00:05:30,600 --> 00:05:35,720 is a good uh answer yes um there are a 129 00:05:34,479 --> 00:05:37,960 couple of specific ones that we're going 130 00:05:35,720 --> 00:05:40,960 to talk about in terms of Jango 131 00:05:37,960 --> 00:05:44,400 specifically and that is yes relational 132 00:05:40,960 --> 00:05:48,039 databases um the services uh IDs which 133 00:05:44,400 --> 00:05:51,360 is yeah the relational database service 134 00:05:48,039 --> 00:05:53,720 um load balances can get very expensive 135 00:05:51,360 --> 00:05:57,199 as well um especially if you're just 136 00:05:53,720 --> 00:05:59,400 spinning one up uh singularly suddenly 137 00:05:57,199 --> 00:06:02,400 uh if you're a poor student in a dorm 138 00:05:59,400 --> 00:06:03,560 room and you're paying $20 a month for 139 00:06:02,400 --> 00:06:06,720 just a load 140 00:06:03,560 --> 00:06:07,840 balancer yeah that's a bit a bit pricey 141 00:06:06,720 --> 00:06:11,000 um not 142 00:06:07,840 --> 00:06:14,840 gateways they can bite you in the butt 143 00:06:11,000 --> 00:06:17,280 um and uh ads is very sneaky in that it 144 00:06:14,840 --> 00:06:20,759 will spin these up for you without you 145 00:06:17,280 --> 00:06:23,400 explicitly knowing a AWS is very helpful 146 00:06:20,759 --> 00:06:24,919 in that scenario also like uh W where 147 00:06:23,400 --> 00:06:27,560 about application framework can be 148 00:06:24,919 --> 00:06:29,880 expensive too so um we're actually not 149 00:06:27,560 --> 00:06:32,680 going to talk about the W we're g we're 150 00:06:29,880 --> 00:06:37,120 just going to let things hit our servers 151 00:06:32,680 --> 00:06:37,120 um what's cheap what's 152 00:06:37,199 --> 00:06:43,880 cheap Lambda Lambda yes Lambda is very 153 00:06:40,599 --> 00:06:46,840 cheap scales to zero anything 154 00:06:43,880 --> 00:06:50,759 else uh spot spot instances yes very 155 00:06:46,840 --> 00:06:55,039 good uh anything else S3 S3 yes the 156 00:06:50,759 --> 00:06:58,560 canonical storage uh service in 157 00:06:55,039 --> 00:07:00,080 AWS um Cloud front also very uh cheap as 158 00:06:58,560 --> 00:07:02,080 well we 159 00:07:00,080 --> 00:07:04,800 probably won't cover this today but uh 160 00:07:02,080 --> 00:07:07,120 really good to um front anything you do 161 00:07:04,800 --> 00:07:08,879 on AWS with a cloud front cloudfront 162 00:07:07,120 --> 00:07:10,960 instance as well but yeah I think you 163 00:07:08,879 --> 00:07:12,680 got them all um and we're going to 164 00:07:10,960 --> 00:07:15,080 transfer over to using 165 00:07:12,680 --> 00:07:19,199 these um so as I said before we're going 166 00:07:15,080 --> 00:07:22,280 to use the AWS cdk there's plenty of 167 00:07:19,199 --> 00:07:26,720 tools like this uh under the 168 00:07:22,280 --> 00:07:28,960 infrastructure as code um umbrella uh 169 00:07:26,720 --> 00:07:30,840 what are they called a terraform open 170 00:07:28,960 --> 00:07:33,360 tofu 171 00:07:30,840 --> 00:07:35,120 uh palumi I think there are a couple of 172 00:07:33,360 --> 00:07:38,120 others on this occasion we're just going 173 00:07:35,120 --> 00:07:41,919 to use uh the cdk one because it's 174 00:07:38,120 --> 00:07:45,400 native to AWS and two because it's cheap 175 00:07:41,919 --> 00:07:48,720 um it's very good uh I have links in my 176 00:07:45,400 --> 00:07:51,080 blog post uh to just the uh the general 177 00:07:48,720 --> 00:07:55,919 hello world starter on this occasion 178 00:07:51,080 --> 00:07:59,039 we're using python on a slight aside um 179 00:07:55,919 --> 00:08:01,400 if you do happen to use other languages 180 00:07:59,039 --> 00:08:04,199 um I would say that typescript ends up 181 00:08:01,400 --> 00:08:08,879 being the best in terms of support for 182 00:08:04,199 --> 00:08:12,520 cdk um and uh ergonomics Python's still 183 00:08:08,879 --> 00:08:14,759 pretty good um but typescript is what 184 00:08:12,520 --> 00:08:17,280 it's actually written in under the uh 185 00:08:14,759 --> 00:08:19,240 under the hood and that ends up seeing 186 00:08:17,280 --> 00:08:22,919 uh the earliest support for newer 187 00:08:19,240 --> 00:08:26,280 features and stuff what cdk actually is 188 00:08:22,919 --> 00:08:29,840 um is just a wrap around cloud formation 189 00:08:26,280 --> 00:08:31,960 which is aws's way to spin up all these 190 00:08:29,840 --> 00:08:35,519 through like a template um cloud 191 00:08:31,960 --> 00:08:39,640 formation is like yaml blobs and Json 192 00:08:35,519 --> 00:08:42,479 blobs all the way down and it's sucks um 193 00:08:39,640 --> 00:08:45,880 so we're going to use Python instead so 194 00:08:42,479 --> 00:08:48,080 let's begin um from our Enterprise grade 195 00:08:45,880 --> 00:08:50,680 stack we're going to do some quick easy 196 00:08:48,080 --> 00:08:53,959 savings that should have pretty much 197 00:08:50,680 --> 00:08:55,480 zero practical effects on um our 198 00:08:53,959 --> 00:08:56,760 application so first off we're going to 199 00:08:55,480 --> 00:09:00,640 remove the load 200 00:08:56,760 --> 00:09:03,040 balances um and before I keep going I 201 00:09:00,640 --> 00:09:05,640 will say what we're doing here is we're 202 00:09:03,040 --> 00:09:08,200 going for the cheap services that scale 203 00:09:05,640 --> 00:09:10,959 to zero there is always an inflection 204 00:09:08,200 --> 00:09:12,880 point where if you end up getting a lot 205 00:09:10,959 --> 00:09:15,519 of load it's often better to go with a 206 00:09:12,880 --> 00:09:18,120 load balancer than the alternative um 207 00:09:15,519 --> 00:09:20,640 because you get savings uh because of 208 00:09:18,120 --> 00:09:24,519 the load um so this is how we would 209 00:09:20,640 --> 00:09:26,519 Define a load balancer in cdk really 210 00:09:24,519 --> 00:09:28,120 simple we've got our load balancer 211 00:09:26,519 --> 00:09:30,399 connected to our VPC it's going to be 212 00:09:28,120 --> 00:09:32,880 internet facing really nice easy 213 00:09:30,399 --> 00:09:36,200 language to understand we add a listener 214 00:09:32,880 --> 00:09:38,480 to Port 80 or whatever Port you want 443 215 00:09:36,200 --> 00:09:41,839 I guess we should uh say here and then 216 00:09:38,480 --> 00:09:45,519 we add our D Jango container um Port 217 00:09:41,839 --> 00:09:47,720 8,000 which you know D Jango by default 218 00:09:45,519 --> 00:09:50,200 kind of serves on that port and you're 219 00:09:47,720 --> 00:09:51,920 good to go but this is expensive you 220 00:09:50,200 --> 00:09:55,440 spin one of these up and you're spending 221 00:09:51,920 --> 00:09:57,640 20 $30 a month just on the load balancer 222 00:09:55,440 --> 00:09:59,800 alone and that's not including any of uh 223 00:09:57,640 --> 00:10:03,240 the requests or services so there is an 224 00:09:59,800 --> 00:10:06,920 alternative anyone want to guess what it 225 00:10:03,240 --> 00:10:11,000 is uh API Gateway I've heard very good 226 00:10:06,920 --> 00:10:13,880 gold star to the person in the back um 227 00:10:11,000 --> 00:10:17,959 here we're going to do it in an ECS 228 00:10:13,880 --> 00:10:20,079 elastic container service um context so 229 00:10:17,959 --> 00:10:22,160 everything we're doing here is we're 230 00:10:20,079 --> 00:10:23,839 running D Jango in a container that 231 00:10:22,160 --> 00:10:26,320 makes it easy to kind of switch between 232 00:10:23,839 --> 00:10:30,320 different Services um we're going to use 233 00:10:26,320 --> 00:10:32,560 ECS uh because one it's cheap um two 234 00:10:30,320 --> 00:10:35,360 it's native uh to AWS and makes it 235 00:10:32,560 --> 00:10:41,279 really easy to spin up stuff in the cdk 236 00:10:35,360 --> 00:10:42,959 uh eks is a a different nightmare um all 237 00:10:41,279 --> 00:10:45,399 deployments are nightmares in some way 238 00:10:42,959 --> 00:10:48,600 but uh we're not going to use the eks 239 00:10:45,399 --> 00:10:53,600 because it's expensive um so yeah here 240 00:10:48,600 --> 00:10:56,720 we go uh in our ECS cluster uh we simply 241 00:10:53,600 --> 00:10:58,079 enable cloud map simply because 242 00:10:56,720 --> 00:11:01,399 everything we do here is actually going 243 00:10:58,079 --> 00:11:03,600 to be adding code and doing things uh in 244 00:11:01,399 --> 00:11:07,399 a more difficult sense cloud map is a 245 00:11:03,600 --> 00:11:09,959 way to add a network within your ECS uh 246 00:11:07,399 --> 00:11:13,800 cluster don't care about the Implement 247 00:11:09,959 --> 00:11:15,399 implementation details um but uh we add 248 00:11:13,800 --> 00:11:17,760 it to our cluster we add a service 249 00:11:15,399 --> 00:11:21,680 endpoints so that uh our container can 250 00:11:17,760 --> 00:11:25,120 read out to the VPC link so we're inside 251 00:11:21,680 --> 00:11:28,000 a VPC everything happens within a VPC 252 00:11:25,120 --> 00:11:32,120 which is a virtual private Cloud um in 253 00:11:28,000 --> 00:11:35,920 AWS uh and we uh attach it via an 254 00:11:32,120 --> 00:11:37,920 integration to an API Gateway um all of 255 00:11:35,920 --> 00:11:39,920 this trying to do it in the console or 256 00:11:37,920 --> 00:11:41,200 trying to do it through cloud formation 257 00:11:39,920 --> 00:11:43,399 or trying to do it through any other 258 00:11:41,200 --> 00:11:45,760 method is like really really verbose and 259 00:11:43,399 --> 00:11:49,839 annoying um but here we have these 260 00:11:45,760 --> 00:11:52,040 lovely uh uh Integrations uh 261 00:11:49,839 --> 00:11:54,959 specifically default uncore integration 262 00:11:52,040 --> 00:11:57,680 equals HTP service Discovery integration 263 00:11:54,959 --> 00:12:00,680 Bang You're Off to the Races you're out 264 00:11:57,680 --> 00:12:04,519 to the world what we are going to ignore 265 00:12:00,680 --> 00:12:06,920 in all this exercise is DNS that's a 266 00:12:04,519 --> 00:12:08,600 completely different problem um which 267 00:12:06,920 --> 00:12:11,079 you can do in several different ways but 268 00:12:08,600 --> 00:12:12,720 we're out to the internet great and 269 00:12:11,079 --> 00:12:15,720 we've saved a few 270 00:12:12,720 --> 00:12:17,600 dollars um next we're going to use some 271 00:12:15,720 --> 00:12:20,399 spot instances somebody over here 272 00:12:17,600 --> 00:12:23,399 mentioned spot instances so here we're 273 00:12:20,399 --> 00:12:25,240 going to use fargate Services because uh 274 00:12:23,399 --> 00:12:27,760 I don't want to manage the cluster in 275 00:12:25,240 --> 00:12:31,040 any meaningful sense AWS will spin up 276 00:12:27,760 --> 00:12:33,120 all the Services Under for me uh so here 277 00:12:31,040 --> 00:12:35,800 we're going to make sure that we have 278 00:12:33,120 --> 00:12:38,680 exactly one container running because we 279 00:12:35,800 --> 00:12:40,639 don't need more we don't need scale we 280 00:12:38,680 --> 00:12:42,800 don't care if it goes down for a few 281 00:12:40,639 --> 00:12:46,800 minutes or whatever um and we're going 282 00:12:42,800 --> 00:12:52,240 to set the capacity providers to spot um 283 00:12:46,800 --> 00:12:55,680 spot instances are what AWS uh kind of 284 00:12:52,240 --> 00:12:57,399 gives you is like their leftover CPU 285 00:12:55,680 --> 00:13:00,839 Cycles from other instances that people 286 00:12:57,399 --> 00:13:03,440 aren't using generally speaking uh it's 287 00:13:00,839 --> 00:13:05,120 a pretty reliable service but uh AWS 288 00:13:03,440 --> 00:13:07,639 will cover out with that it could go 289 00:13:05,120 --> 00:13:09,880 down from time to time and your service 290 00:13:07,639 --> 00:13:12,480 just needs to be able to spin up and 291 00:13:09,880 --> 00:13:15,320 down and know that it's it might um get 292 00:13:12,480 --> 00:13:16,680 taken down generally speaking though if 293 00:13:15,320 --> 00:13:19,040 you're just spinning up one spot 294 00:13:16,680 --> 00:13:20,800 instance you're generally okay 295 00:13:19,040 --> 00:13:23,720 especially with our application which is 296 00:13:20,800 --> 00:13:25,760 just for my friends and family um if 297 00:13:23,720 --> 00:13:27,680 they notice that it's down hit a refresh 298 00:13:25,760 --> 00:13:30,680 it'll probably be up 299 00:13:27,680 --> 00:13:33,519 again um all right those are the easy 300 00:13:30,680 --> 00:13:36,760 wins now we're going to start doing some 301 00:13:33,519 --> 00:13:40,040 slightly more risky stuff um with some 302 00:13:36,760 --> 00:13:41,519 tradeoffs but you know uh we want to 303 00:13:40,040 --> 00:13:44,120 save money at the end of the day we're a 304 00:13:41,519 --> 00:13:46,920 poor college student in our dorm room 305 00:13:44,120 --> 00:13:48,760 and we want to save a few bucks so we're 306 00:13:46,920 --> 00:13:51,399 going to remove Nat gateways Nat 307 00:13:48,760 --> 00:13:54,160 gateways what is a Nat 308 00:13:51,399 --> 00:13:56,480 Gateway someone tell me because I don't 309 00:13:54,160 --> 00:13:59,199 know I mean I know it does some sort of 310 00:13:56,480 --> 00:14:01,160 translation uh and allows you to speak 311 00:13:59,199 --> 00:14:04,120 to the public internet um these are 312 00:14:01,160 --> 00:14:06,839 sneaky things uh that a AWS will spin up 313 00:14:04,120 --> 00:14:09,839 for you if you just uh spin up a a 314 00:14:06,839 --> 00:14:13,320 virtual private cloud with no parameters 315 00:14:09,839 --> 00:14:17,600 whatsoever it will by default give you 316 00:14:13,320 --> 00:14:21,040 uh three subnets a public a private and 317 00:14:17,600 --> 00:14:24,759 a private with natat generally speaking 318 00:14:21,040 --> 00:14:26,839 if you follow all the like guides in AWS 319 00:14:24,759 --> 00:14:29,880 it'll push you to uh running your 320 00:14:26,839 --> 00:14:32,240 application within the private withn 321 00:14:29,880 --> 00:14:34,079 um and you run your database service for 322 00:14:32,240 --> 00:14:35,360 instance in the private subnet but 323 00:14:34,079 --> 00:14:37,440 basically giving you a little bit of 324 00:14:35,360 --> 00:14:39,079 protection so that not everything is out 325 00:14:37,440 --> 00:14:41,399 to the open 326 00:14:39,079 --> 00:14:43,720 internet um but here we're going to go 327 00:14:41,399 --> 00:14:46,519 straight out to the open internet uh set 328 00:14:43,720 --> 00:14:49,480 NE net gateways to zero uh we might have 329 00:14:46,519 --> 00:14:52,160 two subnets we'll have a public one and 330 00:14:49,480 --> 00:14:53,880 a private isolated one um but we're 331 00:14:52,160 --> 00:14:57,440 definitely not going to have one with a 332 00:14:53,880 --> 00:14:59,279 because they uh are quite pricey and you 333 00:14:57,440 --> 00:15:00,759 pay not just for the N instance but you 334 00:14:59,279 --> 00:15:01,920 pay for the traffic that goes through it 335 00:15:00,759 --> 00:15:04,560 as 336 00:15:01,920 --> 00:15:08,639 well all right big one we're going to 337 00:15:04,560 --> 00:15:11,440 remove RDS we're going to remove the uh 338 00:15:08,639 --> 00:15:13,360 um postrest service the managed service 339 00:15:11,440 --> 00:15:15,759 because you know what let's just do it 340 00:15:13,360 --> 00:15:19,720 ourselves it's not that hard right who 341 00:15:15,759 --> 00:15:23,120 who needs data reliability anyway um so 342 00:15:19,720 --> 00:15:26,639 this is how you would uh Define it in 343 00:15:23,120 --> 00:15:28,399 cdk pretty simple you make your database 344 00:15:26,639 --> 00:15:31,360 instance and then you attach it to your 345 00:15:28,399 --> 00:15:33,680 VPC set your engine and which subnet it 346 00:15:31,360 --> 00:15:35,880 goes in uh this would be quite a bit of 347 00:15:33,680 --> 00:15:38,839 a faf to do um if you're doing it 348 00:15:35,880 --> 00:15:40,920 through click Ops or through uh cloud 349 00:15:38,839 --> 00:15:44,639 formation or whatever but here it's 350 00:15:40,920 --> 00:15:47,279 super easy um but we don't want any of 351 00:15:44,639 --> 00:15:51,360 that we want it complicated um so here's 352 00:15:47,279 --> 00:15:54,720 a really simple way to spin up your own 353 00:15:51,360 --> 00:15:57,399 uh IDE uh postest service using a 354 00:15:54,720 --> 00:15:59,839 postrest container Trucking it in ec2 uh 355 00:15:57,399 --> 00:16:01,800 sorry ECS 356 00:15:59,839 --> 00:16:04,959 actually I'm surprised that actually 357 00:16:01,800 --> 00:16:07,839 fits on the uh on the slide let's dumb 358 00:16:04,959 --> 00:16:10,880 it down a bit okay um so all you do is 359 00:16:07,839 --> 00:16:14,360 add your e e EFS file system elastic 360 00:16:10,880 --> 00:16:16,759 file uh system uh add the file system to 361 00:16:14,360 --> 00:16:18,319 ECS volume add the volume to ECS task 362 00:16:16,759 --> 00:16:19,680 add the container to the task Mount the 363 00:16:18,319 --> 00:16:21,199 volume to The Container add the task to 364 00:16:19,680 --> 00:16:23,399 the service allow service to connect to 365 00:16:21,199 --> 00:16:27,079 EFS uh Mount the container service into 366 00:16:23,399 --> 00:16:29,360 Cloud Nam space and you're done 367 00:16:27,079 --> 00:16:32,279 simple let's compress it down a bit 368 00:16:29,360 --> 00:16:34,240 let's let's talk it through slightly um 369 00:16:32,279 --> 00:16:36,720 so what we're going to do uh first we 370 00:16:34,240 --> 00:16:39,319 need a persistent file system everything 371 00:16:36,720 --> 00:16:41,720 in ECS uh in the elastic container 372 00:16:39,319 --> 00:16:44,360 service generally is like stateless and 373 00:16:41,720 --> 00:16:47,839 you need to do special things to give 374 00:16:44,360 --> 00:16:50,560 some State um and of course AWS has a 375 00:16:47,839 --> 00:16:53,000 service or in many cases many services 376 00:16:50,560 --> 00:16:54,800 that will do this for you um on this 377 00:16:53,000 --> 00:16:57,560 occasion we're going to use uh the 378 00:16:54,800 --> 00:17:00,440 elastic file system uh which allows you 379 00:16:57,560 --> 00:17:02,720 to map basically a volume to a container 380 00:17:00,440 --> 00:17:05,319 if you're if you've worked in the 381 00:17:02,720 --> 00:17:08,319 container world if you've used Docker 382 00:17:05,319 --> 00:17:10,600 compose Docker um you you might be 383 00:17:08,319 --> 00:17:13,160 familiar with mounting persistent 384 00:17:10,600 --> 00:17:15,839 volumes to Containers that's just 385 00:17:13,160 --> 00:17:18,079 essentially what we're doing here um but 386 00:17:15,839 --> 00:17:22,959 of course because it's AWS we have to do 387 00:17:18,079 --> 00:17:25,720 it in a very um Vose fashion um so we've 388 00:17:22,959 --> 00:17:30,000 got our file system we create uh our 389 00:17:25,720 --> 00:17:31,799 persistent file system we attach it to 390 00:17:30,000 --> 00:17:33,400 an ECS 391 00:17:31,799 --> 00:17:36,520 volume 392 00:17:33,400 --> 00:17:39,520 um then we attach it to the task 393 00:17:36,520 --> 00:17:41,400 definition which is basically um the 394 00:17:39,520 --> 00:17:45,400 definition of how we're going to run our 395 00:17:41,400 --> 00:17:48,039 container um the task becomes a service 396 00:17:45,400 --> 00:17:51,120 um you attach the volume to the service 397 00:17:48,039 --> 00:17:53,120 uh and then you give permission um to 398 00:17:51,120 --> 00:17:55,520 the service to actually talk with the 399 00:17:53,120 --> 00:17:58,360 volume itself 400 00:17:55,520 --> 00:18:01,679 uh remember this just remember the 401 00:17:58,360 --> 00:18:04,080 pattern cuz it might pop up again soon 402 00:18:01,679 --> 00:18:07,080 um so there we go we've got our own 403 00:18:04,080 --> 00:18:10,240 postgress uh container running in 404 00:18:07,080 --> 00:18:13,000 ECS uh we're not paying for RDS anymore 405 00:18:10,240 --> 00:18:16,520 big big savings um because I think the 406 00:18:13,000 --> 00:18:19,440 lowest RDS instance is still quite 407 00:18:16,520 --> 00:18:22,320 expensive just to spin it up um I know 408 00:18:19,440 --> 00:18:24,480 there are like Aurora Services as well 409 00:18:22,320 --> 00:18:26,120 which are also very expensive but anyway 410 00:18:24,480 --> 00:18:29,280 if you're doing a relational database 411 00:18:26,120 --> 00:18:32,520 service in in uh AWS it's expensive as 412 00:18:29,280 --> 00:18:39,240 hell um but what we could also do is not 413 00:18:32,520 --> 00:18:44,559 use postgress at all um we could use SQL 414 00:18:39,240 --> 00:18:47,559 light uh which you know uh on a big big 415 00:18:44,559 --> 00:18:49,799 project I wouldn't recommend but on a 416 00:18:47,559 --> 00:18:52,080 small project like this we're only going 417 00:18:49,799 --> 00:18:56,000 to have like a couple of dozen users at 418 00:18:52,080 --> 00:18:59,640 most um SQL light's pretty good D Jango 419 00:18:56,000 --> 00:19:03,159 has excellent support for SQL light uh 420 00:18:59,640 --> 00:19:05,600 sqlite itself yeah you can you can get 421 00:19:03,159 --> 00:19:07,960 into trouble using it raw but Django 422 00:19:05,600 --> 00:19:12,080 gives you a lot of protections over it 423 00:19:07,960 --> 00:19:15,280 and generally in a small app um it's not 424 00:19:12,080 --> 00:19:20,200 too bad uh and it simplifies the stuck 425 00:19:15,280 --> 00:19:22,120 it gets rid of uh uh Network calls um 426 00:19:20,200 --> 00:19:25,480 how are we going to do 427 00:19:22,120 --> 00:19:27,240 this does this look familiar we had an 428 00:19:25,480 --> 00:19:29,520 EFS file system we had the file system 429 00:19:27,240 --> 00:19:31,000 to ECS volume we add the volume to the 430 00:19:29,520 --> 00:19:32,480 task we add the container to the task we 431 00:19:31,000 --> 00:19:34,039 Mount the volume we allow the service to 432 00:19:32,480 --> 00:19:37,559 connect to EFS and we Mount the 433 00:19:34,039 --> 00:19:41,120 container service into the cloud map Nam 434 00:19:37,559 --> 00:19:43,480 space simple and cheap we've just saved 435 00:19:41,120 --> 00:19:44,799 ourselves uh a bunch of money on uh 436 00:19:43,480 --> 00:19:48,520 another ECS 437 00:19:44,799 --> 00:19:50,600 service um some technical details here 438 00:19:48,520 --> 00:19:52,679 about uh where you mount the actual 439 00:19:50,600 --> 00:19:54,480 container um here we're just doing it to 440 00:19:52,679 --> 00:19:57,880 the temp path you can do whatever you 441 00:19:54,480 --> 00:20:00,159 want um but the you know the basic idea 442 00:19:57,880 --> 00:20:03,600 is there 443 00:20:00,159 --> 00:20:08,240 um and now we've kind of hit our limit 444 00:20:03,600 --> 00:20:10,200 of things we can do with a Jango uh app 445 00:20:08,240 --> 00:20:12,600 without actually doing anything to the 446 00:20:10,200 --> 00:20:15,000 Jango app we've we've done a bunch of 447 00:20:12,600 --> 00:20:18,280 stuff with services around let's cut to 448 00:20:15,000 --> 00:20:22,919 the Bone um let's get 449 00:20:18,280 --> 00:20:26,280 wild let's use Lambda um how do you run 450 00:20:22,919 --> 00:20:29,840 ajango service and a Lambda uh 451 00:20:26,280 --> 00:20:32,960 Service uh on this occasion I would very 452 00:20:29,840 --> 00:20:39,159 much suggest you use a Docker 453 00:20:32,960 --> 00:20:42,360 image um AWS has like python run times 454 00:20:39,159 --> 00:20:44,159 and they all suck um they're all really 455 00:20:42,360 --> 00:20:47,480 annoying to work with and it's just 456 00:20:44,159 --> 00:20:49,760 really hard to recreate what AWS is 457 00:20:47,480 --> 00:20:53,000 doing under the hood uh with their 458 00:20:49,760 --> 00:20:55,440 python run times so in general I suggest 459 00:20:53,000 --> 00:20:57,720 if you're going to do python in Lambda 460 00:20:55,440 --> 00:20:59,880 just Chuck it in a Docker function and 461 00:20:57,720 --> 00:21:02,760 then throw it over 462 00:20:59,880 --> 00:21:05,039 uh so this is how you do it um we use 463 00:21:02,760 --> 00:21:08,400 that same file system that we use for 464 00:21:05,039 --> 00:21:10,400 SQL light um you got to do some magic uh 465 00:21:08,400 --> 00:21:13,880 which is well documented out in the AWS 466 00:21:10,400 --> 00:21:15,080 docs about how you mount your volume to 467 00:21:13,880 --> 00:21:18,760 a Lambda 468 00:21:15,080 --> 00:21:22,000 function um we attach our docket image 469 00:21:18,760 --> 00:21:23,520 and then we do uh an API Gateway 470 00:21:22,000 --> 00:21:26,200 integration 471 00:21:23,520 --> 00:21:27,960 it's once again this will be all 472 00:21:26,200 --> 00:21:29,520 complicated in Click Ops but it's 473 00:21:27,960 --> 00:21:32,120 actually quite simple when you write it 474 00:21:29,520 --> 00:21:35,520 out in the uh in the 475 00:21:32,120 --> 00:21:38,640 code um a few problems though this will 476 00:21:35,520 --> 00:21:40,440 spin you up a nut Gateway very very 477 00:21:38,640 --> 00:21:43,799 sneaky 478 00:21:40,440 --> 00:21:47,240 um and lambdas don't work out of the box 479 00:21:43,799 --> 00:21:48,640 with a Jango uh application like this so 480 00:21:47,240 --> 00:21:50,559 we got we got to do a little bit of 481 00:21:48,640 --> 00:21:53,159 tweaking now within the actual uh 482 00:21:50,559 --> 00:21:56,799 application code to make it work turns 483 00:21:53,159 --> 00:21:59,880 out um AWS has built something to make 484 00:21:56,799 --> 00:22:02,080 that really really easy so there are a 485 00:21:59,880 --> 00:22:05,440 bunch of libraries that will do this 486 00:22:02,080 --> 00:22:09,360 translation of what a Lambda response 487 00:22:05,440 --> 00:22:11,559 does uh looks like into a HTTP response 488 00:22:09,360 --> 00:22:14,039 I think Mangum is one of them that's out 489 00:22:11,559 --> 00:22:15,480 there there's a bunch of others um but 490 00:22:14,039 --> 00:22:17,240 what I really don't want to do I don't 491 00:22:15,480 --> 00:22:19,880 want to mess with application code if I 492 00:22:17,240 --> 00:22:22,000 don't have to so we're going to use the 493 00:22:19,880 --> 00:22:24,400 advantage of the docker image and we're 494 00:22:22,000 --> 00:22:25,520 going to use this thing called aw AWS 495 00:22:24,400 --> 00:22:28,520 Lambda 496 00:22:25,520 --> 00:22:30,000 adapter um the Lambda web adapter and 497 00:22:28,520 --> 00:22:33,159 and basically what it does you just do 498 00:22:30,000 --> 00:22:38,960 this one line of coding from public 499 00:22:33,159 --> 00:22:41,640 ECR into this particular um directory in 500 00:22:38,960 --> 00:22:44,760 your container and then when you run it 501 00:22:41,640 --> 00:22:49,600 in Lambda you'll just get a HTTP request 502 00:22:44,760 --> 00:22:52,960 you can run uh gunicorn uvicorn whatever 503 00:22:49,600 --> 00:22:55,640 you whiskey whatever works for you um 504 00:22:52,960 --> 00:22:57,080 and it should just be plug andplay and 505 00:22:55,640 --> 00:22:59,400 the advantage of this is when you run it 506 00:22:57,080 --> 00:23:01,279 locally as well it just ignores that so 507 00:22:59,400 --> 00:23:03,960 you can just run python manage run 508 00:23:01,279 --> 00:23:07,120 server for your local um and then you 509 00:23:03,960 --> 00:23:09,440 run your G unicorn uh in production and 510 00:23:07,120 --> 00:23:11,880 you should be good to go uh links there 511 00:23:09,440 --> 00:23:13,120 links also in my blog post about it uh 512 00:23:11,880 --> 00:23:14,919 check it out it's pretty cool I haven't 513 00:23:13,120 --> 00:23:19,840 checked out checked it recently but it's 514 00:23:14,919 --> 00:23:22,240 in the AWS Labs uh GitHub um 515 00:23:19,840 --> 00:23:24,320 organization so it's still experimental 516 00:23:22,240 --> 00:23:26,640 but plenty of examples not just for 517 00:23:24,320 --> 00:23:29,039 python but for uh a bunch of different 518 00:23:26,640 --> 00:23:32,960 languages 519 00:23:29,039 --> 00:23:37,240 um okay there we go can we go deeper 520 00:23:32,960 --> 00:23:42,679 what can we do here what's cheaper than 521 00:23:37,240 --> 00:23:44,640 EFS S3 S3 the cheapest file system file 522 00:23:42,679 --> 00:23:48,559 system it's not really a file system but 523 00:23:44,640 --> 00:23:48,559 let's make it a file system 524 00:23:49,480 --> 00:23:55,880 um so I I built this little Library here 525 00:23:52,760 --> 00:23:58,880 um I will admit it's not original uh 526 00:23:55,880 --> 00:24:01,080 there was something like this in uh 527 00:23:58,880 --> 00:24:05,000 Zappa which was a library to help you 528 00:24:01,080 --> 00:24:08,840 deploy uh D Jango applications to um to 529 00:24:05,000 --> 00:24:12,080 AWS Lambda um essentially what it does 530 00:24:08,840 --> 00:24:14,679 is it just downloads a file from S3 531 00:24:12,080 --> 00:24:18,240 locally uh you do all your changes and 532 00:24:14,679 --> 00:24:21,600 then re-uploads it um so really safe you 533 00:24:18,240 --> 00:24:25,799 know your data is safe S3 is a 534 00:24:21,600 --> 00:24:29,120 really um really robust uh object 535 00:24:25,799 --> 00:24:32,080 storage uh 536 00:24:29,120 --> 00:24:34,720 don't do this for work once again as I 537 00:24:32,080 --> 00:24:37,320 say at the start um not employer 538 00:24:34,720 --> 00:24:41,279 approved we do not do this in production 539 00:24:37,320 --> 00:24:45,080 at all so uh don't try um so how do you 540 00:24:41,279 --> 00:24:48,279 do this okay uh we create an S3 bucket 541 00:24:45,080 --> 00:24:51,000 in uh in cdk super simple it's the 542 00:24:48,279 --> 00:24:54,159 canonical example create an S3 bucket 543 00:24:51,000 --> 00:24:57,520 whatever Library using super easy and 544 00:24:54,159 --> 00:24:59,320 then we just uh map it to uh our Lambda 545 00:24:57,520 --> 00:25:01,640 function here I'm using an environment 546 00:24:59,320 --> 00:25:03,240 variable do it however you want um 547 00:25:01,640 --> 00:25:05,559 specifically you do need to make sure 548 00:25:03,240 --> 00:25:07,480 that you map it to the sltm file when 549 00:25:05,559 --> 00:25:09,039 you're working in Docker when you're 550 00:25:07,480 --> 00:25:13,320 working in Lambda because that's the 551 00:25:09,039 --> 00:25:15,159 only writable um directory uh and then 552 00:25:13,320 --> 00:25:18,679 you got to do a slight bit of Jango 553 00:25:15,159 --> 00:25:20,960 settings so install D Jango SQL light 554 00:25:18,679 --> 00:25:23,600 object storage uh make sure it knows the 555 00:25:20,960 --> 00:25:27,840 bucket name and you should be good to 556 00:25:23,600 --> 00:25:32,039 go and given all this now we have our 557 00:25:27,840 --> 00:25:34,159 stack or that that big initial um stack 558 00:25:32,039 --> 00:25:35,600 has whittel down to something like this 559 00:25:34,159 --> 00:25:38,600 which is pretty small and gives you a 560 00:25:35,600 --> 00:25:39,960 pretty good amount of functionality um 561 00:25:38,600 --> 00:25:42,360 for ajango app that you're going to 562 00:25:39,960 --> 00:25:45,320 share amongst people you lose a few 563 00:25:42,360 --> 00:25:47,840 things um initial response cold starts 564 00:25:45,320 --> 00:25:51,120 pretty slow um but you know what that's 565 00:25:47,840 --> 00:25:53,440 something you can live with uh you can 566 00:25:51,120 --> 00:25:55,919 do this a bunch of times if nobody hits 567 00:25:53,440 --> 00:25:57,799 it at all you pay nothing which is 568 00:25:55,919 --> 00:25:58,880 absolutely great all these Services 569 00:25:57,799 --> 00:26:01,279 scale to 570 00:25:58,880 --> 00:26:03,480 zero um there are some opportunities 571 00:26:01,279 --> 00:26:05,600 that I haven't covered here uh so you 572 00:26:03,480 --> 00:26:09,799 could explore scheduling of spinning 573 00:26:05,600 --> 00:26:13,399 stuff up and down um AWS has uh event 574 00:26:09,799 --> 00:26:14,840 Bridge Schuler I think is the name um 575 00:26:13,399 --> 00:26:17,399 which is really robust and you can do 576 00:26:14,840 --> 00:26:20,760 all sorts of crazy things um also with 577 00:26:17,399 --> 00:26:24,080 cdk you can do crazy things with uh 578 00:26:20,760 --> 00:26:26,360 lambdas for internal uh Dev opsy type 579 00:26:24,080 --> 00:26:29,840 code it's really really useful for that 580 00:26:26,360 --> 00:26:32,799 I used it as a um bit of a DNS resolver 581 00:26:29,840 --> 00:26:34,679 for a little bit of uh time there I 582 00:26:32,799 --> 00:26:37,200 decided not to use a load balancer and I 583 00:26:34,679 --> 00:26:40,000 just mapped whatever the public IP 584 00:26:37,200 --> 00:26:43,919 address of the container was to uh the 585 00:26:40,000 --> 00:26:46,279 DNS uh uh which is not great I wouldn't 586 00:26:43,919 --> 00:26:48,240 do that in real life you know it's not 587 00:26:46,279 --> 00:26:52,039 happening anymore 588 00:26:48,240 --> 00:26:53,720 um uh you could perhaps use Lambda as a 589 00:26:52,039 --> 00:26:55,279 proxy to negate the need for natat 590 00:26:53,720 --> 00:26:57,679 gateways there is a weird way you could 591 00:26:55,279 --> 00:27:00,799 do that in some certain scenarios where 592 00:26:57,679 --> 00:27:03,039 you only hitting external like a 593 00:27:00,799 --> 00:27:05,480 specific external API and you can also 594 00:27:03,039 --> 00:27:07,000 use I don't know if I'm I'm going to 595 00:27:05,480 --> 00:27:10,000 pronounce this wrong 596 00:27:07,000 --> 00:27:13,000 fckn um to reduce natat costs as well 597 00:27:10,000 --> 00:27:15,279 there's like a cdk tutorial on how you 598 00:27:13,000 --> 00:27:16,520 can just easily add it so that your n 599 00:27:15,279 --> 00:27:19,000 costs go 600 00:27:16,520 --> 00:27:21,159 down but that's really where we're at 601 00:27:19,000 --> 00:27:23,000 we've run out of time and we've gotten 602 00:27:21,159 --> 00:27:25,440 to the point where you've built your app 603 00:27:23,000 --> 00:27:26,720 you shared it with your friends you 604 00:27:25,440 --> 00:27:29,120 haven't looked at it a while and you 605 00:27:26,720 --> 00:27:30,799 finally log into your AWS account you 606 00:27:29,120 --> 00:27:33,679 look at the logs and you see nobody's 607 00:27:30,799 --> 00:27:35,919 hitting it and you realize man I haven't 608 00:27:33,679 --> 00:27:38,000 used that app in a long while why is it 609 00:27:35,919 --> 00:27:43,080 even there anymore 610 00:27:38,000 --> 00:27:43,080 um let's just let's get rid of 611 00:27:43,200 --> 00:27:49,159 it and it's really really 612 00:27:46,039 --> 00:27:52,200 easy through cdk to just get rid of all 613 00:27:49,159 --> 00:27:55,679 those uh resources as well everybody's 614 00:27:52,200 --> 00:27:58,519 got that story of I've got that one cost 615 00:27:55,679 --> 00:28:00,960 that keeps coming up in my AWS bill it's 616 00:27:58,519 --> 00:28:04,519 like 30 cents I have an S3 bucket 617 00:28:00,960 --> 00:28:08,320 somewhere and I don't know where 618 00:28:04,519 --> 00:28:10,840 um cdk and uh cloud formation gives you 619 00:28:08,320 --> 00:28:13,880 a lot more um overview of all your 620 00:28:10,840 --> 00:28:16,200 resources and this is super super useful 621 00:28:13,880 --> 00:28:17,679 not just for when the Project's done but 622 00:28:16,200 --> 00:28:19,440 for when you're spinning up and you're 623 00:28:17,679 --> 00:28:22,600 just noodling around and figuring out 624 00:28:19,440 --> 00:28:26,480 what to do and how things fit 625 00:28:22,600 --> 00:28:28,880 together thus ends my talk uh there any 626 00:28:26,480 --> 00:28:32,760 I I think we have one one minute for 627 00:28:28,880 --> 00:28:32,760 questions any questions from the 628 00:28:33,080 --> 00:28:38,240 floor we got one up the back and then 629 00:28:35,480 --> 00:28:38,240 I'll come back for 630 00:28:38,760 --> 00:28:44,440 here I'll come to 631 00:28:42,200 --> 00:28:46,360 you oh thanks for the talk I was 632 00:28:44,440 --> 00:28:48,200 wondering um how much weigh you or are 633 00:28:46,360 --> 00:28:50,600 you paying for your personal app that 634 00:28:48,200 --> 00:28:52,279 you deployed using that cheap method uh 635 00:28:50,600 --> 00:28:55,360 well the the brilliant thing is that 636 00:28:52,279 --> 00:28:58,360 Lambda has a whole bunch of um uh stuff 637 00:28:55,360 --> 00:29:00,840 in the free tier and I'm paying zero 638 00:28:58,360 --> 00:29:03,960 well that's that's unfair I'm paying a 639 00:29:00,840 --> 00:29:06,519 couple cents for S3 costs I think but I 640 00:29:03,960 --> 00:29:10,120 I run a few stupid little apps through 641 00:29:06,519 --> 00:29:11,799 this method um and largely I don't know 642 00:29:10,120 --> 00:29:17,320 the bill comes in and it's like a couple 643 00:29:11,799 --> 00:29:18,840 of cents so um caveat though I will say 644 00:29:17,320 --> 00:29:21,880 if your app gets 645 00:29:18,840 --> 00:29:25,200 popular all this goes out the window all 646 00:29:21,880 --> 00:29:30,399 of it uh you will you will suffer the 647 00:29:25,200 --> 00:29:31,840 pain of um of those of those Services as 648 00:29:30,399 --> 00:29:35,000 I said before there's that inflection 649 00:29:31,840 --> 00:29:36,760 point at land is cheap until it's not if 650 00:29:35,000 --> 00:29:38,360 you start to get really popular that's 651 00:29:36,760 --> 00:29:40,320 when you have to start thinking about 652 00:29:38,360 --> 00:29:42,600 switching over to something like ECS and 653 00:29:40,320 --> 00:29:46,600 load balances and stuff where you you 654 00:29:42,600 --> 00:29:48,919 get uh the the cost of volume actually 655 00:29:46,600 --> 00:29:52,320 drives those prices down if that makes 656 00:29:48,919 --> 00:29:55,840 sense sorry one more question was there 657 00:29:52,320 --> 00:29:58,919 yes would you suggest using um like 658 00:29:55,840 --> 00:30:02,480 event Watchers for spooling up the uh 659 00:29:58,919 --> 00:30:06,679 ECS instance via Route 660 00:30:02,480 --> 00:30:08,640 53's logs it's really cheeky as as I 661 00:30:06,679 --> 00:30:10,559 mentioned before there are plenty of 662 00:30:08,640 --> 00:30:13,200 opportunities here with schedulers and 663 00:30:10,559 --> 00:30:17,039 events and stuff and because cdk makes 664 00:30:13,200 --> 00:30:19,519 it super easy to spin up um little uh 665 00:30:17,039 --> 00:30:22,000 utility Lambda functions yes there's 666 00:30:19,519 --> 00:30:24,399 probably an opportunity where you could 667 00:30:22,000 --> 00:30:26,760 spin it like spin everything down to 668 00:30:24,399 --> 00:30:29,440 zero and then when you get that request 669 00:30:26,760 --> 00:30:31,799 after some time out you know let's say 670 00:30:29,440 --> 00:30:34,799 someone uh you you spin everything down 671 00:30:31,799 --> 00:30:36,799 and someone finally hits it the next day 672 00:30:34,799 --> 00:30:39,279 you hold on to the request you spin 673 00:30:36,799 --> 00:30:41,519 everything up and then do the um you 674 00:30:39,279 --> 00:30:44,360 know do the request very much like what 675 00:30:41,519 --> 00:30:46,559 herok used to do on its free tier I 676 00:30:44,360 --> 00:30:48,760 don't know if I'm talking to the right 677 00:30:46,559 --> 00:30:52,799 crowd here but heroki used to spin down 678 00:30:48,760 --> 00:30:54,559 to zero if it had no traffic after I 679 00:30:52,799 --> 00:30:56,440 don't know x amount of hours and that 680 00:30:54,559 --> 00:30:58,559 was how it kind of made its free tier 681 00:30:56,440 --> 00:31:00,159 viable you could Poss possibly build 682 00:30:58,559 --> 00:31:01,720 something like that too that's that's 683 00:31:00,159 --> 00:31:03,720 definitely an option especially if 684 00:31:01,720 --> 00:31:06,080 Lambda is not good for you Lambda kind 685 00:31:03,720 --> 00:31:08,679 of sucks when it comes to you know 686 00:31:06,080 --> 00:31:11,120 longer running things and things where 687 00:31:08,679 --> 00:31:13,880 you want a file system and yada y so on 688 00:31:11,120 --> 00:31:16,960 and so forth but this is AWS the world 689 00:31:13,880 --> 00:31:18,919 is your like the Horizon opens out in 690 00:31:16,960 --> 00:31:21,279 front of you and you can do a lot of 691 00:31:18,919 --> 00:31:25,519 stupid 692 00:31:21,279 --> 00:31:29,919 things um that's that's time isn't it 693 00:31:25,519 --> 00:31:29,919 thank you all righty then thank you