1 00:00:00,350 --> 00:00:02,950 ‫So YAML is what we use 2 00:00:02,950 --> 00:00:05,480 ‫all across the US for many types. 3 00:00:05,480 --> 00:00:07,110 ‫Also for CloudFormation. 4 00:00:07,110 --> 00:00:09,680 ‫And so CloudFormation supports YAML and JSON. 5 00:00:09,680 --> 00:00:11,850 ‫And these are basically some scripting languages 6 00:00:11,850 --> 00:00:14,770 ‫or data languages that you can use for CloudFormation. 7 00:00:14,770 --> 00:00:17,200 ‫And to be honest, I'll be very, very honest with you, 8 00:00:17,200 --> 00:00:19,750 ‫JSON is absolutely absolutely horrible for CloudFormation. 9 00:00:19,750 --> 00:00:22,285 ‫It is unreadable, it is unwriteable. 10 00:00:22,285 --> 00:00:25,150 ‫And YAML is so great in so many ways, 11 00:00:25,150 --> 00:00:27,570 ‫and this is what the language will be used 12 00:00:27,570 --> 00:00:30,290 ‫at the exam to show you some CloudFormation templates 13 00:00:30,290 --> 00:00:32,560 ‫and this is what I've been using so far. 14 00:00:32,560 --> 00:00:33,880 ‫So let's learn a little bit about it. 15 00:00:33,880 --> 00:00:35,870 ‫Even though we've been touched with it so many times, 16 00:00:35,870 --> 00:00:38,920 ‫now is the time, I think, to formalize how is YAML. 17 00:00:38,920 --> 00:00:41,670 ‫And so this is a YAML file. 18 00:00:41,670 --> 00:00:46,150 ‫And so YAML file has a lot of key and values 19 00:00:46,150 --> 00:00:48,010 ‫and they're called key value pairs, 20 00:00:48,010 --> 00:00:51,610 ‫and to me, they're very readable objects. 21 00:00:51,610 --> 00:00:54,790 ‫Okay, on the left hand side, we can just look at it 22 00:00:54,790 --> 00:00:59,010 ‫and make sense if I asked you, what's the invoice number? 23 00:00:59,010 --> 00:01:00,280 ‫You don't need to be a genius to tell me 24 00:01:00,280 --> 00:01:04,690 ‫that the invoice number is 34843, and so this is great. 25 00:01:04,690 --> 00:01:07,950 ‫I tell you what is the date, you can also tell me the dates. 26 00:01:07,950 --> 00:01:10,881 ‫If I ask you, hey, what are the quantities 27 00:01:10,881 --> 00:01:12,930 ‫of the product we've ordered? 28 00:01:12,930 --> 00:01:15,140 ‫You can look at product and then you can look 29 00:01:15,140 --> 00:01:17,130 ‫within the product, there's a list of quantity 30 00:01:17,130 --> 00:01:18,840 ‫and we have four and one. 31 00:01:18,840 --> 00:01:20,310 ‫So you get the idea, right? 32 00:01:20,310 --> 00:01:22,670 ‫With YAML, we're able to have key value pairs 33 00:01:22,670 --> 00:01:25,340 ‫at top level, but also nested objects. 34 00:01:25,340 --> 00:01:29,330 ‫It has a support for arrays, so if we look at products, 35 00:01:29,330 --> 00:01:32,380 ‫you can see here that there's a little minus sign 36 00:01:32,380 --> 00:01:35,750 ‫and that means array, so the product is an array 37 00:01:35,750 --> 00:01:40,240 ‫of SKU, quantity, description, et cetera. 38 00:01:40,240 --> 00:01:44,060 ‫And then we can look at, for example, bill-to, 39 00:01:44,060 --> 00:01:46,390 ‫within it, there's a nested object called given 40 00:01:46,390 --> 00:01:49,610 ‫Chris, family, Dumars, and then the address 41 00:01:49,610 --> 00:01:52,330 ‫also has a nested object within it, 42 00:01:52,330 --> 00:01:55,280 ‫which is called lines, city, post state, and postal. 43 00:01:55,280 --> 00:01:58,020 ‫If we look at also lines, we can see that there 44 00:01:58,020 --> 00:02:00,270 ‫is a multiline string support, 45 00:02:00,270 --> 00:02:03,260 ‫so we have a small vertical bar right here, 46 00:02:03,260 --> 00:02:05,130 ‫and this is called a multiline string, 47 00:02:05,130 --> 00:02:08,280 ‫so we can easily add multiline string through YAML, 48 00:02:08,280 --> 00:02:10,040 ‫and we can also include comments, 49 00:02:10,040 --> 00:02:12,400 ‫although they're not showing on this page. 50 00:02:12,400 --> 00:02:17,070 ‫So YAML to me is a great way of reading and writing stuff. 51 00:02:17,070 --> 00:02:20,960 ‫Obviously some YAML files can be quite complicated, 52 00:02:20,960 --> 00:02:23,120 ‫but overall we get the idea. 53 00:02:23,120 --> 00:02:25,620 ‫If we have a look at the CloudFormation we had, 54 00:02:25,620 --> 00:02:27,650 ‫let's just look at a simple one. 55 00:02:27,650 --> 00:02:30,490 ‫We can see this one that we had a YAML file. 56 00:02:30,490 --> 00:02:32,600 ‫The first top level key was Resources, 57 00:02:32,600 --> 00:02:34,107 ‫then there is a second nested object within 58 00:02:34,107 --> 00:02:38,140 ‫called MyInstance, which has more nested stuff within it, 59 00:02:38,140 --> 00:02:39,730 ‫such as Type and Properties, 60 00:02:39,730 --> 00:02:43,800 ‫and Properties was again nested as key value pairs. 61 00:02:43,800 --> 00:02:46,620 ‫If we look at the other one, we can see we had 62 00:02:46,620 --> 00:02:49,550 ‫the Parameters top level, the Resources top level, 63 00:02:49,550 --> 00:02:52,330 ‫more nested stuff, and if we look at SecurityGroups, 64 00:02:52,330 --> 00:02:54,460 ‫because there's a little minus sign right here, 65 00:02:54,460 --> 00:02:57,770 ‫it was a list, so we have a list of SecurityGroups 66 00:02:57,770 --> 00:02:59,300 ‫that we've defined right here. 67 00:02:59,300 --> 00:03:02,130 ‫The first SecurityGroup and the second SecurityGroup. 68 00:03:02,130 --> 00:03:03,410 ‫So we can navigate through this, 69 00:03:03,410 --> 00:03:06,130 ‫and really understand that it looks like 70 00:03:06,130 --> 00:03:08,890 ‫we can read this YAML template, 71 00:03:08,890 --> 00:03:11,900 ‫just using the small concepts we learned from before. 72 00:03:11,900 --> 00:03:13,680 ‫I encourage you to go online and learn 73 00:03:13,680 --> 00:03:14,730 ‫a little bit more about YAML, 74 00:03:14,730 --> 00:03:18,260 ‫and even practice converting JSON documents to YAML. 75 00:03:18,260 --> 00:03:20,730 ‫But overall, it is something that I think is quite easy 76 00:03:20,730 --> 00:03:23,160 ‫to read, and what you really should understand 77 00:03:23,160 --> 00:03:26,060 ‫is that you can nest objects separated by column. 78 00:03:26,060 --> 00:03:27,520 ‫You get the key and the value, 79 00:03:27,520 --> 00:03:31,770 ‫and using the minus sign, you get to assign a list. 80 00:03:31,770 --> 00:03:32,900 ‫So that's it for YAML. 81 00:03:32,900 --> 00:03:34,910 ‫I hope this makes more sense to you now, 82 00:03:34,910 --> 00:03:36,860 ‫and I will see you in the next lecture.