Welcome back to BackSpace Academy! In this practical lab on VPC 1
architecture design and deployment with cloud formation designer I'm going to 2
introduce you to the AWS cloud formation designer and this is a great tool to 3
really understand VPC because you're going to get to use this graphical user 4
interface to design and architecture on the screen and then see that go from a 5
design on the screen through to a cloud formation template and then that cloud 6
formation template can then be used to deploy our architecture and the and its 7
associated resources to AWS and this is a great tool because it integrates 8
really well with our existing version control systems and creates a great all 9
the way through version control of our architecture designed from a user 10
interface and a visual perspective right through to the nuts and bolts of a cloud 11
formation template so let's get into it okay so starting off we need to go to 12
the cloud formation console so against services cloud formation once we get 13
there we need to click on design a template that will take us straight into 14
the cloud formation and designer so that consists of three pane so on the left 15
hand side here we've got the resources types which will list obviously the 16
different resources that are available to be used in our template in the center 17
here we've got a canvas and that is where we drag and drop our our resources 18
onto this canvas and we can join that up and Link it up and and that will be used 19
to design our architecture and from there 20
it will create automatically a cloud formation template for us and we can 21
edit that cloud formation template in the editor pane down below there so we 22
can see here we've got components of our cloud formation template that will be 23
the parameters the mappings our conditions 24
metadata and outputs as we would have in our cloud formation template we can also 25
see our cloud formation template here as well 26
it's an empty template right now it's just saying the the format version and 27
nothing else we can also see that in either JSON or YAML so I'm going to 28
select the YAML here simply business a lot easier to read I'll just 29
go back to components here now the first thing we'll do is we're going to give 30
this template a name so we can see here it's called new template we're going to 31
change that and we're just going to call a backspace and we'll say that okay so 32
all of the resources that we're going to be using will be located in the ec2 33
section so we just scroll down till we get to ec2 and expand that and the first 34
thing we're going to start with will be we're going to start with a VPC so 35
scroll down to VPC and we'll drag that on to the canvas there you can see it's 36
given it a name ec2 VPC blah blah blah, we want to give it a more understandable 37
name so we just get rid of the stuff at the end in and we'll just call it 38
backspace, so backspace ec2 VPC and we'll save that now because we've done 39
that the canvas needs to be updated so what we do is on the top right-hand side 40
here we could click on the Refresh diagram button and that will update it 41
and there we can see that our VPC is now got a name backspace EC2 VPC 42
now in our editor pane we're just going to minimize that so on the right hand 43
side there we're going to minimize that and give the canvas full screen and 44
we're going to expand that canvas there so it gives a lot more room for the VPC 45
and then we'll just go back to the split screen select that down the bottom right 46
hand side there and bring that back up again so now that we've created that VPC 47
we need to give it some properties and the the one property that it 48
definitely needs is a CIDR block range so what I'm going to do is I'm just 49
going to jump back into the lab notes and going to copy over here 50
the properties that we need so we need to have a CIDR defined and we 51
also need need to enable DNS for this fee PC so what we do is we go back in 52
here and we just get into the properties get rid of those brackets and press 53
Enter, home and control V to put it in there 54
what we need to do is we need to tab twice, so just tab twice there and that will 55
be accepted, if you don't do that then it'll be a bit of a mess, so make sure 56
that it's indented from properties when you do that, so again the designer is now 57
out of date so we can hit refresh and there we go so if we go into our 58
template and have a look at that we can see there if we just maximize that we 59
can see there that it is got a resource in it's our backspace ec2 VPC, it's a 60
type ec2 VPC and we have properties there with a CIDR block and 61
enableDNS and enable DNS host names in there as well, so now what we'll do is we'll, 62
I'll just put back into the split screen view, what we can do now is we can 63
actually add a subnet to our VPC, so we just drag across 64
same as before and we drag a subnet across to our VPC and just drop that on 65
there and again, we'll rename it to something that is understandable and 66
we're just going to call this one public subnet, click on save and refresh the 67
designer again, I'm just going to minimize the editor and make that fill 68
that quite a bit there, just leave a little bit of room in the VPC for other 69
stuff to come along and that's fine, so what we need to do now is that we need 70
to go back into the editor, so again it's back to split screen and we need to add 71
some properties for that, so we can see here it's already added properties 72
for the VPC ID and then because we dragged and dropped that 73
subnet into the VPC so it's automatically created a reference to 74
that that backspace ec2 VPC so I'm just going to jump back into the lab notes 75
and I'm going to copy over what we need for that that properties section okay so 76
we go there it's we've got a CIDR block again it's /24 our VPC was 77
/16 and we're going to as normal we'll put it into u.s. east, so we just 78
do enter and control V and we'll just make sure that everything is indented 79
properly, so you just tab and then you just put in a couple of spaces in there, 80
so we can see we've got our properties VPC ID we had our CIDR block and we had 81
our availability zone, if you're not sure exactly what should be in 82
there you can just go into the cloud formation developer notes and AWS 83
developer manual and you can search for AWS EC2 subnet and it'll tell you 84
exactly what you need to put in for cloud formation to accept it. If you 85
leave off CIDR block it then your template will fail when when you go to 86
run it because it needs a CIDR block it also needs an availability zone as well 87
so that stuff needs to go in there and we just refresh the screen, so now that 88
we've created a VPC we've created a subnet and some other stuff and 89
added the property to that, it's a good idea to save our template, and then also 90
deploy our template at the same time to make sure there's no errors, it's not a 91
good idea to go through and do your whole architecture and then run it at 92
the end because you might have a bit of a mess, so it's good to do it piece by 93
piece, so what we're going to do now is we're going to go into the file menu up 94
the top left hand side here and we're going to select save we're going to save 95
it as a local file, we just use backspace a template that will be fine and I'm 96
just gonna save it in there and the beauty of this is that that is 97
actually a text file, so we want to have a look at it we can so I just open that 98
up find something to view it in notepad will be fine, okay so you can see there 99
that it is basically nothing more than a text file so we can use this quite 100
easily in our version control system and and we can also at the same time if we 101
wanted to we can download that as an image and so we can download as a PNG 102
image if we want as well so this is really good if we want to put that into 103
reports or whatever for management I want to see exactly what's going on we 104
can do that, so it's a good tool it's a good tool from go to whoa, through from 105
design through the deployment, so let's have a look at now deploying this 106
template so we need to go back into cloud formation we'll leave that we've 107
already saved it's not a problem and what we need to do now is that we need 108
to create a stack and we're going to choose a file so we just click on choose 109
file we'll select our backspace template next and we'll give it a go our name 110
backspace and next we won't worry about any tags or any rollback triggers or 111
anything like that let's create that stack so what will happen is that it 112
will start to create that and what we can do is we we can actually see what's 113
going on with it as it goes along we'll just expand it up 114
we'll click on refresh so it's currently creating that VPC 115
we finished creating the VPC, it's now 116
creating that subnet, we'll click on refresh again, ok so there we can see 117
that it has completed that creating that subnet and so the cloud formation stack 118
has been completed if there is any problem then it would say a rollback is 119
in progress and it would tell you exactly the reason why there is a 120
problem for example if you didn't have a cider block on your VPC or your subnet 121
and you can actually do that if you want just have a bit of a play around with it 122
let's see what happens and that will fail and I'll tell you that that you 123
need to have a CIDR block on your VPC. Just going back into that split screen 124
we can see create complete there