1 00:00:11,259 --> 00:00:16,599 Welcome back to BackSpace Academy. Now from our introduction to AWS we should 2 00:00:16,599 --> 00:00:21,009 already know that cloudformation uses text files that we create called 3 00:00:21,009 --> 00:00:27,429 templates and it interprets those to deploy resources across the AWS cloud 4 00:00:27,429 --> 00:00:30,160 we're going to have a look at what one of these templates looks like the 5 00:00:30,160 --> 00:00:34,690 structure and the sections of them, then we'll look at the stacksets service 6 00:00:34,690 --> 00:00:39,309 which allows you to use a cloudformation template to launch across 7 00:00:39,309 --> 00:00:44,649 multiple AWS accounts which is great if you're a large organization. We'll look at 8 00:00:44,649 --> 00:00:49,660 the cloudformer tool which can look at your existing infrastructure and create 9 00:00:49,660 --> 00:00:55,809 a template from that which can then be used to create a replica of that infrastructure 10 00:00:55,809 --> 00:01:00,699 and finally we'll look at the cloudformation designer which is a 11 00:01:00,699 --> 00:01:07,149 graphical user interface to the cloudformation service. A cloudformation 12 00:01:07,149 --> 00:01:14,380 template allows you to define in a text file exactly what your deployment looks 13 00:01:14,380 --> 00:01:20,200 like and the configuration of it and because it's a text file you can manage 14 00:01:20,200 --> 00:01:25,000 it in the same way that you would manage code and you would use version control 15 00:01:25,000 --> 00:01:31,509 in the same way so you could use git subversion or Microsoft sourcesafe to 16 00:01:31,509 --> 00:01:37,390 manage the version control of that text file. Now those files are in either JSON 17 00:01:37,390 --> 00:01:42,759 or JavaScript object notation or YAML which stands for yet another markup 18 00:01:42,759 --> 00:01:48,700 language and that template describes all of the AWS resources that you need to 19 00:01:48,700 --> 00:01:53,770 deploy and then cloudformation will interpret that text file and will take 20 00:01:53,770 --> 00:01:59,729 care of the provisioning and configuring of that infrastructure 21 00:01:59,729 --> 00:02:03,869 so this is what a cloudformation template structure looks like 22 00:02:03,869 --> 00:02:09,539 so with JSON you can see the individual objects of that template are separated 23 00:02:09,539 --> 00:02:14,790 by brackets and commas now YAML is similar to if you have ever 24 00:02:14,790 --> 00:02:19,140 coded in CoffeeScript or if you've done development with Pug or anything like that 25 00:02:19,140 --> 00:02:24,989 the brackets and the commas are replaced by indentations and so what 26 00:02:24,989 --> 00:02:29,760 that means is that you get really concise and neat code and as you can see 27 00:02:29,760 --> 00:02:35,280 there the JSON on the Left looks a lot messier than the YAML on the right so 28 00:02:35,280 --> 00:02:40,140 I'd encourage you to use YAML and in the exam if you have a question on cloud 29 00:02:40,140 --> 00:02:44,670 formation and they supply a template they normally provide both a JSON and 30 00:02:44,670 --> 00:02:50,400 the YAML so don't be too concerned about which one you selected the first section 31 00:02:50,400 --> 00:02:56,100 of a template will be the format version and that will be the version of the 32 00:02:56,100 --> 00:03:02,370 cloudformation interpreter that the template conforms to next we'll have a 33 00:03:02,370 --> 00:03:07,590 description and that will always follow the format version then we could have 34 00:03:07,590 --> 00:03:12,840 metadata which will be JSON objects or keys that can be put in there in that 35 00:03:12,840 --> 00:03:17,940 template to provide additional info we have parameters and that allows you to 36 00:03:17,940 --> 00:03:23,579 pass information to the cloudformation service when the stack is being deployed 37 00:03:23,579 --> 00:03:27,989 for example you might want to get information from the end user when 38 00:03:27,989 --> 00:03:32,040 they're deploying this stack of what size of the instance for example that 39 00:03:32,040 --> 00:03:37,260 they would like to deploy with and we have mappings and they match keys to 40 00:03:37,260 --> 00:03:42,150 corresponding name value pairs for example you might want to match a 41 00:03:42,150 --> 00:03:48,810 specific ami to a region so if your end user selects a certain region as a 42 00:03:48,810 --> 00:03:56,040 parameter then we could map that parameter to a specific ami for that 43 00:03:56,040 --> 00:04:01,889 region transforms are used for two purposes first of all they can be used 44 00:04:01,889 --> 00:04:07,440 for defining the service application model to use if you're going to be doing 45 00:04:07,440 --> 00:04:12,330 a service architecture or they can be used to include 46 00:04:12,330 --> 00:04:17,760 template snippets from cloudformation to include in your cloudformation 47 00:04:17,760 --> 00:04:22,290 template we also have the output section and that would declare output values 48 00:04:22,290 --> 00:04:26,550 that can be put out to the screen to the person that is deploying the stack or 49 00:04:26,550 --> 00:04:32,880 they could actually be outputs to another cloudformation template and the 50 00:04:32,880 --> 00:04:39,390 resources section is the only compulsory section of a template so you must have 51 00:04:39,390 --> 00:04:43,860 the resources section and that simply just declares the resources that you're 52 00:04:43,860 --> 00:04:49,770 going to be deploying and finally we've got conditions and we can use those to 53 00:04:49,770 --> 00:04:55,050 control when a resource can be created or a property defined so we've under 54 00:04:55,050 --> 00:05:01,010 certain conditions we don't want that to occur we can put that in as a condition 55 00:05:01,010 --> 00:05:07,950 cloudformation as stack sets allows you to create stacks across regions and even 56 00:05:07,950 --> 00:05:13,350 across multiple accounts so that is great if you're a large enterprise and 57 00:05:13,350 --> 00:05:17,250 you've got organizations across the globe and they've all got individual 58 00:05:17,250 --> 00:05:21,720 accounts or you might have departments with individual AWS accounts so that's 59 00:05:21,720 --> 00:05:25,980 great for that situation where you would have a one controlling administrator 60 00:05:25,980 --> 00:05:31,740 account that would have a stack set and that could be deployed across all of 61 00:05:31,740 --> 00:05:38,820 your infrastructure company-wide cloud former is an application that 62 00:05:38,820 --> 00:05:45,180 runs on an ec2 instance and you deploy the application using cloudformation 63 00:05:45,180 --> 00:05:49,650 When that application has been deployed the application that's running on that 64 00:05:49,650 --> 00:05:55,380 ec2 instance will look at all of your infrastructure in your account and it 65 00:05:55,380 --> 00:06:00,180 will compile that for you and then you can select those resources that are 66 00:06:00,180 --> 00:06:04,740 deployed and it will put them automatically into a cloudformation 67 00:06:04,740 --> 00:06:09,600 template for you. So that's great because you can have any existing infrastructure 68 00:06:09,600 --> 00:06:14,490 and you don't want to go to the work of having to create a cloudformation 69 00:06:14,490 --> 00:06:23,010 template the cloud format all can do it all for you and finally we've got the 70 00:06:23,010 --> 00:06:28,110 cloudformation designer now that's a great tool and maybe going on to do the 71 00:06:28,110 --> 00:06:33,150 associate level course we'll get to use this quite a bit and what it does it's a 72 00:06:33,150 --> 00:06:39,360 visual drag-and-drop interface for creating cloudformation templates it'll 73 00:06:39,360 --> 00:06:44,760 automatically produce that JSON or Yama file for you which is really good 74 00:06:44,760 --> 00:06:50,669 because you're going from an architecture design diagram and in 75 00:06:50,669 --> 00:06:55,140 getting that directly to a template which is a great workflow to you so I 76 00:06:55,140 --> 00:07:00,390 thoroughly encourage that you get to learn cloudformation designer it takes 77 00:07:00,390 --> 00:07:05,610 a lot of time to get used to but I think it's worth the effort so that brings us 78 00:07:05,610 --> 00:07:09,270 to the end of the cloudformation lecture I hope you've enjoyed it and 79 00:07:09,270 --> 00:07:12,590 I'll see you in the next one