<commit_before>#!/bin/bash
# This script print a list of IPs of the EC2 instances in your current Autoscaling Group.
set -eu

aws=/usr/local/bin/aws

export AWS_DEFAULT_REGION=$(curl -s curl http://169.254.169.254/latest/dynamic/instance-identity/document | \
                            jq -r .region)
current_instance_id=$(curl -s curl http://169.254.169.254/latest/meta-data/instance-id)
current_autoscaling_group=$(aws autoscaling describe-auto-scaling-instances | \
                            jq -r ".AutoScalingInstances[] | select(.InstanceId == \"$current_instance_id\") | .AutoScalingGroupName")

if [ -z "$current_autoscaling_group" ]; then
  # Instance doesn't belong to an autoscaling group
  exit 1
fi

peer_instances=$($aws autoscaling describe-auto-scaling-instances | \
                jq -r ".AutoScalingInstances[] | select(.AutoScalingGroupName == \"$current_autoscaling_group\" and .InstanceId != \"$current_instance_id\") | .InstanceId")
<commit_msg>[aws-ecs] Log error when instance doesn't belong to autoscaling group<commit_after>#!/bin/bash
# This script print a list of IPs of the EC2 instances in your current Autoscaling Group.
set -eu

aws=/usr/local/bin/aws

export AWS_DEFAULT_REGION=$(curl -s curl http://169.254.169.254/latest/dynamic/instance-identity/document | \
                            jq -r .region)
current_instance_id=$(curl -s curl http://169.254.169.254/latest/meta-data/instance-id)
current_autoscaling_group=$(aws autoscaling describe-auto-scaling-instances | \
                            jq -r ".AutoScalingInstances[] | select(.InstanceId == \"$current_instance_id\") | .AutoScalingGroupName")

if [ -z "$current_autoscaling_group" ]; then
  echo "instance doesn't belong to an autoscaling group" | logger -p local0.error  -t weave/peers.sh -s
  exit 1
fi

peer_instances=$($aws autoscaling describe-auto-scaling-instances | \
                jq -r ".AutoScalingInstances[] | select(.AutoScalingGroupName == \"$current_autoscaling_group\" and .InstanceId != \"$current_instance_id\") | .InstanceId")

{'fraction_non_alphanumeric': 0.1276803118908382, 'fraction_numerical': 0.025828460038986353, 'mean_word_length': 3.3961456102783725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2865993', 'n_tokens_mistral': 700, 'n_tokens_neox': 623, 'n_words': 150}