0

I made these two:

aws_ecs_list_services(){
  cluster=${1:-xxxx}
taskarn=$(aws ecs list-services --cluster  $cluster  | grep "arn" | tr -d '"'|  cut -d':' -f6 | cut -d'/' -f3 | tr -d ',')
echo  $taskarn;
  
}

aws_describe_services(){
cluster=${1:-xxx}
  aws_ecs_list_services $cluster | xargs -n 1 -t aws ecs describe-services  --cluster $cluster  --query 'services[*].events[0]' --output table --services 
}

bash function to query the services in my AWS cluster and check the status of the services.

I get a nice glance of what is going on, problem is that the event date is in EPOCH time (for example: 1668770177.526)

I can manually convert it

using this other function:

convert_timestamp_to_date(){
  time_stamp_to_date=$(date -r $1)
  echo $time_stamp_to_date
  export tim
}

but I first have to multiply for 1000 and then run

convert_timestamp_to_date 1668770177526

Wonder if there is a way of refactoring the aws api call to have the event formatted as human readable.

bruvio
  • 853
  • 1
  • 9
  • 30
  • Have you tested `aws configure set cli_timestamp_format iso8601`? – β.εηοιτ.βε Nov 18 '22 at 11:54
  • Also according to [this](https://spin.atomicobject.com/2021/11/03/fix-incorrect-aws-cli-timestamp/), the epoch is the format for cli v1, while iso is the default for cli v2. Maybe it is time to upgrade to cli v2? – β.εηοιτ.βε Nov 18 '22 at 11:55
  • good shout on cli v1... I had both installed (v2 system wide, v1 in virtual env) and v1 was taking precedence. now dates are in iso format – bruvio Nov 18 '22 at 14:09

0 Answers0