Skip to content

Instantly share code, notes, and snippets.

@sasasin
Created March 8, 2023 12:14
Show Gist options
  • Save sasasin/1692c853d26cd66aa631c2b454734b10 to your computer and use it in GitHub Desktop.
Save sasasin/1692c853d26cd66aa631c2b454734b10 to your computer and use it in GitHub Desktop.
AWS CloudWatch Synthetics Canary のソースコードのzipをダウンロードして解凍するやつ
#!/bin/bash
CANARY_NAME="$1"
CANARY_SOURCE_LOCATION_ARN=$( \
aws synthetics get-canary \
--name "${CANARY_NAME}" \
--query 'Canary.Code.SourceLocationArn' \
--output text \
)
aws lambda get-layer-version-by-arn \
--arn ${CANARY_SOURCE_LOCATION_ARN} \
--query 'Content.Location' \
| xargs wget -O "${CANARY_NAME}".zip
unzip -d "${CANARY_NAME}" "${CANARY_NAME}.zip"
@sasasin
Copy link
Author

sasasin commented Mar 8, 2023

aws synthetics describe-canaries \
| jq -r '.Canaries[].Name' \
| sort \
| xargs -L1 ./get-canary-source-code.sh 

などとして使うとガバッと取れる

@sasasin
Copy link
Author

sasasin commented Mar 8, 2023

Canary でアクセスしてるURLは

rg 'http' | sed -e 's/ /\n/g' -e 's/\[//g' -e 's/\]//g' -e 's/\'//g' -e 's/;//g' | grep http | sort -u

と出せる

@sasasin
Copy link
Author

sasasin commented Mar 8, 2023

(ひどいsedだ、突貫にしても、もっとマシにできるはずだ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment