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