{"action":"created","comment":{"url":"https://api.github.com/repos/sportngin/opsicle/pulls/comments/23411886","id":23411886,"diff_hunk":"@@ -7,21 +7,29 @@ def initialize(environment)\n     end\n \n     def execute(options={})\n+\n       if instances.length == 1\n         choice = 1\n       else\n         Output.say \"Choose an Opsworks instance:\"\n-        instances.each_index do |x|\n-          Output.say \"#{x+1}) #{instances[x][:hostname]}\"\n+        instances.each_with_index do |instance, index|\n+          Output.say \"#{index+1}) #{instance[:hostname]}\"\n         end\n         choice = Output.ask(\"? \", Integer) { |q| q.in = 1..instances.length }\n       end\n \n-      instance_ip = instances[choice-1][:elastic_ip] || instances[choice-1][:public_ip]\n       ssh_command = \" \\\"#{options[:\"ssh-cmd\"].gsub(/'/){ %q(\\') }}\\\"\" if options[:\"ssh-cmd\"] #escape single quotes\n-      ssh_options = \"#{options[:\"ssh-opts\"]} \" if options[:\"ssh-opts\"]\n+      ssh_options = options[:\"ssh-opts\"] ? \"#{options[:\"ssh-opts\"]} \" : \"\"\n+\n+      instance = instances[choice-1]\n+      if instance_ip = instance[:elastic_ip] || instance[:public_ip]\n+        ssh_string = \"#{ssh_username}@#{instance_ip}\"\n+      else\n+        ssh_string = \"#{ssh_username}@#{public_ips.sample} ssh #{instance[:private_ip]}\"\n+        ssh_options.concat('-A -t ')\n+      end","path":"lib/opsicle/commands/ssh.rb","position":28,"original_position":28,"commit_id":"05b2bbe5e334264504d879576653e1f765eef95c","original_commit_id":"05b2bbe5e334264504d879576653e1f765eef95c","user":{"login":"elliothursh","id":2453875,"avatar_url":"https://avatars.githubusercontent.com/u/2453875?v=3","gravatar_id":"","url":"https://api.github.com/users/elliothursh","html_url":"https://github.com/elliothursh","followers_url":"https://api.github.com/users/elliothursh/followers","following_url":"https://api.github.com/users/elliothursh/following{/other_user}","gists_url":"https://api.github.com/users/elliothursh/gists{/gist_id}","starred_url":"https://api.github.com/users/elliothursh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elliothursh/subscriptions","organizations_url":"https://api.github.com/users/elliothursh/orgs","repos_url":"https://api.github.com/users/elliothursh/repos","events_url":"https://api.github.com/users/elliothursh/events{/privacy}","received_events_url":"https://api.github.com/users/elliothursh/received_events","type":"User","site_admin":false},"body":"if i do that something like that does does that mean I don't have to refactor the config at this point in time?","created_at":"2015-01-22T21:34:43Z","updated_at":"2015-01-22T21:34:43Z","html_url":"https://github.com/sportngin/opsicle/pull/73#discussion_r23411886","pull_request_url":"https://api.github.com/repos/sportngin/opsicle/pulls/73","_links":{"self":{"href":"https://api.github.com/repos/sportngin/opsicle/pulls/comments/23411886"},"html":{"href":"https://github.com/sportngin/opsicle/pull/73#discussion_r23411886"},"pull_request":{"href":"https://api.github.com/repos/sportngin/opsicle/pulls/73"}}},"pull_request":{"url":"https://api.github.com/repos/sportngin/opsicle/pulls/73","id":27814621,"html_url":"https://github.com/sportngin/opsicle/pull/73","diff_url":"https://github.com/sportngin/opsicle/pull/73.diff","patch_url":"https://github.com/sportngin/opsicle/pull/73.patch","issue_url":"https://api.github.com/repos/sportngin/opsicle/issues/73","number":73,"state":"open","locked":false,"title":"Adding the ability connect to a private instance with a proxy","user":{"login":"elliothursh","id":2453875,"avatar_url":"https://avatars.githubusercontent.com/u/2453875?v=3","gravatar_id":"","url":"https://api.github.com/users/elliothursh","html_url":"https://github.com/elliothursh","followers_url":"https://api.github.com/users/elliothursh/followers","following_url":"https://api.github.com/users/elliothursh/following{/other_user}","gists_url":"https://api.github.com/users/elliothursh/gists{/gist_id}","starred_url":"https://api.github.com/users/elliothursh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elliothursh/subscriptions","organizations_url":"https://api.github.com/users/elliothursh/orgs","repos_url":"https://api.github.com/users/elliothursh/repos","events_url":"https://api.github.com/users/elliothursh/events{/privacy}","received_events_url":"https://api.github.com/users/elliothursh/received_events","type":"User","site_admin":false},"body":"This enables the user to connect to instances without a public IP by connecting through a proxy first. If a user selects an instance with out a public IP, it will ssh to the chosen instance through a randomly chosen public IP from that stack. \r\n\r\nI suppose this is a fix for [this](https://github.com/sportngin/opsicle/issues/46)\r\nDeploy Plan\r\n-----------\r\n> Does Infrastructure need to know anything special about this deploy?\r\n\r\nRollback Plan\r\n-------------\r\n* To roll back this change, revert the merge with: `git revert -m 1 MERGE_SHA` and perform another deploy.\r\n\r\nURLs\r\n----\r\n> Links to bug tickets or user stories.\r\n\r\nQA Plan\r\n-------\r\n> Fill in scenarios below. Review [QA Best Practices](https://source.sportngin.com/page/show/1227795-qa-best-practices).\r\n\r\n#### Happy Path Scenarios\r\nTry ssh-ing to an instance with no public IP. It should still connect.","created_at":"2015-01-22T02:54:40Z","updated_at":"2015-01-22T21:34:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24e3095c23ced125ab5a91e9719674744719461e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sportngin/opsicle/pulls/73/commits","review_comments_url":"https://api.github.com/repos/sportngin/opsicle/pulls/73/comments","review_comment_url":"https://api.github.com/repos/sportngin/opsicle/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sportngin/opsicle/issues/73/comments","statuses_url":"https://api.github.com/repos/sportngin/opsicle/statuses/05b2bbe5e334264504d879576653e1f765eef95c","head":{"label":"sportngin:smarter-ssh","ref":"smarter-ssh","sha":"05b2bbe5e334264504d879576653e1f765eef95c","user":{"login":"sportngin","id":3728684,"avatar_url":"https://avatars.githubusercontent.com/u/3728684?v=3","gravatar_id":"","url":"https://api.github.com/users/sportngin","html_url":"https://github.com/sportngin","followers_url":"https://api.github.com/users/sportngin/followers","following_url":"https://api.github.com/users/sportngin/following{/other_user}","gists_url":"https://api.github.com/users/sportngin/gists{/gist_id}","starred_url":"https://api.github.com/users/sportngin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sportngin/subscriptions","organizations_url":"https://api.github.com/users/sportngin/orgs","repos_url":"https://api.github.com/users/sportngin/repos","events_url":"https://api.github.com/users/sportngin/events{/privacy}","received_events_url":"https://api.github.com/users/sportngin/received_events","type":"Organization","site_admin":false},"repo":{"id":14806020,"name":"opsicle","full_name":"sportngin/opsicle","owner":{"login":"sportngin","id":3728684,"avatar_url":"https://avatars.githubusercontent.com/u/3728684?v=3","gravatar_id":"","url":"https://api.github.com/users/sportngin","html_url":"https://github.com/sportngin","followers_url":"https://api.github.com/users/sportngin/followers","following_url":"https://api.github.com/users/sportngin/following{/other_user}","gists_url":"https://api.github.com/users/sportngin/gists{/gist_id}","starred_url":"https://api.github.com/users/sportngin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sportngin/subscriptions","organizations_url":"https://api.github.com/users/sportngin/orgs","repos_url":"https://api.github.com/users/sportngin/repos","events_url":"https://api.github.com/users/sportngin/events{/privacy}","received_events_url":"https://api.github.com/users/sportngin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sportngin/opsicle","description":"","fork":false,"url":"https://api.github.com/repos/sportngin/opsicle","forks_url":"https://api.github.com/repos/sportngin/opsicle/forks","keys_url":"https://api.github.com/repos/sportngin/opsicle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sportngin/opsicle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sportngin/opsicle/teams","hooks_url":"https://api.github.com/repos/sportngin/opsicle/hooks","issue_events_url":"https://api.github.com/repos/sportngin/opsicle/issues/events{/number}","events_url":"https://api.github.com/repos/sportngin/opsicle/events","assignees_url":"https://api.github.com/repos/sportngin/opsicle/assignees{/user}","branches_url":"https://api.github.com/repos/sportngin/opsicle/branches{/branch}","tags_url":"https://api.github.com/repos/sportngin/opsicle/tags","blobs_url":"https://api.github.com/repos/sportngin/opsicle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sportngin/opsicle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sportngin/opsicle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sportngin/opsicle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sportngin/opsicle/statuses/{sha}","languages_url":"https://api.github.com/repos/sportngin/opsicle/languages","stargazers_url":"https://api.github.com/repos/sportngin/opsicle/stargazers","contributors_url":"https://api.github.com/repos/sportngin/opsicle/contributors","subscribers_url":"https://api.github.com/repos/sportngin/opsicle/subscribers","subscription_url":"https://api.github.com/repos/sportngin/opsicle/subscription","commits_url":"https://api.github.com/repos/sportngin/opsicle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sportngin/opsicle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sportngin/opsicle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sportngin/opsicle/issues/comments/{number}","contents_url":"https://api.github.com/repos/sportngin/opsicle/contents/{+path}","compare_url":"https://api.github.com/repos/sportngin/opsicle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sportngin/opsicle/merges","archive_url":"https://api.github.com/repos/sportngin/opsicle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sportngin/opsicle/downloads","issues_url":"https://api.github.com/repos/sportngin/opsicle/issues{/number}","pulls_url":"https://api.github.com/repos/sportngin/opsicle/pulls{/number}","milestones_url":"https://api.github.com/repos/sportngin/opsicle/milestones{/number}","notifications_url":"https://api.github.com/repos/sportngin/opsicle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sportngin/opsicle/labels{/name}","releases_url":"https://api.github.com/repos/sportngin/opsicle/releases{/id}","created_at":"2013-11-29T16:34:07Z","updated_at":"2015-01-06T21:10:13Z","pushed_at":"2015-01-22T02:53:42Z","git_url":"git://github.com/sportngin/opsicle.git","ssh_url":"git@github.com:sportngin/opsicle.git","clone_url":"https://github.com/sportngin/opsicle.git","svn_url":"https://github.com/sportngin/opsicle","homepage":null,"size":1366,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":7,"default_branch":"master"}},"base":{"label":"sportngin:master","ref":"master","sha":"c37944e71a96a3d1cc8f59a5b0864b468a5b31e1","user":{"login":"sportngin","id":3728684,"avatar_url":"https://avatars.githubusercontent.com/u/3728684?v=3","gravatar_id":"","url":"https://api.github.com/users/sportngin","html_url":"https://github.com/sportngin","followers_url":"https://api.github.com/users/sportngin/followers","following_url":"https://api.github.com/users/sportngin/following{/other_user}","gists_url":"https://api.github.com/users/sportngin/gists{/gist_id}","starred_url":"https://api.github.com/users/sportngin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sportngin/subscriptions","organizations_url":"https://api.github.com/users/sportngin/orgs","repos_url":"https://api.github.com/users/sportngin/repos","events_url":"https://api.github.com/users/sportngin/events{/privacy}","received_events_url":"https://api.github.com/users/sportngin/received_events","type":"Organization","site_admin":false},"repo":{"id":14806020,"name":"opsicle","full_name":"sportngin/opsicle","owner":{"login":"sportngin","id":3728684,"avatar_url":"https://avatars.githubusercontent.com/u/3728684?v=3","gravatar_id":"","url":"https://api.github.com/users/sportngin","html_url":"https://github.com/sportngin","followers_url":"https://api.github.com/users/sportngin/followers","following_url":"https://api.github.com/users/sportngin/following{/other_user}","gists_url":"https://api.github.com/users/sportngin/gists{/gist_id}","starred_url":"https://api.github.com/users/sportngin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sportngin/subscriptions","organizations_url":"https://api.github.com/users/sportngin/orgs","repos_url":"https://api.github.com/users/sportngin/repos","events_url":"https://api.github.com/users/sportngin/events{/privacy}","received_events_url":"https://api.github.com/users/sportngin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sportngin/opsicle","description":"","fork":false,"url":"https://api.github.com/repos/sportngin/opsicle","forks_url":"https://api.github.com/repos/sportngin/opsicle/forks","keys_url":"https://api.github.com/repos/sportngin/opsicle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sportngin/opsicle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sportngin/opsicle/teams","hooks_url":"https://api.github.com/repos/sportngin/opsicle/hooks","issue_events_url":"https://api.github.com/repos/sportngin/opsicle/issues/events{/number}","events_url":"https://api.github.com/repos/sportngin/opsicle/events","assignees_url":"https://api.github.com/repos/sportngin/opsicle/assignees{/user}","branches_url":"https://api.github.com/repos/sportngin/opsicle/branches{/branch}","tags_url":"https://api.github.com/repos/sportngin/opsicle/tags","blobs_url":"https://api.github.com/repos/sportngin/opsicle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sportngin/opsicle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sportngin/opsicle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sportngin/opsicle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sportngin/opsicle/statuses/{sha}","languages_url":"https://api.github.com/repos/sportngin/opsicle/languages","stargazers_url":"https://api.github.com/repos/sportngin/opsicle/stargazers","contributors_url":"https://api.github.com/repos/sportngin/opsicle/contributors","subscribers_url":"https://api.github.com/repos/sportngin/opsicle/subscribers","subscription_url":"https://api.github.com/repos/sportngin/opsicle/subscription","commits_url":"https://api.github.com/repos/sportngin/opsicle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sportngin/opsicle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sportngin/opsicle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sportngin/opsicle/issues/comments/{number}","contents_url":"https://api.github.com/repos/sportngin/opsicle/contents/{+path}","compare_url":"https://api.github.com/repos/sportngin/opsicle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sportngin/opsicle/merges","archive_url":"https://api.github.com/repos/sportngin/opsicle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sportngin/opsicle/downloads","issues_url":"https://api.github.com/repos/sportngin/opsicle/issues{/number}","pulls_url":"https://api.github.com/repos/sportngin/opsicle/pulls{/number}","milestones_url":"https://api.github.com/repos/sportngin/opsicle/milestones{/number}","notifications_url":"https://api.github.com/repos/sportngin/opsicle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sportngin/opsicle/labels{/name}","releases_url":"https://api.github.com/repos/sportngin/opsicle/releases{/id}","created_at":"2013-11-29T16:34:07Z","updated_at":"2015-01-06T21:10:13Z","pushed_at":"2015-01-22T02:53:42Z","git_url":"git://github.com/sportngin/opsicle.git","ssh_url":"git@github.com:sportngin/opsicle.git","clone_url":"https://github.com/sportngin/opsicle.git","svn_url":"https://github.com/sportngin/opsicle","homepage":null,"size":1366,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sportngin/opsicle/pulls/73"},"html":{"href":"https://github.com/sportngin/opsicle/pull/73"},"issue":{"href":"https://api.github.com/repos/sportngin/opsicle/issues/73"},"comments":{"href":"https://api.github.com/repos/sportngin/opsicle/issues/73/comments"},"review_comments":{"href":"https://api.github.com/repos/sportngin/opsicle/pulls/73/comments"},"review_comment":{"href":"https://api.github.com/repos/sportngin/opsicle/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sportngin/opsicle/pulls/73/commits"},"statuses":{"href":"https://api.github.com/repos/sportngin/opsicle/statuses/05b2bbe5e334264504d879576653e1f765eef95c"}}}}