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
import boto3 | |
from datetime import datetime | |
def lambda_handler(event, context): | |
# CloudWatch Metrics に付与するタイムスタンプとして使う | |
timestamp = datetime.utcnow() | |
client = boto3.client('ec2') | |
responses = [] | |
next_token = None |
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/bash | |
set -eo pipefail | |
# オライリージャパンで購入した電子書籍を、ブクログにISBN登録するやつ。 | |
# https://www.oreilly.co.jp/ebook/bookshelf をウェブブラウザで開いて、全選択 & コピーして、 | |
pbpaste \ | |
| grep ISBN \ | |
| sed -e 's| |\n|g' \ | |
| grep 978 \ | |
| sed -e 's|-||g' | |
# で出てきた ISBN コードのリストを https://booklog.jp/input に「ISBN コードでまとめて登録」 |
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/bash | |
# コンテナイメージ名っぽい文字列を抽出するやつ | |
# 組織のgitリポジトリをドサッと手元に持ってきて、リポジトリ横断でリストアップしたい | |
# ファイル形式それぞれで漁り方が異なる | |
# フィルタリングが不完全で、コンテナ名ではないものが残ることがあるし、コンテナ名が除外されてることもある(かもしれない) | |
# rg は ripgrep | |
# rg --type xxxx が指す拡張子の調べ方は rg --list-type | grep xxxx で出る | |
# 詳しくは https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md を参照 |
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/bash -e | |
set -o pipefail | |
# AWS Amplify Hosting の任意の年月日のアクセスログをダウンロードしてS3にアップするやつ。 | |
# 1個2個なら app id や domain name を直接指定してもいいけど、数が多いと面倒なので、 | |
# app id と domain name のリストを作って、ループで回して全部取ってくる。 | |
# このシェルスクリプトを毎日1回 cron で回せば毎日のアクセスログを取得できる。 | |
# 本音は CloudFront みたくポチポチしたらS3に勝手に出るようになってほしい。 | |
# この S3 バケットのパスにアップロードする | |
S3_BUCKET_NAME_PATH=$1 |
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/bash | |
IAM_POLICY_ARN="$1" | |
IAM_POLICY_NAME=$(echo "${IAM_POLICY_ARN}" | awk 'BEGIN{FS="/"}{print $NF}') | |
aws iam get-policy-version \ | |
--policy-arn "${IAM_POLICY_ARN}" \ | |
--version-id $(\ | |
aws iam get-policy \ |
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/bash | |
set -eo pipefail | |
# https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html | |
AWS_CLI_COMMAND=$@ | |
aws-cli-exec-with-next-token() | |
{ | |
NEXT_TOKEN="$1" | |
if [ "${NEXT_TOKEN}" == "" ]; then |
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
# 起動停止の状態を確認するやつ | |
aws synthetics describe-canaries \ | |
| jq -r '.Canaries[] | [.Name, .Status.State] | @csv' | |
# ぜんぶ起動するやつ | |
aws synthetics describe-canaries \ | |
| jq -r '.Canaries[].Name' \ | |
| sort \ | |
| xargs -L1 aws synthetics start-canary --name |
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/bash | |
CANARY_NAME="$1" | |
CANARY_SOURCE_LOCATION_ARN=$( \ | |
aws synthetics get-canary \ | |
--name "${CANARY_NAME}" \ | |
--query 'Canary.Code.SourceLocationArn' \ | |
--output text \ | |
) |
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/bash | |
set -eo pipefail | |
CODEBUILD_PROJECT_NAME="$1" | |
aws codebuild update-project \ | |
--name "${CODEBUILD_PROJECT_NAME}" \ | |
--cli-input-json file://"${CODEBUILD_PROJECT_NAME}".patch.json \ | |
> /dev/null |
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/bash | |
set -eo pipefail | |
aws codebuild list-projects \ | |
| jq -r '.projects[]' \ | |
| sort \ | |
| xargs -IXXXX -P1 aws codebuild batch-get-projects --names XXXX \ | |
| jq -r '.projects[] | [.name, .environment.image] | @csv' |