wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.98k stars 263 forks source link

awless ssh says IP Address does not exist for EC2 Instance when it does. #115

Closed FilBot3 closed 7 years ago

FilBot3 commented 7 years ago

I am able to list the instances that are running under my profile, and I can see the IP address of the EC2 instance. However, when I try to use awless ssh it says that the instance has no IP Address. I can list the IP using the Ruby aws-sdk-ruby and get the IP, but awless does not allow me to hit that IP.

I'm currently on OSX 10.12.5, with Golang 1.8. $ awless --version awless version=v0.1.1


$ ruby packer_helper.rb describe-ec2 --ec2-instance=i-08f3ea393d4ade003
i-08f3ea393d4ade003
10.155.59.83
user01@M1711732 [09:38:44] ~/Documents/development/aws/ets_tools_aws-repo/packer/splunk  [splunk-dev !?]
$ awless ssh cloud-user@i-08f3ea393d4ade003 -p awsprofile -e
[verbose] loading AWS session with profile 'awsprofile' and region 'us-west-2'
[error]   no IP address for instance i-08f3ea393d4ade003
user01@M1711732 [09:41:34] ~/Documents/development/aws/ets_tools_aws-repo/packer/splunk  [splunk-dev !?]
$ awless ssh cloud-user@i-08f3ea393d4ade003 -p awsprofile -e -i ~/.aws/ssh_keys/splunk-admin.pem
[verbose] loading AWS session with profile 'awsprofile' and region 'us-west-2'
[error]   no IP address for instance i-08f3ea393d4ade003```
simcap commented 7 years ago

Not good! Thanks for reporting.

I have a few ideas of where it might come from. Can you share here (hiding the sensitive info) the output of the 2 following commands. First verify you have still the issue and then run:

> awless ls instances -p awsprofile > awless ls instances -p awsprofile --local

Also what does your awsprofile looks like in the ~/.aws/config file? If you could tell us which keys are set: region, ... ?

Cheers

FilBot3 commented 7 years ago

The ~/.aws/config

$ cat ~/.aws/config
[default]
output = json
region = us-west-2

the ~/.aws/credentials file holds the login information.

$ awless ls instances -p cmeng
|        ID ▲         |    ZONE    |             NAME              |   STATE    |    TYPE    | PUBLIC IP |  PRIVATE IP   |
|---------------------|------------|-------------------------------|------------|------------|-----------|---------------|
| i-008f033c3b9f14f87 | us-west-2b | Bind Servers                  | running    | t2.medium  |           | 192.23.130.254 |
| i-00ecee7ef8b4d1f94 | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-018e05ceb076b383a | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-01a830d18fe019422 | us-west-2b | spinnaker-cloudmgmt           | running    | m4.xlarge  |           | 192.155.60.45  |
| i-01e0cffc0762567f7 | us-west-2b | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.60.123 |
| i-022189d8bc42ab4ce | us-west-2a | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.59.136 |
| i-024479b7c56a8f133 | us-west-2b | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.60.228 |
| i-028c351bed44907f5 | us-west-2b | spinnaker-dcos                | running    | m4.xlarge  |           | 192.155.60.60  |
| i-02f4c0f3e257ddfdb | us-west-2b | Chef Server                   | running    | m4.large   |           | 192.23.132.85  |
| i-03042c991c1e3b1f6 | us-west-2b | spinnaker-cloudiam            | running    | m4.xlarge  |           | 192.155.60.8   |
| i-030539b8e3f31eed3 | us-west-2a | spinnaker-cloudmgmt           | running    | t2.nano    |           | 192.155.59.170 |
| i-0320a337e1033e80a | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-035c985ed03ac620d | us-west-2a | Bind Servers                  | running    | t2.medium  |           | 192.155.57.254 |
| i-03f9c1d3f932a565e | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-054c5dc55380b7c1f | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-05954800185b8fd93 | us-west-2a |                               | running    | m3.medium  |           | 192.23.129.37  |
| i-05c0233e4c384e9b9 | us-west-2b | Bind Servers                  | running    | t2.medium  |           | 192.155.58.254 |
| i-0612422c4c274010c | us-west-2a |                               | running    | t2.medium  |           | 192.155.56.10  |
| i-070d548571987f882 | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-073ebc220cfdef61e | us-west-2b | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-077da95bcaaf03d55 | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-07e962890c5f28e8e | us-west-2b | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-086a8f22a308cf8f6 | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-08de7ac0067d34b78 | us-west-2a | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.59.60  |
| i-08f3ea393d4ade003 | us-west-2a | team-splunk-ets-development   | running    | c4.2xlarge |           | 192.155.59.83  |
| i-0915f113911f40a2b | us-west-2a | Bind Servers                  | running    | t2.medium  |           | 192.23.129.254 |
| i-0a5ed5837c832e497 | us-west-2b | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0b2ca1756736389fd | us-west-2a | Spork Master Sandbox          | running    | m4.large   |           | 192.23.131.117 |
| i-0c2258ba5360da5d3 | us-west-2b | spinnaker-projectn            | running    | m4.xlarge  |           | 192.155.58.245 |
| i-0cb8cf840a4386caa | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0cc545ae6c0ccd4a7 | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0d0ca4ce4c183d230 | us-west-2b | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0d0d42677c0acd8ff | us-west-2b | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.60.210 |
| i-0e37ed80d1915e31f | us-west-2a | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0e4328a8f5ab88c67 | us-west-2b | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0ef87beac77c510ad | us-west-2a | spinnaker-norbert             | running    | m4.xlarge  |           | 192.155.59.131 |
| i-0f5070669ad40a0fe | us-west-2b | spinnaker-sds                 | terminated | m4.xlarge  |           |               |
| i-0f666f017ef1d59b3 | us-west-2a | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.59.43  |
| i-0fb99d875fa51cfe3 | us-west-2a | spinnaker-sds                 | running    | m4.xlarge  |           | 192.155.59.201 |
| i-0fbcdb21449a91e56 | us-west-2a | docker-compose-packer         | running    | t2.medium  |           | 192.155.59.229 |
| i-0fcbd5744dc1bdad7 | us-west-2a | spinnaker-cloudmgmt           | running    | m4.xlarge  |           | 192.155.59.147 |
Columns truncated to fit terminal: 'Uptime', 'KeyPair'
user01@M1711732 [11:30:30] ~/Documents/development/aws/team_aws_splunk  [ec2-single-instance !?]
$ awless ls instances -p cmeng --local
No results found.
simcap commented 7 years ago

Since you only have private IPs have you tried with the --private flag as such awless ssh .... --private

It will use the the private IP of the instance. Though it will only connect if you can resolve locally this IP (VPN, Proxy command, ...).

We also need to improve on the error message (and might even try with the private IP as a fallback)

Note also we will soon add a awless ssh .... --through flag to be able to connect to a internal/private instance through another public instance (i.e. a bastion, or proxy host, ssh Proxy Command)

FilBot3 commented 7 years ago

using the --private flag did the trick. I apologize for opening up an issue to have you say that.

simcap commented 7 years ago

No worries. Glad it is working for you now.