Setup problems: AWS


#753

Don’t know how to solve the following issue when doing aws configure.

“Invalid endpoint: https://ec2.Default region name [us-wetst-2 st-2]: us-west-2.amazonaws.com

The following shows default region name in my AWS configure:
$ aws configure
AWS Access Key ID [****************CSCQ]: ****************CSCQ
AWS Secret Access Key [****************t1Nj]: ****************t1Nj
Default region name [Default region name [us-wetst-2 st-2]: us-west-2]: us-west-2
Default output format [text]: text

More information as follows:
When I remove default information, the default region part is still weird.

$ aws configure
AWS Access Key ID []:
AWS Secret Access Key [
]:
Default region name [Default region name [us-wetst-2 st-2]: us-west-2]:
Default output format []:

Thank you!


#754

Hi,

I’m based off US and using AWS us-west-2 but getting the following error on Cygwin.

myname@GACDTL07NH3096 ~
$ wget https://raw.githubusercontent.com/fastai/courses/master/setup/setup_p2.sh
–2017-08-22 15:46:19-- https://raw.githubusercontent.com/fastai/courses/master/setup/setup_p2.sh
Resolving raw.githubusercontent.com… 151.101.56.133
Connecting to raw.githubusercontent.com|151.101.56.133|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 528 [text/plain]
Saving to: ‘setup_p2.sh’

setup_p2.sh 100%[============================================================================>] 528 --.-KB/s in 0s

2017-08-22 15:46:19 (2.84 MB/s) - ‘setup_p2.sh’ saved [528/528]

myname@GACDTL07NH3096 ~
$ bash setup_p2.sh
Only us-west-2 (Oregon), eu-west-1 (Ireland), and us-east-1 (Virginia) are currently supported

The region seems to be correct, so I don’t know what went wrong…
myname@GACDTL07NH3096 ~
$ aws configure get region
us-west-2

Thanks so much!


#755

Solved.

  1. Run rm ~/.aws/config
  2. Run aws configure again.

Everything will be reset.


(George Zhang) #756

Hi Jeremy,

I looked through the alias scripts you provided and spotted a few syntax errors. These could lead your aliases to have different behaviors than what they claimed. People who have abnormal behaviors with the aliases might benefit from this post.

Here is one of them:

alias aws-get-p2='export instanceId=`aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=p2.xlarge" --query "Reservations[0].Instances[0].InstanceId"` && echo $instanceId'

Wow. That is a mouth full. Let’s zoom in and focus on where the problem lies.

aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=p2.xlarge"

Here Jeremy is trying to filter out only the instances that are stopped and have p2.xlarge as instance-type. However, the option values for aws ec2 describe-instances --filter are written in wrong syntax. Here is the correct syntax as specified in AWS-CLI refernce page of the command:

Syntax:
Name=string,Values=string,string ...

The most important thing to notice here is that we have to use space to separates different values of the same option, not comma. Look again at the option part of the command:

--filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=p2.xlarge"

It puts two option values in one pair of quotes and tries to separate them with comma. Though it appears to make sense, it is not the correct syntax. Here the filter option is simply ignored as bad syntax argument. So it is actually not filtering anything.

To make things a bit more clear, here is an reference page example that also uses two filters:

aws ec2 describe-instances --filters "Name=instance-type,Values=m1.small,m1.medium" "Name=availability-zone,Values=us-west-2c"

Pay attention to how the two filters are in two separate pairs of quotes.

So, the problematic part of our original command should be rewritten as:

aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped" "Name=instance-type,Values=p2.xlarge"

Because of the special importance of space in syntax, we must not separate Name and Values with space.

Name=instance-state-name, Values=stopped

With only one extra space, the whole thing will blow up.

These adjustment should address some of the problems people might face while using the aliases.

George


(michael) #757

Thx a lot


(Nikhil Utane) #758

Hi, I am facing peculiar problem while running setup_p2.sh.
The AWS commands seem to be be returning some unexpected character because of which subsequent commands fail.

For e.g.

$ export region=`aws configure get region`
$ echo $region
us-west-2

Still when I run the script, the if condition fails and I get

“Only us-west-2 (Oregon), eu-west-1 (Ireland), and us-east-1 (Virginia) are currently supported”

I tried using $ syntax but still getting same problem.

export region=$(aws configure get region)

However it works fine if I manually set region.

export region=“us-west-2”

This is happening for every aws command and it is difficult to keep doing it manually for all commands.

Has anybody else faced the same issue? I am on Windows 7
Thanks.


(Nikhil Utane) #759

Found that it is the last NULL termination character which is creating the problem. Once you get rid of it, then it works.
You can remove it using:

$ export region=${region::-1}

You’ll have to do it for all aws commands.

There aren’t many references to this issue other than one that Martie raised 5 days ago. Did anything change recently? Thanks.


(Manishankar) #760

Hello,
Trying to set up p2 instance, facing issues in connecting with the server. I’ve managed to setup the server using setup_p2.sh and verified in AWS console that the server is running, but getting ‘Connection timed out’ message on port 22 as below. I’ve tried Terminating the server and setting up again some 3 times, ensured all resources are cleared as per instructions on the Wiki page.



gbs@gbs-PC ~
$ ssh -i /home/gbs/.ssh/aws-key.pem ubuntu@ec2-34-212-106-158.us-west-2.compute.amazonaws.com
ssh: connect to host ec2-34-212-106-158.us-west-2.compute.amazonaws.com port 22: Connection timed out

Kindly help. TIA.


(Saurabh Mittal) #763

Hey Manishankar, Are you using the scripts from git or the obsolete links from platform.ai etc?
Secondly, it appears to me that there are at least two issues in your ssh command:

  1. Its using an old name : aws-key.pem instead of aws-key-fast-ai.pem
  2. You seem to be on Windows, but using the username as ubuntu
    Cheers
    Saurabh

(Saurabh Mittal) #764

Hi,Just wondering if this could have been due to the encoding that changes between DOS and Unix for example?


(gughapriyaaelango@gmail.com) #765

When i check .aws/credentials : i get -
/home/DELL/.aws/credentials: line 1: $’[default]\r’: command not found
/home/DELL/.aws/credentials: line 2: aws_access_key_id: command not found
/home/DELL/.aws/credentials: line 3: aws_secret_access_key: command not found


(gughapriyaaelango@gmail.com) #766

When i do this : ~/.aws/credentials
I get :
/home/DELL/.aws/credentials: line 1: $’[default]\r’: command not found
/home/DELL/.aws/credentials: line 2: aws_access_key_id: command not found
/home/DELL/.aws/credentials: line 3: aws_secret_access_key: command not found


#767

I had the same problem, and then I realized that my AWS user didn’t have “AdministratorAccess” permission. Add this permission in AWS IAM to my user fixed the problem.


(Nikhil Utane) #768

But why now? I didn’t do anything different than what many others would have done on windows platform. The scripts should have handled these things by now. Isn’t it?

-Thanks
Nikhil


(Saurabh Mittal) #769

Exactly - why now :slight_smile: ?
Hence you need to see what is it that you are doing differently from others…Given that this course has been running for almost an year now.

BTW, scripts wouldn’t handle the DOS vs Unix thing, that would need to be done via dos2unix utility as alluded earlier and pointed by many others as well.

If you are manually truncating last character from all the commands, then it certainly seems that the issue is caused due to this only.


(Manishankar) #770

Hi Saurabh,
Thanks for responding. I was using the setup_p2.sh script from http://files.fast.ai/files/ (read somewhere on the forum that the links from platform.ai are obsolete and that http://files.fast.ai/files/ should be used). Will try using the scripts grom git. thanks again, cheers!


(Nikhil Utane) #771

Nothing to do with script. The same problem can be seen when command is run manually. If you scroll up earlier Martie also reported the issue 5 days ago. That’s why I doubted if something changed recently.


(Fenil Suchak) #773

After running the instance successfully and generating the instance id, while connecting it via ssh I get the following error,
ssh: connect to host ec2-35-166-96-231.us-west-2.compute.amazonaws.com port 22: Connection refused

Any idea? how to get around this?


(shuvi) #774

I got the following error while after I input the command “pip install awscli”. How dangerous can this be?

/Library/Python/2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.


#775

Hello all.

There is an time out error, when I use Jeremy’s aws-alias.sh.

First, when
alias aws-get-t2=‘export instanceId=aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped,Name=instance-type,Values=t2.micro" --query "Reservations[0].Instances[0].InstanceId" && echo $instanceId’

I run aws-get-t2, I get the ERROR:
(‘Connection aborted.’, error(61, ‘Connection refused’))

and when I change aws-get-t2 to below:
alias aws-get-t2=‘export instanceId=aws ec2 describe-instances --filters "Name=instance-state-name,Values=stopped" "Name=instance-type,Values=t2.micro" --query "Reservations[0].Instances[0].InstanceId" && echo $instanceId’

I run aws-get-t2, I get the ERROR:
HTTPSConnectionPool(host=‘ec2.us-west-2c.amazonaws.com’, port=443): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<botocore.awsrequest.AWSHTTPSConnection object at 0x10aa18d50>, ‘Connection to ec2.us-west-2c.amazonaws.com timed out. (connect timeout=60)’))

And I have made sure My t2.micro is running all the time.

Can @jeremy and someone give me some hints and guide ? Thanks.