Okay.
Hello lagers and welcome to this lecture and this lecture we're going to learn how to use boot straps
scripts so bootstrap scripts are a way of automating your w s easy to deployments.
It's a way of running things at the command line when your AWP is easy to instance first boots and you
can run things individual commands you can run updates you can install software you can basically do
anything that you can do in the command line and it will run as a script as that easy to instance first
boots up.
So let's go over to the adobe us console.
Okay so here I am in the AWOL so console I am in the Irish Region.
I'm still having some DNS outages in northern Virginia right now which is causing a whole bunch of weird
problems for me.
I can't run some update for example on any easy to instance.
So I'm gonna do this from the Irish region where it will work fine.
So let's go over to E2 and we're gonna go in and provision a new easy to instance.
So I'm gonna go ahead and launch my instance I'm going to use the amazon Linux too am I.
And I'm gonna use a T2 micro.
Now I'm gonna give this instance a AAA MRO so I'm going to give it admin access.
And the reason for that is I'm going to create an S3 bucket using my bootstrap script.
Now if you click if you see down here we've got advance details and if you click on that it will open
up this little text box and in here we paste our boot straps scripts.
So a straps script will always begin with the numbers symbol and then followed by an exclamation mark.
And this is called a shebang.
And then what we do is we do forward slash Ben forward slash bash.
And this is the path to our interpreter and our interpreter basically just takes the commands and runs
them at the root level.
When we first provision our easy to instance when it first boots up.
So what should we do when this first boots up.
Well I think it's sensible to do a yam update.
I think then what we want to do is we want to go in and install the Apache service.
So do yum install HTC BD.
So we're turning this into a little web server once that services installed we want to start the service
so service to DVD then start.
And then of course if the if the easy to instance reboots we want to make sure the Apache service comes
back up on a reboot so to do that we just type in check config hasty TBD and then on and then what we
might want to do is we might want to go over to Alvar dub dub dub tier male directory and we might want
to create a little web page.
So put in here echo paste here now and then we're going to do a header and we'll just say hello cloud
gurus.
Welcome to my Web page.
Something like that now we're gonna end our header and our hatred here now and then I'm going to close
that out.
So it's gonna echo that and we want it to write to an index dot HMO file.
So that will create an index but each team will file with the hello cloud gurus welcome to my Web site
a Web page.
And then we might just want to create a random S3 bucket let's to make bucket.
Oh sorry.
W S S three.
Make bucket and then we'll just call it C when you copy and paste this from the resources section.
Make sure you change the bucket name.
So I'm just gonna do a whole bunch of random letters and numbers.
So that will then go ahead and create my bucket and then what I might want to do is I might want to
back up my web page to my S3 bucket.
So he might do eight of us s three and then copy index dot each to AML and we want to copy that to us
S3 and then again I'm going to just paste that in there.
So if this works what's going to happen is it's gonna go in.
It's gonna do an update.
It's going to install Apache it's then going to start the Apache service.
It's going to then make sure the Apache turns service turns on if there's a reboot.
It's gonna go over to my var dub dub dub reached email directory.
It's gonna create a little web page and then it's going to create an S3 bucket and then move the contents
of my web page over to S3 as well so it's gonna do a backup and in theory we shouldn't even need to
log into this easy to instance we should just be able to navigate to its public IP address and we'll
be able to see this web page.
Hello cloud gurus welcome to my Web page.
Just gonna copy and paste this into my clipboard so I can give it to you in the resources section you'll
be able to download this in the resources section of the course.
Let's go in and add our storage.
So I'm just going to use a gig's my tag I'm just gonna call this boot strapped server and then I'm gonna
go in to my security group's gonna use an existing security group.
Use my web DMC and I'm gonna go ahead and hit review and launch I'm gonna launch this with my London
keeper.
And there we go.
I'm gonna go ahead and launch my instance.
So as soon as that easy to instance comes up I should just be able to navigate to this IP V for address
and once once I do that I should be able to see my web server.
So let's I'm just going to pause video and wait for this website to come up online.
Okay.
It is now up online.
I'm going to go over to a new tab and I'm just going to paste it in.
And there we go.
Hello cloud gurus welcome to my Web page.
So it is definitely working.
That script has run successfully.
Let's go back over here and we'll go back over to S3 and we'll see if it's created my S3 bucket.
I can see my S3 bucket in here this is a new S3 bucket and I can also see my index got hitched here
Mal file which is now in there as well.
So it's backed it up to S3.
So bootstrap scripts are super powerful as you can see it's a way of automating your infrastructure
so you don't have to go in and manually install things.
So feel free to come back and delete that bucket.
I'm just going to go in and hit delete and delete it.
I need to copy this into my clipboard up here and just copy and then paste and then hit to confirm.
And that will go ahead and delete my bucket.
Let's go back over too easy to say I don't want you to delete this instance just yet.
We are going to use it in the next two labs to make sure you have access to it and just leave it up
and running.
So if you've got the time please join me in the next lecture where we're going to look at instance metadata.