Now that we've created our VPC architecture we can now look at 1
deploying our ec2 instances into that VPC, so the first thing we need to do 2
before we create an ec2 instance is that we need to create a security group for 3
that instance so what we do is again we go to the ec2 section we scroll down to 4
the security group and we drop that on to the VPC we don't drop that onto the 5
public subnet drop it onto the VPC okay we'll rename that again so we click on 6
components and I'm just going to rename there any in backspace ec2 SG will be 7
fine for us and we'll update our designer so now our security group has a 8
number of the dots that the the all of these icons have has depends on but the 9
one that we're interested in now is in the bottom right hand side here we've 10
got VPC ID so if we click on that we can see the VPC is seen highlighted and 11
we just go through and drop that onto the VPC and that will make sure that 12
our VPC ID is referenced in that security group so we also need to add 13
some more properties in there so I've just copied those over from the lab 14
notes and paste those in there okay so what we need to make sure is 15
that when we paste it in that the indenting lines up with this here so it 16
indents from properties and it will be in line with VPC id, it'll be like that 17
and then when we go into our security ingress rule that will be indented again 18
with IP protocol and then the from to port and side a block will then be 19
indented again and then we go back and so that is a TCP port 80 connection for 20
for everything and then we have our port 20 to ssh traffic 21
therefore IP protocol TCP so that is our security group ingress rules that have 22
been defined them so again we click on it refresh and that will update that for us 23
okay so now that we've done that we can now look at saving it again as a 24
different version so we'll save that local file and we'll call this one too 25
so again we go into our cloud formation console we leave it we've already saved 26
that that's fine and again we go through and we'll select our stack and we'll 27
update our stack choose our file again 28
and next and next next and update ok so that update has completed fine it's it's 29
created the security group not a problem there ok so let's go back into designer 30
so click on design template will load that back in again 31
okay just zoom in a bit okay so I'll just minimize the editor now now that 32
we've got our security grid created we now can go ahead and put our ec2 33
instance in there so again we see two and drag an instance across into here 34
again we'll rename that instance so we click on components and we'll rename 35
that so we're just call a back space ec2 I that will be fine 36
refresh our designer, Okay I'll just minimize the editor so that we can see 37
it a little bit better so again we've got a lot of different stuff here but 38
what we're interested in is that depends on so it depends we can't create this 39
ec2 instance until our route to the Internet is there available otherwise 40
it's just not going to be able to connect so has no point launching an ec2 41
instance until that is ready to go so we put our depends on so the pink dot there 42
and we drag that over to our public route okay so now that we've got that 43
instance icon on there we need to actually define you know what what ami 44
is instance using we need to define also what size that instance is so we can 45
start off by putting that into the property so we click on that we'll just 46
max or split screen to get the editor up click on components to bring that up and 47
we can see that we've got our subnet ID reference that's fine so what we need to 48
do is to go into properties and just before network interfaces and press 49
enter and we're going to copy over the the details of that instance so just 50
copy that over from the lab notes 51
okay so make sure that it looks like that so you have properties and then you 52
have an indent of two spaces then your image ID and then the instance type and 53
then lining up again will be the network interfaces after that so again we 54
refresh our designer so now that we've got our our image ID which is a 55
wordpress image in our instance type we need to give information about the a 56
network interface side of things so again we'll copy that over from the lab 57
notes and we'll paste that in to where the current network interfaces section 58
is delete that one and we'll paste the new one in okay so I'm just going to 59
maximize this and we can see it a little bit better so there we go so we've got 60
our image ID which is a wordpress AMI we've got our t2 micro and then in the 61
networking section we've got our group set set which is our back space ec2 62
security group which is associated with this instance we wanted to associate a 63
public IP address when it launches it's going to be a webserver it needs a 64
public IP address we have a device index air and delete on termination being true 65
so when we terminate it we want it to go and we have a subnet ID there which is 66
defined it's going into our public subnet so we'll just go back to split 67
screen and we'll refresh our designer 68
okay so now that we've done that we can look at now deploying our doing our 69
final update which will deploy our WordPress server to this VPC 70
architecture so again we save our current template to a local file we'll 71
save that and we're going to give it the name backspace three 72
and we'll save that one there when that's finished saving we go again into 73
the cloud formation console we click on that stack and we update that stack 74
we'll choose our new file upload that click on next and next and next and 75
we'll update that stack so the update is near in progress after short them at a 76
time it will be ready to go and we can start to have a look at our web server 77
in action okay so our update has been completed so our architecture has been 78
created and our ec2 instance has been created and a route through to the 79
Internet has been created so we should be able to now point our web server 80
you're sorry should be able to point our browser to this WordPress web server and 81
we should get a web page so let's go to the ec2 console and then we can see we 82
got one running instance seeing okay so there's our instance and it's still 83
going through doing it status checks so we just wait for it to finish that okay 84
so our status checks have completed so we should now be able to or very shortly 85
be able to access our web server so we just go and get the public IP address 86
and we'll go to that so just go to that and there you can see we have our 87
WordPress server up and running so that's a pretty cool thing so this has 88
been a very very long lab but I'm sure you can appreciate that this is a great 89
way to really learn about VPC you're going to understand what is required for 90
internet access you're going to understand exactly if any of this stuff 91
is missing it's not going to I'm sure you've learned a lot about 92
cloud formation as well and how how to launch a stack and how to fix a stack if 93
there are problems with it so that brings us to the end all we need to do 94
now is to clean this up so what we do is we just close out of here we don't go 95
anywhere near the ec2 management console leave that alone if you delete it from 96
here it's going to create problems when you go to delete the slacks and don't 97
touch anything here go back into cloud formation and delete the stack from 98
there first so just select it actions and delete stack so when you delete a 99
stack it will delete every resource that was created so it's going to delete that 100
entire VPC that we've created it's going to delete the security groups 101
around tables it's going to delete finally delete that instance as well so 102
we cook on yes delete that delete will be happening okay so after a certain 103
amount of time you're going to see that stack deleted and all of the resources 104
that were created by that stack will also be deleted now this is a very big 105
lab quite a complex lab I've created almost 30 pages of lab notes and make 106
sure you download those it's taken about a week of full time to get this lab up 107
and running and I hope you appreciate it because it's going to really be a really 108
good lab for you to learn and fully understand VPC so make sure you download 109
those lab dates go through them very carefully take your time and you'll get 110
there in the end and I'll look forward to seeing you in the next lecture