- Hands-On Artificial Intelligence on Amazon Web Services
- Subhashini Tripuraneni Charles Song
- 516字
- 2021-06-24 12:48:44
Configuring the AWS CLI
Before we can use the AWS CLI, we need to perform a few configuration steps. The fastest way to configure your AWS CLI is with the following command:
$ aws configure
AWS Access Key ID [None]: <your access key>
AWS Secret Access Key [None]: <your secret key>
Default region name [None]: us-east-1
Default output format [None]: json
The explanation of the preceding code is as follows:
- The first two items that we need to enter are the security credentials so that the CLI has the permissions to perform actions on your behalf. This is the key pair that is contained within the CSV file that we downloaded during the creation of a new user with the IAM service. Open the CSV file and copy and paste the access key ID and the secret access key into the configuration command prompt.
- Next, for the default region name, we will again use us-east-1 for consistency throughout this book.
- Finally, for the default output format, enter json. This will set the output for the AWS CLI to be JSON format.
The AWS configure command creates a hidden directory, .aws, in your user home directory, for example, ~/.aws on macOS and Linux. In this directory, two files are created. One is .aws/credentials, with the following code:
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
The other is .aws/config, with the following code:
[default]
region = us-east-1
output = json
Locate these files on your system and verify their contents.
In case you did not copy down or download the access key pair, you can obtain a new key pair in the AWS Management Console:
- Navigate to the IAM service under the Security, Identity, & Compliance heading.
- In the IAM Management Console, click on Users on the right-hand pane and click on your username.
- On the user summary page, click on the Security credentials tab.
- Under the Access keys section, click on the Create access key button and a new access key will be created for you.
- Remember to delete the old key pair after the new one has been created.
This is how your screen will look:

Remember to configure your AWS CLI with the following command, each time you change your access key:
$ aws configure
Enter your security credentials, default region, and default output format as we explained in the initial AWS CLI configuration.
To test whether the AWS CLI is configured properly, issue the following command:
$ aws s3 ls
2018-12-01 18:01:20 contents.aws.ai
2018-12-01 18:01:49 data.aws.ai
2018-12-01 18:01:35 website.aws.ai
This command will print all of the S3 buckets in your AWS account. More specifically, this command lists the S3 buckets that the user who is associated with the access key has permissions to see. Remember the key pair we configured the CLI with, which belongs to the user to whom we granted the administrative policy? One of the permissions within the administrative policy gives the user access to S3. In any case, you should see the S3 bucket that we created in the previous section of this chapter via the AWS Management Console.
- 大數(shù)據(jù)管理系統(tǒng)
- 程序設(shè)計(jì)缺陷分析與實(shí)踐
- VB語言程序設(shè)計(jì)
- Pig Design Patterns
- STM32嵌入式微控制器快速上手
- 網(wǎng)絡(luò)布線與小型局域網(wǎng)搭建
- R Machine Learning Projects
- Mastering Exploratory Analysis with pandas
- 工業(yè)機(jī)器人入門實(shí)用教程
- 網(wǎng)站規(guī)劃與網(wǎng)頁設(shè)計(jì)
- x86/x64體系探索及編程
- 數(shù)據(jù)庫基礎(chǔ):Access
- 深度剖析:硬盤固件級(jí)數(shù)據(jù)恢復(fù)
- Internet of Things for Architects
- 人工智能算法(卷2):受大自然啟發(fā)的算法