mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-12 09:24:24 -05:00
43076e96a6
Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> Co-authored-by: Otto Bittner <cobittner@posteo.net>
45 lines
1.2 KiB
Bash
Executable File
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
|