1

00:00:07,700  -->  00:00:12,179
Welcome back to BackSpace Academy. In
this lab we're going to be getting our

2

00:00:12,179  -->  00:00:17,820
hands on with the command-line interface.
We'll be creating a Cloud 9 environment

3

00:00:17,820  -->  00:00:24,720
and using the terminal of that Cloud 9
environment to send CLI commands to AWS.

4

00:00:24,720  -->  00:00:29,910
We're going to issue a command that
will create an s3 bucket we'll also issue

5

00:00:29,910  -->  00:00:34,649
commands to upload an object and then
delete that object and finally

6

00:00:34,649  -->  00:00:41,219
we'll issue a command to delete the bucket and
clean it all up. Ok so starting off in

7

00:00:41,219  -->  00:00:47,329
the management console. We get to the
Cloud 9 console by going to services and

8

00:00:47,329  -->  00:00:52,850
cloud 9 and that will bring us to this
landing page here. If we've already got

9

00:00:52,850  -->  00:00:58,350
Cloud 9 environments already set up,
you'll have a different screen here but

10

00:00:58,350  -->  00:01:02,039
if you haven't used Cloud 9 before this
is what you will be presented with.

11

00:01:02,039  -->  00:01:10,439
We'll click on create environment. We'll
give out our environment a name.

12

00:01:10,439  -->  00:01:16,619
We won't worry about a description it's only
optional and we'll click on next step.

13

00:01:16,619  -->  00:01:21,840
We're going to be creating a new
instance to run this Cloud 9 application on

14

00:01:21,840  -->  00:01:27,869
and we're going to select a t2 micro
instance for that., We're also going to

15

00:01:27,869  -->  00:01:32,729
select the Amazon Linux AMI because it's
got a lot of tools pre-installed on there

16

00:01:32,729  -->  00:01:37,710
including the command-line
interface. What we've also got here is a

17

00:01:37,710  -->  00:01:43,020
cost saving settings. So if we're not
using this service for whatever reason

18

00:01:43,020  -->  00:01:46,829
instead of getting billed for that EC2
instance it will go into hibernation mode

19

00:01:46,829  -->  00:01:52,890
and we will only be billed for the
drives that are attached to that instance

20

00:01:52,890  -->  00:01:56,880
we won't be billed for that
compute capacity as such so that is a

21

00:01:56,880  -->  00:02:00,780
very good thing. We'll leave that there
so that after 30 minutes it will go into

22

00:02:00,780  -->  00:02:05,850
hibernation. When we go back into this it
will come out of hibernation if we

23

00:02:05,850  -->  00:02:13,410
haven't used it. Click on next step and
that's how easy it is to create

24

00:02:13,410  -->  00:02:20,460
a Cloud9 environment in your default VPC
and we will click on create environment now.

25

00:02:20,460  -->  00:02:25,200
After a few minutes the EC2 instance
will be launched and that Cloud 9

26

00:02:25,200  -->  00:02:31,680
application will be running and we'll
have the IDE operating within our

27

00:02:31,680  -->  00:02:41,790
browser. Ok, so after about five minutes
or so we've got our cloud 9 integrated

28

00:02:41,790  -->  00:02:45,480
development environment up and running.
On the left hand side there we can

29

00:02:45,480  -->  00:02:51,990
see that we've got a tree view of our
file structure within this ec2 instance.

30

00:02:51,990  -->  00:02:56,190
So that's great so we can actually from
there we can upload files quite easily

31

00:02:56,190  -->  00:03:01,260
just by simply dragging and dropping
them onto a form. Down on the bottom

32

00:03:01,260  -->  00:03:05,910
there we've got a batch screen. So that's
a linux terminal console and from there

33

00:03:05,910  -->  00:03:12,810
we can start issuing commands through
our EC2 instance to the AWS service and

34

00:03:12,810  -->  00:03:19,290
in the center there we've got tabs which
will allow us to view files and modify

35

00:03:19,290  -->  00:03:24,930
those files. So that is our editor as
such. Now if we want to change this,

36

00:03:24,930  -->  00:03:31,170
yours will probably be a quite light and
bright user interface I like a dark one.

37

00:03:31,170  -->  00:03:37,680
What you can do is just go into this
toolbox icon here this sprocket and

38

00:03:37,680  -->  00:03:44,280
just click on that for the Preferences
and if you scroll down and you go to

39

00:03:44,280  -->  00:03:51,239
themes you can select. By default I
think you have this flat theme which

40

00:03:51,239  -->  00:03:54,390
will be that one there but you can
change it to a darker theme and I'd like

41

00:03:54,390  -->  00:03:59,040
this dark grey one here. If you like
the dark grey you can change it to that

42

00:03:59,040  -->  00:04:04,140
quite easily. So we just close out of
that now and we will start to issue some

43

00:04:04,140  -->  00:04:10,500
commands and see how we go. Now the first
thing that we need to do is to check

44

00:04:10,500  -->  00:04:18,330
whether the AWS command line interface
tools are installed so we do AWS - - and

45

00:04:18,330  -->  00:04:24,270
version and there we can see we've got
the latest version of our CLI in there

46

00:04:24,270  -->  00:04:27,360
so what I'll do now is I'm going to
issue a command

47

00:04:27,360  -->  00:04:33,870
and that is going to create a bucket on
our on our AWS account

48

00:04:33,870  -->  00:04:41,300
The command there is AWS for the CLI command
s3 for the s3 service MB is the

49

00:04:41,300  -->  00:04:47,039
command to make a bucket and then we do
s3 colon forward slash forward slash and

50

00:04:47,039  -->  00:04:54,629
the name of that bucket. I'm just
going to give it a unique name.

51

00:04:54,629  -->  00:04:58,439
You'll need to have a different name to
this it will need to be unique for a

52

00:04:58,439  -->  00:05:03,509
bucket, and we'll click on enter, and so
there we can see that has

53

00:05:03,509  -->  00:05:09,840
successively created a bucket for us. If we go into the s3 console we'll be

54

00:05:09,840  -->  00:05:13,889
able to see that that bucket has been
created, but before we do that how about

55

00:05:13,889  -->  00:05:21,960
we upload a file. First off, what we'll
do is, we'll upload a file to this EC2

56

00:05:21,960  -->  00:05:26,729
instance and we're going to be doing
that by going on to the the tree view here

57

00:05:26,729  -->  00:05:33,449
and what we can do is go to file
and upload local files and then all we

58

00:05:33,449  -->  00:05:36,089
need to do is just drag and drop a file.
I'm just going to drag and drop the

59

00:05:36,089  -->  00:05:42,930
lab notes onto this onto this form and
then that will upload that to this EC2

60

00:05:42,930  -->  00:05:50,669
instance. Ok so there on the left-hand
side you can see that we're uploading it

61

00:05:50,669  -->  00:05:57,629
and very quickly it has uploaded that to
our our EC2 instance. I'm just going

62

00:05:57,629  -->  00:06:03,839
to shorten that name a little bit and
just going to call it notes and that

63

00:06:03,839  -->  00:06:09,210
will be fine. Ok what we can do now is
that we can issue a command that will

64

00:06:09,210  -->  00:06:17,879
copy that file over as an s3 object to
the s3 bucket. The command we need to

65

00:06:17,879  -->  00:06:24,770
use is the AWS s3 CP command. So AWS s3

66

00:06:24,770  -->  00:06:29,669
CP and then the the actual file name. So
it'll be notes.

67

00:06:29,669  -->  00:06:34,169
Now remember file names are case
sensitive so this has a capital n so I'm

68

00:06:34,169  -->  00:06:39,300
putting a capital in there, .PDF and
then the name of the bucket which will

69

00:06:39,300  -->  00:06:43,290
be s3
and then that name of the bucket.

70

00:06:43,290  -->  00:06:52,860
S3 colon forward slash forward slash and
that bucket name CLI... Okay so there we go

71

00:06:52,860  -->  00:07:01,080
AWS s3 CP the file name and then the
bucket name there. Click enter and

72

00:07:01,080  -->  00:07:08,060
there we go it's uploaded that notes.PDF
to that bucket. If we go into the

73

00:07:08,060  -->  00:07:12,690
management console for s3 we'll be able
to see that uploaded object inside of

74

00:07:12,690  -->  00:07:17,520
that bucket. Okay so we do a new tab here
and just jump into the management

75

00:07:17,520  -->  00:07:30,090
console. There we go. Iif we jump
into the s3 service, have a look for that bucket

76

00:07:30,090  -->  00:07:36,480
there it is, CLI pcoady and there
we can see we've got that bucket

77

00:07:36,480  -->  00:07:41,730
has been created our notes.PDF document
is in. Everything seems fine.

78

00:07:41,730  -->  00:07:46,410
What we'll do now is we'll clean it all up by
deleting that that note.PDF

79

00:07:46,410  -->  00:07:55,230
the command we use is a AWS s3 RM
and then s3 and colon forward slash

80

00:07:55,230  -->  00:08:02,100
forward slash and then the name of that
bucket and then forward slash

81

00:08:02,100  -->  00:08:08,310
the name of the actual file itself and enter. There we can see we've successfully

82

00:08:08,310  -->  00:08:13,050
deleted that and if we go to this
management console and if we refresh the

83

00:08:13,050  -->  00:08:18,240
screen we can see it now the bucket is
empty. So the buckets empty we can now delete it.

84

00:08:18,240  -->  00:08:28,140
the command that we use is AWS s3
and rb to remove that bucket and then

85

00:08:28,140  -->  00:08:35,880
simply the name of that bucket. Okay so
it's removed that bucket

86

00:08:35,880  -->  00:08:39,599
that's pretty well all I want to show you as
far as the command line interface goes

87

00:08:39,599  -->  00:08:43,979
because it's a very, very powerful tool
that can be used with a whole heap of

88

00:08:43,979  -->  00:08:49,230
different services. If you want to
know more about the CLI or you want to

89

00:08:49,230  -->  00:08:54,960
see the documentation just go to the
Amazon website so aws.amazon.com/CLI

90

00:08:54,960  -->  00:09:05,640
and then we can go to the CLI
reference. Okay so that will have a whole

91

00:09:05,640  -->  00:09:09,600
heap of different commands that are
available for the different services

92

00:09:09,600  -->  00:09:14,100
you see the available services is
absolutely massive. Ee'll scroll down

93

00:09:14,100  -->  00:09:20,610
to what we've been using, which is s3. We see there we've got two we've got s3

94

00:09:20,610  -->  00:09:27,420
and we've got s3 API. The s3 API is
far more powerful and that takes

95

00:09:27,420  -->  00:09:32,540
advantage of all of the API commands
that are available whereas the s3

96

00:09:32,540  -->  00:09:37,950
commands only have very shortened
limited use, so they're they're more for

97

00:09:37,950  -->  00:09:43,260
quick things to be done, so CP instead of
copy and then having this big long string

98

00:09:43,260  -->  00:09:48,149
Let's have a look at that
so we go into the s3 API and if we want

99

00:09:48,149  -->  00:09:54,390
to create a bucket we can scroll down
and we can see the command there it's

100

00:09:54,390  -->  00:09:59,850
quite long and lengthy, so we can see
there it's a lot more verby than using

101

00:09:59,850  -->  00:10:04,020
just a simple CP command but it's a lot
more powerful, you can do a lot more with it

102

00:10:04,020  -->  00:10:16,160
I'll just go back and we'll have a
look the s3 commands so we can see here

103

00:10:16,160  -->  00:10:21,150
we don't have a lot of commands
available so they're the only commands

104

00:10:21,150  -->  00:10:25,709
that are available using their s3. If
you want more than that and you want the

105

00:10:25,709  -->  00:10:30,390
full capability that you have with the
s3 service you can use the s3 API commands

106

00:10:30,390  -->  00:10:33,330
Let's have a look at one of
the ones that we've been using there

107

00:10:33,330  -->  00:10:39,390
CP and we can see there it's going to
have different options and whatever that

108

00:10:39,390  -->  00:10:46,380
are available it'll have an example we
scroll down. Ok so there we can see

109

00:10:46,380  -->  00:10:50,550
we've got an example. Now what you do there is
that we've got first off we define what

110

00:10:50,550  -->  00:10:55,079
that file, that local file, is and then we
define where we want to send it to

111

00:10:55,079  -->  00:10:59,190
so we just sent it to my bucket but if
you wanted to change the name of that

112

00:10:59,190  -->  00:11:04,470
because you can see here we're going
from test to test2 can actually put

113

00:11:04,470  -->  00:11:11,149
that extension to that bucket name there.
So that's pretty well it, as far as that

114

00:11:11,149  -->  00:11:17,220
S3 stuff goes, it's not really a lot to
learn with that s3 but again go to the

115

00:11:17,220  -->  00:11:21,149
document page and have a look at it and
see if we can play around with some of

116

00:11:21,149  -->  00:11:25,500
these different sorts of commands and
you'll find it is quite a powerful thing to use

117

00:11:25,500  -->  00:11:29,970
so that brings us to the end of
the lab first thing that we need to do

118

00:11:29,970  -->  00:11:35,310
now is just clean up this development
environment so what we do is, we click on

119

00:11:35,310  -->  00:11:43,320
AWS Cloud 9 here. We go to our
dashboard and there are our environments

120

00:11:43,320  -->  00:11:46,140
now I've got two environments here
you'll just have one, select that

121

00:11:46,140  -->  00:11:57,390
environment and delete and just type in
delete and that will eventually delete

122

00:11:57,390  -->  00:12:01,410
that ec2 instance and that complete
environment and bring you back

123

00:12:01,410  -->  00:12:04,920
so that you're not going to get a bill at the
end of the month. That brings us to the

124

00:12:04,920  -->  00:12:09,980
end and I look forward to seeing you in
the next one
