1 00:00:00,251 --> 00:00:01,600 ‫Finally, we are going to talk about 2 00:00:01,600 --> 00:00:02,660 ‫the conditions. 3 00:00:02,660 --> 00:00:05,021 ‫So conditions are used to control the creation 4 00:00:05,021 --> 00:00:08,672 ‫of resources, or outputs based on some statements. 5 00:00:08,672 --> 00:00:09,910 ‫Logical statements. 6 00:00:09,910 --> 00:00:11,632 ‫The conditions can be whatever you want them to be, 7 00:00:11,632 --> 00:00:14,552 ‫but the common ones are that, maybe you want to say, 8 00:00:14,552 --> 00:00:16,331 ‫if you're in dev, or if you're in test, 9 00:00:16,331 --> 00:00:20,632 ‫or if you're in prod create or don't create that resource. 10 00:00:20,632 --> 00:00:22,051 ‫Maybe it can be based on the region, 11 00:00:22,051 --> 00:00:23,840 ‫maybe based on the parameter value. 12 00:00:23,840 --> 00:00:26,579 ‫Each condition can reference another condition, 13 00:00:26,579 --> 00:00:29,171 ‫parameter value or mapping, so you can compose them. 14 00:00:29,171 --> 00:00:31,592 ‫So to define them, to make it a little more concrete, 15 00:00:31,592 --> 00:00:33,992 ‫here is a condition that I've created 16 00:00:33,992 --> 00:00:36,242 ‫under the block conditions. 17 00:00:37,110 --> 00:00:39,822 ‫Here we say, okay, do we want to create 18 00:00:39,822 --> 00:00:41,542 ‫the production resources? 19 00:00:41,542 --> 00:00:44,319 ‫For this, you need to have the environment type, 20 00:00:44,319 --> 00:00:45,710 ‫and that may be a parameter. 21 00:00:45,710 --> 00:00:47,550 ‫This environment type right here. 22 00:00:47,550 --> 00:00:49,062 ‫We need to have the reference, 23 00:00:49,062 --> 00:00:54,062 ‫so the value of this paramater to be equal to prod, 24 00:00:54,091 --> 00:00:56,339 ‫P-R-O-D, the string prod. 25 00:00:56,339 --> 00:00:59,980 ‫So here, basically, this whole thing is going to be true, 26 00:00:59,980 --> 00:01:04,030 ‫only if the environment is equal to prod. 27 00:01:04,030 --> 00:01:08,251 ‫Using this prod resources we are able to, 28 00:01:08,251 --> 00:01:11,223 ‫basically define and condition other resources. 29 00:01:11,223 --> 00:01:13,561 ‫It's up to you how you wanna chose it, 30 00:01:13,561 --> 00:01:15,423 ‫all the functions you can use in there are going to be 31 00:01:15,423 --> 00:01:17,756 ‫And, Equals, If, Not or, Or. 32 00:01:18,667 --> 00:01:20,528 ‫These are logical functions, 33 00:01:20,528 --> 00:01:22,926 ‫and you can compose them as much as you want. 34 00:01:22,926 --> 00:01:24,567 ‫Now how do we use a condition? 35 00:01:24,567 --> 00:01:25,661 ‫Well you can apply it, as I said, 36 00:01:25,661 --> 00:01:27,828 ‫to resources, outputs etc. 37 00:01:28,751 --> 00:01:30,326 ‫If we look at a resource, for example, 38 00:01:30,326 --> 00:01:33,345 ‫my MountPoint, the type of it is a 39 00:01:33,345 --> 00:01:36,145 ‫AWS EC2 VolumeAttachment, 40 00:01:36,145 --> 00:01:39,577 ‫and this only gets created if the condition 41 00:01:39,577 --> 00:01:43,415 ‫CreateProdResources from before is true. 42 00:01:43,415 --> 00:01:46,436 ‫That gives you an idea of how conditions are used, 43 00:01:46,436 --> 00:01:49,217 ‫basically they're on the same level as the type, 44 00:01:49,217 --> 00:01:52,756 ‫right here underneath the name of the Resource. 45 00:01:52,756 --> 00:01:54,126 ‫So that's it for conditions, 46 00:01:54,126 --> 00:01:55,697 ‫I think they're pretty much advanced, 47 00:01:55,697 --> 00:01:57,028 ‫I'm not sure they're asked at the exam, 48 00:01:57,028 --> 00:01:58,836 ‫but for you it's still good to know about them, 49 00:01:58,836 --> 00:02:00,446 ‫that they exist, and you can have some 50 00:02:00,446 --> 00:02:03,595 ‫little bit more logic in your classroom mission templates. 51 00:02:03,595 --> 00:02:04,596 ‫I hope that was helpful, 52 00:02:04,596 --> 00:02:06,575 ‫and I will see you in the next lecture.