constellation/.github/actions/constellation_create/aws-logs.sh
Moritz Sanft 43076e96a6
ci: fix resource selection for serial log downloading (#2101)
Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
Co-authored-by: Otto Bittner <cobittner@posteo.net>
2023-07-13 16:28:33 +02:00

45 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Usage: ./aws-logs.sh <region>
set -euo pipefail
shopt -s inherit_errexit
echo "Using AWS region: ${1}"
echo "Using Constellation UID: ${2}"
controlInstances=$(
aws ec2 describe-instances \
--filters "Name=tag:constellation-uid,Values=${2}" "Name=tag:constellation-role,Values=control-plane" \
--region "${1}" \
--no-paginate \
--output json |
yq eval '.Reservations[].Instances[].InstanceId' -
)
workerInstances=$(
aws ec2 describe-instances \
--filters "Name=tag:constellation-uid,Values=${2}" "Name=tag:constellation-role,Values=worker" \
--region "${1}" \
--no-paginate \
--output json |
yq eval '.Reservations[].Instances[].InstanceId' -
)
echo "Fetching logs from control planes"
for instance in ${controlInstances}; do
printf "Fetching for %s\n" "${instance}"
aws ec2 get-console-output --region "${1}" --instance-id "${instance}" |
jq -r .'Output' |
tail -n +2 > control-plane-"${instance}".log
done
echo "Fetching logs from worker nodes"
for instance in ${workerInstances}; do
printf "Fetching for %s\n" "${instance}"
aws ec2 get-console-output --region "${1}" --instance-id "${instance}" |
jq -r .'Output' |
tail -n +2 > worker-"${instance}".log
done