so let's start by creating an OPS works stack and launching an application on 2
top of that so when you first start you get this sale welcome to AWS opsworks 3
screen so we can launch a sample stack is so it's going to go here add your 4
first stack okay so it's going to use the sample stack so sample stack here we're 5
not going to do our own cookbooks or anything like that so just select Linux 6
and create the stack so that will go through create the stack it will set up 7
the cookbook and the recipes in that responsible repository and it will 8
create the layer and and instance to that layer so that's all done very 9
quickly very quickly so there we go so we've now made this slack the stack it's 10
got a node app server on there as a layer get a little message here saying 11
we can start the instance so once we start the instance we can actually start 12
to what once it's running we can deploy our application to that so I just click 13
on got it so we'll just have a look is so we've got our instance here so there 14
is one instance but it's stopped we have a layer and we have an application there 15
so I'm just going to have a look at this application first so this is the 16
application that's going to be running on the infrastructure that we have 17
defined using a chef recipe and you can see here it's pulling it in from a 18
github repository. So if I just go have a look at that github repository 19
and have a look and see what's in there ok so that looks just like any 20
ordinary nodejs application so just have a look in here so there we go so 21
require Express so it's an Express node.js application that developers 22
would certainly recognize so that is the application node.js application that is 23
going to be launched on this infrastructure so we'll just go back to 24
our stack and I'm going to start up these instances so 25
or the single instance here so it's currently stopped and we'll start that 26
and that will go through and do its usual boot up and health checks and 27
whatever that a ec2 instance does it take some time so while that's running a 28
right run around or something per stack again so what we can have a look at is 29
the layers so here's our layer which has got one instance inside it it has 30
recipes there it has some EBS volumes So lets have a look at the recipes so there we can see 31
so there's a nodejs demo recipe that is used for deployment and that is located 32
in an Amazon s3 bucket there so that is a code that defines our infrastructure 33
so when we talk about infrastructure as a code this is what we're talking about 34
so we have we have code they're located in a repository and that defines our 35
infrastructure we also have code for our actual application that we're going to 36
run on this app server okay so there are two repositories there one for our our 37
infrastructure as code and the other one for our actual application that we're 38
going to run on ad destruction okay so we've just fast forward it took a little 39
bit of time to to do that but it's finally finished 40
so we have our instance up and running there so we can see it's being assigned 41
a public IP and if we go to that public IP it won't really do anything as 42
there is no application running on it so let's go back to apps and there is our 43
nodejs sample app that was located in that github repository so we're going to 44
deploy that to that infrastructure okay this is selling here our ops works 45
we'll run this command on one of one instances so we deploy that so that 46
should be running now and what I'm going to do is go back to that instance I'm 47
going to go to this public IP and see what see 48
and there we go so opsworks has created the infrastructure that we require it's 49
used a chef recipe to do that a chef recipe has defined all of the 50
infrastructure as code it has deployed all of that infrastructure and then 51
subsequently it has deployed our nodejs application from a github repository so 52
there you can see that is the the application that within that github 53
repository that's been launched on a node.js server so pretty good so a lot 54
more powerful than elastic Beanstalk or or ec2 container service and certainly 55
if you're going to be looking at really advanced this is probably the high end 56
of the deployment options on AWS okay so so that we don't actually get a nasty 57
bill at the end of the month for all these services that we're not going to 58
be using we're just going to delete this stack and all the associated resources 59
so the first thing we need to do is we need to stop and then after it's stopped 60
we need to delete our instance so which is chugging away there to stop we also 61
need to delete the application as well so if we delete that out and confirm 62
deletion of that and we just need to wait for that to finish stopping that 63
instance so that instance is now stopped so we can delete that so once that's 64
deleted then we can go back into our stack and we can delete the stack once 65
the instance has been deleted so we just delete that and that's done