Where to get proper `region name` and `output format` for AWS configuration?
Solution 1
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
Input for Default region name
has to match the region of the instance you're trying to connect with. You can leave output format
empty- all it's asking is what format you'd like the output in, but it will spit out whatever is default for the command that you enter.
Here I am trying to find some info on my instance which resides in us-west-2, but I've entered us-east-1 as default region in aws configure, so I get an error.
[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
Now, I enter my instance region in aws configure and the command returns what I want.
[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"
}
]
Hope that helps.
Solution 2
Per the AWS CLI documentation:
--region (string)
The region to use. Overrides config/env settings.
So, just add a --region us-east-1
or whatever to your command and you're all set.
Related videos on Youtube
makansij
Updated on September 18, 2022Comments
-
makansij over 1 year
I'm trying to get log events via my aws server. I log into the server as usual, and then I enter the following command:
sudo aws logs get-log-events --log-group-name <myLogs> --log-stream-name <stream-name>
I get the error...
You must specify a region. You can also configure your region by running "aws configure".
So, I enter
aws configure
and I see the following:AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: Default output format [None]:
So, I go to my IAM page, and click on
Users
, following this instructions. And after I create the key, I get each of the four pieces of information from the following sources:Access Key ID
from the IAM page.Secret Access Key
after creating the key on the IAM page.The IAM page shows
N/A
for the fieldsregion name
andoutput format
, so I am not sure where to get theregion name
and thedefault format
. So I entered the following:region name
=us-west-2
output format
=json
Trying again, I enter
sudo aws logs get-log-events --log-group-name <myLogs> --log-stream-name <sream-name --region us-west-2
..but I get the same error message again:
You must specify a region. You can also configure your region by running aws configure
.How do I find the correct
region name
andoutput format
? More generally, how do I get myaws
credentials or configurations to stop giving me errors? -
makansij over 8 yearsStill gives an error, albeit a different one :
Unable to locate credentials. You can configure credentials by running "aws configure".
-
EEAA over 8 yearsYou messed up your config the last time you ran
aws configure
. You'll need to fix that. -
makansij over 8 yearsI did. I re-ran
aws configure
to fix my credentials.sudo aws logs get-log-events --log-group-name <my-logs> --log-stream-name <log-name> --region us-west-2
-
EEAA over 8 yearsThe credential issues you're having now have absolutely zero to do with you adding the region flag. Either you're mucked up your credentials or possibly your credentials do not have the necessary privileges to collect logs from your desire region.
-
makansij over 8 yearsI even checked the
config
file to make sure - the configurations are correct. -
EEAA over 8 yearsWell then you have another issue that is beyond the scope of this question.
-
John Rotenstein about 8 yearsTry a command that doesn't require a region (eg
aws s3 ls
) to see if your credentials are still valid. It's also possible that running something undosudo
points to a different directory that does not contain your credentials. Trysudo aws configure
to see if it fixes things.