{"action":"created","comment":{"url":"https://api.github.com/repos/weaveworks/integrations/pulls/comments/41773643","id":41773643,"diff_hunk":"@@ -2,29 +2,221 @@\n # This script print a list of IPs of the EC2 instances in your current Autoscaling Group.\n set -eu\n \n-aws=/usr/local/bin/aws\n+__instance_tag_key=\"${1:-WEAVE_ECS}\"\n \n-export AWS_DEFAULT_REGION=$(curl -s curl http://169.254.169.254/latest/dynamic/instance-identity/document | \\\n-                            jq -r .region)\n-current_instance_id=$(curl -s curl http://169.254.169.254/latest/meta-data/instance-id)\n-current_autoscaling_group=$($aws autoscaling describe-auto-scaling-instances | \\\n-                            jq -r \".AutoScalingInstances[] | select(.InstanceId == \\\"$current_instance_id\\\") | .AutoScalingGroupName\")\n+__awscli=\n+__instance_id=\n+__region=\n+__instance_autoscaling_group=\n+__peer_autoscaling_instance_ids=\n+__list_of_active_spot_fleets=\n+__spot_fleet_request_id=\n+__spot_fleet_peer_instance_ids=\n+__peer_private_ips=\n+__peer_tag_instance_ids=\n \n-if [ -z \"$current_autoscaling_group\" ]; then\n-  >&2 echo \"instance doesn't belong to an autoscaling group\"\n-  exit 1\n-fi\n+check_data() {\n+  if [[ \"${1}x\" == \"x\" ]]; then\n+    return 1\n+  fi\n+}\n \n-peer_instances=$($aws autoscaling describe-auto-scaling-instances | \\\n-                jq -r \".AutoScalingInstances[] | select(.AutoScalingGroupName == \\\"$current_autoscaling_group\\\" and .InstanceId != \\\"$current_instance_id\\\") | .InstanceId\")\n+check_exit() {\n+  if [[ \"${1}\" != \"0\" ]]; then\n+    >&2 echo \"${FUNCNAME[1]} Exited with a nonzero status\"\n+    exit 2\n+  fi\n+}\n \n-if [ -z \"$peer_instances\" ]; then\n-# no peers found\n-  exit 0\n-fi\n+get_from_curl() {\n+  local __endpoint=\"${1}\"\n+  local __retry_attempts=3\n+  local __retry_delay=1\n+  local __retries=0\n+  local __retval=\n+  # the metadata service occasionally returns empty with a 200 status, so retry a couple times just in case (very rare)\n+  while true; do\n+    local __retval=$(curl -s \"http://169.254.169.254/latest/${__endpoint}\")\n+    if [[ \"${__retval}x\" != \"x\" ]]; then","path":"aws/ecs/packer/to-upload/peers.sh","position":60,"original_position":55,"commit_id":"dbb019459d1640973433036809ea993f7a747026","original_commit_id":"a3a2754e3918f5271a06a0ccb8b710a1d2e6f59b","user":{"login":"2opremio","id":2362916,"avatar_url":"https://avatars.githubusercontent.com/u/2362916?v=3","gravatar_id":"","url":"https://api.github.com/users/2opremio","html_url":"https://github.com/2opremio","followers_url":"https://api.github.com/users/2opremio/followers","following_url":"https://api.github.com/users/2opremio/following{/other_user}","gists_url":"https://api.github.com/users/2opremio/gists{/gist_id}","starred_url":"https://api.github.com/users/2opremio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2opremio/subscriptions","organizations_url":"https://api.github.com/users/2opremio/orgs","repos_url":"https://api.github.com/users/2opremio/repos","events_url":"https://api.github.com/users/2opremio/events{/privacy}","received_events_url":"https://api.github.com/users/2opremio/received_events","type":"User","site_admin":false},"body":"Isn't this the same as `if ! check_data \"${__retval}\"; then` ?","created_at":"2015-10-12T16:19:21Z","updated_at":"2015-10-12T16:19:21Z","html_url":"https://github.com/weaveworks/integrations/pull/26#discussion_r41773643","pull_request_url":"https://api.github.com/repos/weaveworks/integrations/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/weaveworks/integrations/pulls/comments/41773643"},"html":{"href":"https://github.com/weaveworks/integrations/pull/26#discussion_r41773643"},"pull_request":{"href":"https://api.github.com/repos/weaveworks/integrations/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/weaveworks/integrations/pulls/26","id":47374614,"html_url":"https://github.com/weaveworks/integrations/pull/26","diff_url":"https://github.com/weaveworks/integrations/pull/26.diff","patch_url":"https://github.com/weaveworks/integrations/pull/26.patch","issue_url":"https://api.github.com/repos/weaveworks/integrations/issues/26","number":26,"state":"open","locked":false,"title":"Update peers.sh to support spot fleets and tags","user":{"login":"randywallace","id":815389,"avatar_url":"https://avatars.githubusercontent.com/u/815389?v=3","gravatar_id":"","url":"https://api.github.com/users/randywallace","html_url":"https://github.com/randywallace","followers_url":"https://api.github.com/users/randywallace/followers","following_url":"https://api.github.com/users/randywallace/following{/other_user}","gists_url":"https://api.github.com/users/randywallace/gists{/gist_id}","starred_url":"https://api.github.com/users/randywallace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randywallace/subscriptions","organizations_url":"https://api.github.com/users/randywallace/orgs","repos_url":"https://api.github.com/users/randywallace/repos","events_url":"https://api.github.com/users/randywallace/events{/privacy}","received_events_url":"https://api.github.com/users/randywallace/received_events","type":"User","site_admin":false},"body":"Reference issue: weaveworks/integrations#1","created_at":"2015-10-11T20:24:57Z","updated_at":"2015-10-12T16:19:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28a2a3f5d61e61b3d0bc05f336759f5802abb5e3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/weaveworks/integrations/pulls/26/commits","review_comments_url":"https://api.github.com/repos/weaveworks/integrations/pulls/26/comments","review_comment_url":"https://api.github.com/repos/weaveworks/integrations/pulls/comments{/number}","comments_url":"https://api.github.com/repos/weaveworks/integrations/issues/26/comments","statuses_url":"https://api.github.com/repos/weaveworks/integrations/statuses/dbb019459d1640973433036809ea993f7a747026","head":{"label":"randywallace:topic-spot-fleet","ref":"topic-spot-fleet","sha":"dbb019459d1640973433036809ea993f7a747026","user":{"login":"randywallace","id":815389,"avatar_url":"https://avatars.githubusercontent.com/u/815389?v=3","gravatar_id":"","url":"https://api.github.com/users/randywallace","html_url":"https://github.com/randywallace","followers_url":"https://api.github.com/users/randywallace/followers","following_url":"https://api.github.com/users/randywallace/following{/other_user}","gists_url":"https://api.github.com/users/randywallace/gists{/gist_id}","starred_url":"https://api.github.com/users/randywallace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randywallace/subscriptions","organizations_url":"https://api.github.com/users/randywallace/orgs","repos_url":"https://api.github.com/users/randywallace/repos","events_url":"https://api.github.com/users/randywallace/events{/privacy}","received_events_url":"https://api.github.com/users/randywallace/received_events","type":"User","site_admin":false},"repo":{"id":43997373,"name":"integrations","full_name":"randywallace/integrations","owner":{"login":"randywallace","id":815389,"avatar_url":"https://avatars.githubusercontent.com/u/815389?v=3","gravatar_id":"","url":"https://api.github.com/users/randywallace","html_url":"https://github.com/randywallace","followers_url":"https://api.github.com/users/randywallace/followers","following_url":"https://api.github.com/users/randywallace/following{/other_user}","gists_url":"https://api.github.com/users/randywallace/gists{/gist_id}","starred_url":"https://api.github.com/users/randywallace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/randywallace/subscriptions","organizations_url":"https://api.github.com/users/randywallace/orgs","repos_url":"https://api.github.com/users/randywallace/repos","events_url":"https://api.github.com/users/randywallace/events{/privacy}","received_events_url":"https://api.github.com/users/randywallace/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/randywallace/integrations","description":"","fork":true,"url":"https://api.github.com/repos/randywallace/integrations","forks_url":"https://api.github.com/repos/randywallace/integrations/forks","keys_url":"https://api.github.com/repos/randywallace/integrations/keys{/key_id}","collaborators_url":"https://api.github.com/repos/randywallace/integrations/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/randywallace/integrations/teams","hooks_url":"https://api.github.com/repos/randywallace/integrations/hooks","issue_events_url":"https://api.github.com/repos/randywallace/integrations/issues/events{/number}","events_url":"https://api.github.com/repos/randywallace/integrations/events","assignees_url":"https://api.github.com/repos/randywallace/integrations/assignees{/user}","branches_url":"https://api.github.com/repos/randywallace/integrations/branches{/branch}","tags_url":"https://api.github.com/repos/randywallace/integrations/tags","blobs_url":"https://api.github.com/repos/randywallace/integrations/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/randywallace/integrations/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/randywallace/integrations/git/refs{/sha}","trees_url":"https://api.github.com/repos/randywallace/integrations/git/trees{/sha}","statuses_url":"https://api.github.com/repos/randywallace/integrations/statuses/{sha}","languages_url":"https://api.github.com/repos/randywallace/integrations/languages","stargazers_url":"https://api.github.com/repos/randywallace/integrations/stargazers","contributors_url":"https://api.github.com/repos/randywallace/integrations/contributors","subscribers_url":"https://api.github.com/repos/randywallace/integrations/subscribers","subscription_url":"https://api.github.com/repos/randywallace/integrations/subscription","commits_url":"https://api.github.com/repos/randywallace/integrations/commits{/sha}","git_commits_url":"https://api.github.com/repos/randywallace/integrations/git/commits{/sha}","comments_url":"https://api.github.com/repos/randywallace/integrations/comments{/number}","issue_comment_url":"https://api.github.com/repos/randywallace/integrations/issues/comments{/number}","contents_url":"https://api.github.com/repos/randywallace/integrations/contents/{+path}","compare_url":"https://api.github.com/repos/randywallace/integrations/compare/{base}...{head}","merges_url":"https://api.github.com/repos/randywallace/integrations/merges","archive_url":"https://api.github.com/repos/randywallace/integrations/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/randywallace/integrations/downloads","issues_url":"https://api.github.com/repos/randywallace/integrations/issues{/number}","pulls_url":"https://api.github.com/repos/randywallace/integrations/pulls{/number}","milestones_url":"https://api.github.com/repos/randywallace/integrations/milestones{/number}","notifications_url":"https://api.github.com/repos/randywallace/integrations/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/randywallace/integrations/labels{/name}","releases_url":"https://api.github.com/repos/randywallace/integrations/releases{/id}","created_at":"2015-10-10T06:21:58Z","updated_at":"2015-10-10T06:21:59Z","pushed_at":"2015-10-12T16:08:50Z","git_url":"git://github.com/randywallace/integrations.git","ssh_url":"git@github.com:randywallace/integrations.git","clone_url":"https://github.com/randywallace/integrations.git","svn_url":"https://github.com/randywallace/integrations","homepage":null,"size":352,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"weaveworks:master","ref":"master","sha":"24fca62e794ec9693068932f450f07ffa4cc2945","user":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"repo":{"id":43001547,"name":"integrations","full_name":"weaveworks/integrations","owner":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/weaveworks/integrations","description":"Weave Third-Party Integrations","fork":false,"url":"https://api.github.com/repos/weaveworks/integrations","forks_url":"https://api.github.com/repos/weaveworks/integrations/forks","keys_url":"https://api.github.com/repos/weaveworks/integrations/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weaveworks/integrations/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weaveworks/integrations/teams","hooks_url":"https://api.github.com/repos/weaveworks/integrations/hooks","issue_events_url":"https://api.github.com/repos/weaveworks/integrations/issues/events{/number}","events_url":"https://api.github.com/repos/weaveworks/integrations/events","assignees_url":"https://api.github.com/repos/weaveworks/integrations/assignees{/user}","branches_url":"https://api.github.com/repos/weaveworks/integrations/branches{/branch}","tags_url":"https://api.github.com/repos/weaveworks/integrations/tags","blobs_url":"https://api.github.com/repos/weaveworks/integrations/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weaveworks/integrations/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weaveworks/integrations/git/refs{/sha}","trees_url":"https://api.github.com/repos/weaveworks/integrations/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weaveworks/integrations/statuses/{sha}","languages_url":"https://api.github.com/repos/weaveworks/integrations/languages","stargazers_url":"https://api.github.com/repos/weaveworks/integrations/stargazers","contributors_url":"https://api.github.com/repos/weaveworks/integrations/contributors","subscribers_url":"https://api.github.com/repos/weaveworks/integrations/subscribers","subscription_url":"https://api.github.com/repos/weaveworks/integrations/subscription","commits_url":"https://api.github.com/repos/weaveworks/integrations/commits{/sha}","git_commits_url":"https://api.github.com/repos/weaveworks/integrations/git/commits{/sha}","comments_url":"https://api.github.com/repos/weaveworks/integrations/comments{/number}","issue_comment_url":"https://api.github.com/repos/weaveworks/integrations/issues/comments{/number}","contents_url":"https://api.github.com/repos/weaveworks/integrations/contents/{+path}","compare_url":"https://api.github.com/repos/weaveworks/integrations/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weaveworks/integrations/merges","archive_url":"https://api.github.com/repos/weaveworks/integrations/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weaveworks/integrations/downloads","issues_url":"https://api.github.com/repos/weaveworks/integrations/issues{/number}","pulls_url":"https://api.github.com/repos/weaveworks/integrations/pulls{/number}","milestones_url":"https://api.github.com/repos/weaveworks/integrations/milestones{/number}","notifications_url":"https://api.github.com/repos/weaveworks/integrations/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weaveworks/integrations/labels{/name}","releases_url":"https://api.github.com/repos/weaveworks/integrations/releases{/id}","created_at":"2015-09-23T13:09:46Z","updated_at":"2015-10-12T15:16:42Z","pushed_at":"2015-10-12T16:08:52Z","git_url":"git://github.com/weaveworks/integrations.git","ssh_url":"git@github.com:weaveworks/integrations.git","clone_url":"https://github.com/weaveworks/integrations.git","svn_url":"https://github.com/weaveworks/integrations","homepage":"","size":352,"stargazers_count":1,"watchers_count":1,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":9,"forks":2,"open_issues":9,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/weaveworks/integrations/pulls/26"},"html":{"href":"https://github.com/weaveworks/integrations/pull/26"},"issue":{"href":"https://api.github.com/repos/weaveworks/integrations/issues/26"},"comments":{"href":"https://api.github.com/repos/weaveworks/integrations/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/weaveworks/integrations/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/weaveworks/integrations/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/weaveworks/integrations/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/weaveworks/integrations/statuses/dbb019459d1640973433036809ea993f7a747026"}}}}