AWS – CLI

I am rather a command line person myself so in retrospect I was a bit surprised that I didn’t leap to the AWSCLI command line program.  This tool lets you do from your shell what you might have had to do with various AWS screens.

Not quite intuitive

The AWS documentation makes it look pretty simple.  Just type the following command.

pip install awscli --upgrade --user

This actually does make the assumption that you already have python and pip installed on your machine.

I am not a python developer but it sounded like this would all be a downhill slide as pip actually already comes installed with python since 3.4.

I did have some false starts for a lot of reasons.  The first is that if you are installing this on windows you should take the windows install package.  It may have been an error but I tried the 64 bit embedded version which did not seem to have pip, nor did the 32 bit embedded version. I was a bit disappointed but i then tried a windows install that still didn’t quite work.

This was probably my fault as I assumed that this was some sort command to be interpreted by the python interpreter – nope. If you do that, you will end up watching youtube videos and reading webpages that basically lead you in the wrong direction.

Eventually I found the correct web page that pointed out that the pip command is essentially an external program that needs to be run, just as seen above.

However, I found this out after reverting to python 3.5.4 and making sure that both the installed directory as well as its Scripts sub-directory was in the path.  Yup, that makes everything work a lot easier.  But I am not really willing to install the more up to date 3.6.3 python – well at the moment.

AWSCLI

Well, the aws command is exactly like the pip command, you simply run this from the command line and then everything works just fine, well, sorta.

You need to first do one little configuration and amazon again does step you through it.  Of course you do need to either setup a user in the IAM or use an existing user with the necessary privilages.

aws configure

You will be asked four questions and most of these answers are already available from the IAM. What I thought would be the tricky question was what is my aws_access_key_id and the aws_secret_access_key.  The other questions seem pretty tame, what format do you want you output and what region are you in.

I got the hard part right but somehow got my region wrong.  My attempts to manually fix these two files (.aws/credentialls and .aws/config) only seemed to make things worse.  My example command seemed simple enough.

aws ec2 describe-instances

I either ended up having some fairly odd problems with the explanation that my profile could not be found or the program would hang. In the end, I could not manuallly fix these files so I simply deleted the two configuration files and re-ran the configure with a minor change.

aws configure --profile myuser

This worked a lot better and then my test program almost worked.  I realized that I was running my test using a different region (Frankfurt) versus what I should have been US East (Ohio).

I think that I was saved by that mistake.  Once I changed my region I started to get a much more reasonable error.

Invalid endpoint: https://ec2.us east.amazonaws.com

Yes, I made a pretty bad guess at my region but it did help to yield this very badly formatted URL and google came to my assistance.  I turned out that I was nowhere near correct with my region name

(quick side rant)

The amazon documentation has a hyperlink everywhere when you are reading about almost any topic.  It is almost impossible to go through from start to end on a topic without visiting a dozen other document links.  Guess how many links about regions they had on this page.  Yup, none.

Anyway, Amazon also has a list of all of their regions which was very helpful.  I changed my region to one from this list and then my aws test command worked.

I never got a chance to get back to my studies of Aws Lambda, but I will get to that in the morning.

 

Python

https://www.python.org/downloads/release/python-354/

This entry was posted in Setup From Scratch and tagged , , . Bookmark the permalink.