WEBVTT

00:00.780 --> 00:01.880
In this lecture,

00:01.880 --> 00:06.080
we will see how to programmatically
interact with the AWS cloud.

00:07.200 --> 00:10.980
Previously, we saw that
when we create an IAM user,

00:10.980 --> 00:13.620
there are two access methods
that can be provided.

00:14.380 --> 00:19.640
The first one is the access to the management
console using a username and a password.

00:20.260 --> 00:23.080
The second method is to access
programmatically

00:23.140 --> 00:25.600
by making use of access keys.

00:27.300 --> 00:33.000
The AWS CLI is an open source tool that
allows us to interact with AWS services

00:33.000 --> 00:36.000
using command line tools such as Linux Shells,

00:36.260 --> 00:39.320
Command Line Prompts,
and PowerShell and Windows.

00:40.460 --> 00:45.300
The current version of the AWS CLI
as of this recording is version 2,

00:45.300 --> 00:48.760
and it can be installed
on all popular operating systems.

00:50.060 --> 00:54.360
The link in the reference section provides
detailed instructions on how to download,

00:54.360 --> 00:58.380
install and configure AWS CLI
on the operating system of your choice.

00:59.280 --> 01:01.760
Irrespective of the OS that we choose,

01:01.760 --> 01:05.780
installing the CLI tool is as simple
as downloading the required package,

01:05.860 --> 01:09.600
either with the graphical user interface,
or the GUI,

01:09.780 --> 01:12.340
or making use of the CLI as shown here.

01:13.340 --> 01:18.540
Once downloaded, we can install the CLI
by making use of the install script in Linux,

01:18.640 --> 01:20.140
or by launching the installer

01:20.140 --> 01:23.060
and following the on-screen instructions
in other platforms.

01:24.080 --> 01:27.920
Once we have downloaded the AWS CLI,
we need to configure it

01:27.920 --> 01:30.940
so that it can connect
to our specific AWS account.

01:31.700 --> 01:36.240
This is where the access key ID
and the secret access key come in to the picture.

01:37.160 --> 01:41.600
To configure the AWS CLI,
run the command "aws configure".

01:42.480 --> 01:46.400
This command when run
will prompt for additional information.

01:46.880 --> 01:51.860
The first two inputs to be provided are
the Access Key ID and the Secret Access Keys

01:51.860 --> 01:54.720
that were downloaded from
the management console for the user.

01:55.660 --> 01:58.440
Next, we need to specify the default region

01:58.440 --> 02:01.760
which should be used
when deploying resources in AWS.

02:02.260 --> 02:05.500
Normally, this is set to the region
closest to the user,

02:05.620 --> 02:09.440
but it can be set to any other region
depending on our preference.

02:10.460 --> 02:14.700
Once a default is set, we can also override it
later when using the tool.

02:15.100 --> 02:16.860
We will see how to do that later.

02:18.340 --> 02:22.180
The final input that we have to provide
while configuring the AWS tool

02:22.180 --> 02:24.180
is the default output format.

02:24.640 --> 02:28.820
This can be set to a type of JSON, YAML,
Text or Table.

02:29.220 --> 02:32.700
Here we have made use of the JSON format
as the default.

02:34.220 --> 02:37.920
Once we enter all this information,
the CLI is configured,

02:37.920 --> 02:41.280
and we are now ready to use it
to manage our AWS environment.

02:42.140 --> 02:44.500
The credentials and configuration
that we provided

02:44.500 --> 02:49.360
are stored inside a hidden directory called
.aws in the home directory of the user.

02:50.580 --> 02:54.260
Now that we have configured the AWS CLI,
let's start using it.

02:54.800 --> 02:57.880
The syntax of using the CLI is like this.

02:58.920 --> 03:01.760
The base command to be used is aws.

03:02.000 --> 03:04.140
This is followed by the top-level command

03:04.140 --> 03:07.180
which is normally the service
that we want to interact with.

03:07.920 --> 03:12.500
Following this is the subcommand,
which specifies which operations to perform.

03:13.740 --> 03:16.880
All commands come with additional
options and parameters

03:16.880 --> 03:19.820
that can be provided to interact
with the AWS account.

03:20.440 --> 03:25.680
To illustrate this, let us create an IAM user
called lucy using the AWS CLI.

03:26.520 --> 03:34.380
We can do this by running the command
“aws iam create-user --user-name lucy”.

03:35.260 --> 03:40.180
Here, the command is IAM,
which is the service that we want to make use of.

03:40.820 --> 03:43.540
The subcommand is create-user.

03:44.180 --> 03:49.480
The option called user-name allows us
to provide the user that we want to create,

03:49.480 --> 03:51.260
which is lucy in this case.

03:52.540 --> 03:56.620
Once the command is run, the details
related to the newly created user

03:56.620 --> 03:59.040
should be displayed on the screen, like this.

04:00.700 --> 04:05.160
Here we can see the username,
the creation date, user ID,

04:05.160 --> 04:07.300
and something something called as the ARN.

04:08.320 --> 04:11.360
ARN stands for Amazon Resource Name.

04:11.620 --> 04:15.420
This is a unique name which is assigned
to every resource in AWS.

04:15.540 --> 04:19.420
This is done to uniquely identify it
with the AWS ecosystem.

04:20.760 --> 04:25.560
Similarly, we can create and manage
all other resources using the AWS CLI.

04:25.740 --> 04:28.900
Since there are so many services
offered by AWS,

04:28.900 --> 04:32.060
it is impossible to remember
every command, subcommand,

04:32.060 --> 04:34.680
options and parameters
to use for each of them.

04:35.020 --> 04:36.540
Luckily, we don't have to.

04:36.980 --> 04:39.880
The AWS CLI offers help with all the commands.

04:40.600 --> 04:43.840
To access help, type aws help.

04:44.560 --> 04:49.060
This will open up the comprehensive
documentation about how to use the CLI tool

04:49.060 --> 04:53.020
including all the services, commands,
and subcommands that can be used.

04:54.320 --> 04:56.660
To get help related to a specific command,

04:56.660 --> 05:01.540
type aws followed by the command name
and then help, like this.

05:02.780 --> 05:06.700
In this case, we are looking up help
for the iam command.

05:07.940 --> 05:10.120
This will pull up information
about the command

05:10.120 --> 05:12.980
and list all the subcommands
available to the command.

05:14.100 --> 05:18.640
Finally, to get help related to
a particular subcommand or an operation,

05:18.720 --> 05:20.920
such as the create-user in IAM,

05:20.920 --> 05:24.440
use the help command
along with the subcommand, like this.

05:26.580 --> 05:28.000
That's it for this lecture.

05:28.000 --> 05:32.360
Let's head over to the hands-on labs
and practice working with AWS CLI.

