Skip to content

Instantly share code, notes, and snippets.

@mtmtcode
Created March 3, 2021 09:36
Show Gist options
  • Save mtmtcode/05c248bb44578dcd153b424c9cbcbd82 to your computer and use it in GitHub Desktop.
Save mtmtcode/05c248bb44578dcd153b424c9cbcbd82 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
####
#
# peco-awslogs
#
# awslogs getのラッパー。
# AWSのロググループをpecoで絞って取得する。
#
# original: https://qiita.com/hiroga/items/2a9a4673f60aca7cc48f
set -eo pipefail
AWSLOGS_OPTIONS="$@"
COMMAND=$1
while [[ $# -gt 0 ]]; do
case "$1" in
--profile)
AWS_PROFILE=$2
shift 2
;;
*)
shift 1
;;
esac
done
if [[ -z ${AWS_PROFILE} ]]; then
AWS_PROFILE_OPTION=""
else
AWS_PROFILE_OPTION="--profile $AWS_PROFILE"
fi
GROUP=$(awslogs groups ${AWS_PROFILE_OPTION} | peco)
if [[ ${GROUP} = "" ]]; then
exit
fi
awslogs get ${GROUP} ${AWSLOGS_OPTIONS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment