哪里得到正确的`地区名称`和输出格式的AWSconfiguration?

我试图通过我的aws服务器获取日志事件。 我照常login到服务器,然后input以下命令:

sudo aws logs get-log-events --log-group-name <myLogs> --log-stream-name <stream-name>

我得到错误…

You must specify a region. You can also configure your region by running "aws configure".

所以,我inputaws configure ,我看到以下内容:

 AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: Default output format [None]: 

所以,我去我的IAM页面,点击Users ,按照这个指示 。 在创build密钥之后,我从以下来源获得四条信息:

从IAM页面Access Key ID 。 在IAM页面上创buildSecret Access Key后,密钥Secret Access Key

IAM页面显示字段region nameoutput format N/A ,所以我不确定在哪里得到region namedefault format 。 所以我input了以下内容:

region name = us-west-2 output format = json

再试一次,我inputsudo aws logs get-log-events --log-group-name <myLogs> --log-stream-name <sream-name --region us-west-2

但是我再次得到相同的错误消息: You must specify a region. You can also configure your region by running aws configure You must specify a region. You can also configure your region by running aws configure

我如何find正确的region nameoutput format ? 更一般地说,如何获得我的aws凭证或configuration以停止给我错误?

 AWS Access Key ID [None]: enter key id AWS Secret Access Key [None]: enter access key Default region name [None]: enter region code for instance connected with Default output format [None]: leave empty or not 

Default region nameinput必须与您尝试连接的实例的区域匹配。 你可以保持output format空 – 它所要求的是你想输出的格式,但是它会吐出你input的命令的默认值。

在这里,我试图find我驻留在us-west-2的实例的一些信息,但是我已经在aws configure中input了us-east-1作为默认区域,所以我得到一个错误。

 [root@ip-444-21-27-145 lost+found]# aws configure AWS Access Key ID [****************IDBA]: AWS Secret Access Key [****************BHLx]: Default region name [us-west-2]: us-east-1 Default output format [None]: [root@ip-444-21-27-145 lost+found]# aws ec2 describe-instances --instance-id i-0a6a6b7e24er203f0 --query 'Reservations[].Instances[].{Name:ImageId,InstanceId:InstanceId,VolumeInfo:BlockDeviceMappings}' An error occurred (InvalidInstanceID.NotFound) when calling the DescribeInstances operation: The instance ID 'i-0a6a6b7e24er203f0' does not exist 

现在,我在aws configure中input实例区域,命令返回我想要的。

 [root@ip-444-21-27-145 lost+found]# aws configure AWS Access Key ID [****************IDBA]: AWS Secret Access Key [****************BHLx]: Default region name [us-east-1]: us-west-2 Default output format [None]: [root@444-21-27-145 lost+found]# aws ec2 describe-instances --instance-id i-0a6a6b7e24er203f0 --query 'Reservations[].Instances[].{Name:ImageId,InstanceId:InstanceId,VolumeInfo:BlockDeviceMappings}' [ { "InstanceId": "i-0a6a6b7e24er203f0", "VolumeInfo": [ { "DeviceName": "/dev/xvda", "Ebs": { "Status": "attached", "DeleteOnTermination": true, "VolumeId": "vol-0aa40d5ef1df76968", "AttachTime": "2017-11-09T02:00:31.000Z" } }, { "DeviceName": "/dev/sdf", "Ebs": { "Status": "attached", "DeleteOnTermination": false, "VolumeId": "vol-0a82823250ba51323", "AttachTime": "2017-11-09T02:09:29.000Z" } }, { "DeviceName": "/dev/sdg", "Ebs": { "Status": "attached", "DeleteOnTermination": false, "VolumeId": "vol-0be466f7daa5593e2", "AttachTime": "2017-11-09T02:35:46.000Z" } } ], "Name": "ami-32d8124a" } ] 

希望有所帮助。

根据AWS CLI文档 :

 --region (string) The region to use. Overrides config/env settings. 

所以,只要添加一个 – --region us-east-1或任何你的命令,你都成立了。