5.5 Automating EC2 Bootstrap

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
or

Already have an account? Sign In »

Time
3 hours 27 minutes
Difficulty
Beginner
CEU/CPE
4
Video Transcription
00:00
In this video,
00:02
we will
00:03
right a bash scrip to automate our easy to security updates
00:07
and create a bash Script to launch are easy to Web server.
00:13
In our last video,
00:15
we downloaded and used putty toe log in tow. RTC to instance
00:20
we also use Putty Jin to convert our pen file into a PPK file.
00:25
In this video,
00:27
we will really step up our game and automate the EEC to bootstrap process.
00:32
We will also configure and launch our easy to Web server via bash script.
00:38
So, in essence, everything that we have been doing throughout the past few easy to videos
00:43
manually.
00:45
Such is
00:47
updating our Lennix Am mine. Installing our Apache servers,
00:51
we will combine into a script that will automate all of these tasks.
00:56
For those who may not be familiar, bash stands for
01:00
the born again shell.
01:02
It's a command line interpreter
01:03
that's included with most Lennox distributions.
01:07
It's used for scripting to do such things as read files or execute commands.
01:12
Now our course won't make you a bash expert.
01:17
However, I highly recommend that you continue learning more about bash and other scripting. Language is such as python
01:23
to really take your career to the next level.
01:27
The first thing that we will need to do is create a landing page for a Web server.
01:32
I've created a basic HTML foul
01:34
that says today I am honored to teach you how to automate the EEC to bootstrap process.
01:42
We will need to upload this file
01:45
to an S three bucket,
01:49
So let's log into the console
01:52
and select s3
01:57
click Create bucket.
02:01
Let's give the bucket a unique name.
02:04
I will name mine Cyber Very Dash E C to Dash Automation Dash Demo,
02:10
then click Create bucket.
02:16
Next, we want to attach a role.
02:21
So let's go back out to the console and select I am.
02:29
Then click rolls from the menu on the left
02:35
click create role
02:38
we will slay easy to
02:44
then
02:45
next. Permissions
02:47
in the filter type s3 To select the S tree policies,
02:55
select
02:57
Amazon ist three Full access,
03:00
then click review.
03:06
Let's give our role of name.
03:08
I will call mine
03:09
E C. To underscore
03:13
can underscore Call underscore history
03:16
and
03:17
I will update the description.
03:28
Finally click create role
03:34
and our new role has been created.
03:40
Now let's go back to our newly created as three bucket,
03:45
we will need to upload our static Web page that we created.
03:53
Next. Let's go back to the console
03:57
and click on Easy to.
04:01
Then click Launch instance.
04:08
You select the Amazon Lennox to am I
04:13
t to Micro is our instance type.
04:16
Then click
04:17
configure instance. Details.
04:20
Navigate down to where it says
04:24
I am role.
04:28
Then from the dropdown,
04:30
select our easy to can call as three roll
04:34
scroll down to advanced details,
04:40
then click inside the user data box.
04:43
This is where we create our bash scrip.
04:46
Usually one would create the script in the text editor, but since this is a learning demo, we could place are short script directly into the window, line by line.
04:56
This will give us a chance to learn what each command is doing within the script.
05:01
The first line that we type is called the Shebang.
05:05
This is the pound sign, followed by an exclamation point
05:10
and then the path to the bash Interpreter.
05:15
Next
05:15
we run Yemen stall H T T P D
05:19
Dash. Why?
05:20
To install our Apache server.
05:25
Next we run yum
05:27
update dash y
05:29
to install any security updates.
05:35
Next,
05:36
we will have our E. C. Two Instance, copy our static Web page that we uploaded into Rs Tree Bucket
05:44
to the HTML directory of our new Apache server.
05:59
Next
06:00
we run service H T T p d start
06:03
to start our Apache server,
06:06
and finally,
06:09
we will run the check config. H t t p d on command.
06:14
This command will check to see if the Apaches service is running on our instance,
06:18
just in case our session gets terminated.
06:23
Next, click, add storage,
06:28
click add volume,
06:31
accepted the faults and then click add tags.
06:38
Then select Configure Security Group.
06:41
We will use our existing security group that we created. In a previous lesson,
06:46
Cy Berry underscored Demo underscored DMC
06:49
Now Click Review and Launch
06:53
perform a final review.
06:56
Then Click Launch.
07:00
We will use the existing key pair that we created in previous lesson,
07:04
Then click launch Instances,
07:09
then select view instances
07:13
in the filter. I like to type pending and running to clear out in the stop determinate instances.
07:20
And now that we see are instances
07:23
are being created.
07:27
Once running, our instance will execute the script that we added in the user data box.
07:39
So
07:40
now are instances up in running.
07:43
I will copy the public I p address to the clipboard.
07:55
Next, we will open a browser
07:57
and see if our script worked.
08:01
We expect to see a fully patched and functioning Web server
08:05
hosting our HTML page that we uploaded to RST bucket
08:13
and there's our Web page.
08:16
So just to summarize,
08:18
before we even created this instance,
08:20
we created an HTML page.
08:24
Then we created a new S three bucket
08:28
that we uploaded our HTML file into.
08:31
We then created a new E C to roll, and I am
08:35
that has full access to as three buckets.
08:39
Next, we launched a new easy to instance.
08:43
We instructed it to install the Apache server,
08:46
install any security updates,
08:50
copy the HTML page from Rs three bucket
08:54
to the HTML directory of our Apache server,
08:58
turn on the Apache server
09:01
and check to ensure that the servers running
09:05
all of this was done from a few lines of a bash grip.
09:09
That, my friends, is just a taste of the power of automation.
09:15
Congratulations, everyone, Fantastic job.
09:20
In this video,
09:22
we wrote a bash grip toe automate R E C two security updates,
09:26
and
09:28
we created a bash scrip to launch our easy to Web server
Up Next
Intro to AWS

This Introduction to Amazon Web Services (AWS) course will teach you about Amazon's secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow.

Instructed By