Last active
May 25, 2018 02:16
-
-
Save i2tsuki/d91e74b12248b278c16934b753251c3c to your computer and use it in GitHub Desktop.
AWS のイベントを calendar に登録するくん
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eux | |
PROFILE="mackerelng-production" | |
RESP="$(aws --profile ${PROFILE} --region "us-east-1" health describe-events --query 'events[?eventTypeCategory==`scheduledChange`]')" | |
LENGTH="$(echo ${RESP} | jq 'length')" | |
for i in $(seq 0 $(($LENGTH-1))) | |
do | |
START_TIME=$(echo ${RESP} | jq -r ".[${i}].startTime") | |
END_TIME=$(echo ${RESP} | jq -r ".[${i}].endTime") | |
# DURATION は気付かない時間に予定がはいることがあるので、 1440 固定 | |
# DURATION=$(echo $((${END_TIME} - ${START_TIME}))) | |
DURATION=1440 | |
START_TIME=$(date -d "@${START_TIME}" +"%d/%m/%y %H:%M") | |
END_TIME=$(date -d "@${END_TIME}" +"%d/%m/%y %H:%M") | |
EVENT_NAME=$(echo ${RESP} | jq -r ".[${i}].eventTypeCode") | |
ARN=$(echo ${RESP} | jq -r ".[${i}].arn") | |
gcalcli add --calendar 'システムプラットフォーム部' --title "${PROFILE}-${EVENT_NAME}" --where "" --when "${START_TIME}" --duration "${DURATION}" --description ${ARN} --reminder "0m" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment