付録: 構築で使ったコマンド早見表
本シリーズで使用したコマンドを、ツール別にまとめた早見表です。手元のリファレンスとして使ってください。
1. Git / GitHub
初期設定
git config --global user.name "<your-name>"
git config --global user.email "<your-email@example.com>"
git config --global init.defaultBranch main
git config --global core.autocrlf true # Windows なら true、Mac/Linux は input
新規リポジトリ作成
git init -b main # main ブランチで初期化
git status # 状態確認
git status -s # short 表記
git add . # 全変更を staging
git add <file> # 特定ファイルだけ staging
git commit -m "メッセージ"
git log --oneline -10 # 直近 10 件
git log --graph --oneline --all # ブランチグラフで表示
リモート操作
git remote -v # リモート確認
git remote add origin <URL>
git push -u origin main # 初回 push(upstream 設定)
git push # 通常 push
git pull
git fetch # 取得のみ(merge しない)
ブランチ操作
git branch # ブランチ一覧
git checkout -b feature/x # 新規ブランチ作成 + 切替
git switch main # 既存ブランチへ切替(新しい構文)
git merge feature/x
git rebase main
diff / blame
git diff # 未 commit の変更
git diff --staged # staging 済の変更
git diff main..feature/x # ブランチ間の diff
git blame <file> # 行ごとの commit 履歴
取り消し
git restore <file> # 未 staging の変更を取消
git restore --staged <file> # staging を取消
git reset --soft HEAD^ # 直前 commit 取消(変更は残す)
git reset --hard HEAD^ # 直前 commit + 変更も取消(危険)
gh CLI
gh auth login # 認証
gh auth status # 状態確認
gh repo create <name> --private --source=. --remote=origin --push
gh repo view <owner>/<repo>
gh repo list
gh run list --limit 5
gh run view <run-id> --log
gh run watch <run-id> --interval 5 --exit-status
gh pr create --title "..." --body "..."
gh pr list
2. AWS CLI
プロファイル管理
aws configure --profile aws-prod
aws configure list-profiles
export AWS_PROFILE=aws-prod # bash
$env:AWS_PROFILE = "aws-prod" # PowerShell
aws sts get-caller-identity # ★ プロファイル切替後に必ず叩く
S3
aws s3 ls # バケット一覧
aws s3 ls s3://<bucket>/ # バケット内 1 階層
aws s3 ls s3://<bucket> --recursive # 全ファイル
aws s3 cp file.txt s3://<bucket>/path/ # 単発アップロード
aws s3 sync ./dir/ s3://<bucket>/ --delete # ディレクトリ完全同期
aws s3 rm s3://<bucket>/path/file # 削除
aws s3 rm s3://<bucket> --recursive # バケット中身全削除
aws s3api head-object --bucket <bucket> --key file.txt
aws s3api get-bucket-versioning --bucket <bucket>
aws s3api put-bucket-versioning --bucket <bucket> --versioning-configuration Status=Enabled
DynamoDB
aws dynamodb list-tables --region ap-northeast-1
aws dynamodb describe-table --table-name <table>
aws dynamodb scan --table-name <table> --max-items 10
aws dynamodb scan --table-name <table> --select COUNT
aws dynamodb get-item --table-name <table> --key '{"id":{"S":"<UUID>"}}'
aws dynamodb put-item --table-name <table> --item '{"id":{"S":"a"},"name":{"S":"x"}}'
aws dynamodb delete-table --table-name <table> --region ap-northeast-1
Lambda
aws lambda list-functions --region ap-northeast-1
aws lambda get-function-configuration --function-name <name>
aws lambda invoke --function-name <name> --payload '{"x":1}' out.json
aws lambda update-function-code --function-name <name> --zip-file fileb://function.zip
CloudWatch Logs
# Git Bash の場合: MSYS_NO_PATHCONV=1 を立てる
export MSYS_NO_PATHCONV=1
aws logs describe-log-groups --query 'logGroups[].logGroupName'
aws logs tail /aws/lambda/<name> --since 30m --follow
aws logs filter-log-events --log-group-name /aws/lambda/<name> --filter-pattern 'ERROR'
CloudFront
aws cloudfront list-distributions
aws cloudfront get-distribution --id <DISTRIBUTION_ID>
aws cloudfront create-invalidation --distribution-id <ID> --paths "/*"
aws cloudfront create-invalidation --distribution-id <ID> --paths "/index.html" "/learn.html"
aws cloudfront wait invalidation-completed --distribution-id <ID> --id <INVALIDATION_ID>
ACM
aws acm list-certificates --region us-east-1
aws acm describe-certificate --region us-east-1 --certificate-arn <ARN>
IAM
aws iam list-users
aws iam list-roles
aws iam get-role --role-name <name>
aws iam list-attached-role-policies --role-name <name>
aws iam list-access-keys --user-name <username>
aws iam create-access-key --user-name <username>
aws iam delete-access-key --user-name <username> --access-key-id <ID>
SES
aws sesv2 list-email-identities --region ap-northeast-1
aws sesv2 create-email-identity --email-identity <email> --region ap-northeast-1
aws sesv2 get-email-identity --email-identity <email> --region ap-northeast-1
aws sesv2 get-account --region ap-northeast-1 --query 'SendQuota'
CloudWatch Alarms
aws cloudwatch describe-alarms --region ap-northeast-1
aws cloudwatch describe-alarms --region us-east-1 # CloudFront 用
aws cloudwatch set-alarm-state --alarm-name <name> --state-value ALARM --state-reason "test"
aws cloudwatch put-metric-alarm ...
aws cloudwatch delete-alarms --alarm-names <name>
3. Terraform
基本コマンド
terraform version
terraform init # provider ダウンロード + backend 接続
terraform init -reconfigure # backend 設定変更時
terraform init -upgrade # provider バージョン更新
terraform fmt # フォーマット
terraform fmt -recursive # サブディレクトリも
terraform validate # 構文チェック
terraform plan # 差分確認(実行はしない)
terraform plan -input=false -no-color
terraform plan -out=tfplan # plan を保存
terraform apply # 実行
terraform apply -auto-approve # 確認スキップ
terraform apply tfplan # 保存した plan を実行
terraform apply -target=module.x # 特定リソースのみ
terraform destroy # 全削除(注意)
terraform destroy -target=module.x # 特定リソースのみ削除
state 操作
terraform state list # 管理下のリソース一覧
terraform state show <address> # 詳細表示
terraform state rm <address> # state から除外(リソースは残る)
terraform state mv <src> <dst> # state 内でリソース移動
terraform import <address> <ID> # 既存リソースを管理下に
Lock 管理
terraform force-unlock <LOCK_ID> # ロック強制解除
Output
terraform output # 全 output
terraform output <name> # 特定 output
terraform output -json # JSON 形式
terraform output -raw <name> # 値だけ(クォート無し)
Workspace
terraform workspace list
terraform workspace new dev
terraform workspace select prod
4. PowerShell
基本
Get-Location # cd 確認 (pwd)
Set-Location <path> # cd
Get-ChildItem # ls
New-Item -ItemType Directory -Path <path>
Remove-Item <path> -Recurse -Force
Copy-Item <src> <dst>
Move-Item <src> <dst>
環境変数
$env:AWS_PROFILE = "aws-prod" # 設定
$env:AWS_PROFILE # 取得
[Environment]::SetEnvironmentVariable("X","Y","User") # 永続化(User scope)
ファイル読み書き(BOM 注意)
# BOM 無し UTF-8 で書く(重要)
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($path, $content, $utf8NoBom)
# BOM 確認
$bytes = [System.IO.File]::ReadAllBytes($path)
$bytes[0..2] | ForEach-Object { '{0:X2}' -f $_ } # EF BB BF なら BOM 付き
# 読込
$content = [System.IO.File]::ReadAllText($path, [System.Text.Encoding]::UTF8)
JSON 操作
$obj | ConvertTo-Json -Compress -Depth 10
$json | ConvertFrom-Json
winget
winget search <name>
winget install --id <package-id> --accept-source-agreements --accept-package-agreements
winget list
winget upgrade
winget uninstall --id <package-id>
5. Git Bash (MINGW64)
パス変換回避
export MSYS_NO_PATHCONV=1
# またはパスを // で始める
aws logs tail //aws/lambda/my-function
環境変数
export AWS_PROFILE=aws-prod
echo $AWS_PROFILE
unset AWS_PROFILE
env | grep AWS
Windows PATH 追加
export PATH="$PATH:/c/Program Files/GitHub CLI"
6. curl
基本
curl https://example.com # GET
curl -I https://example.com # HEAD(ヘッダだけ)
curl -sI https://example.com # silent + HEAD
curl -L https://example.com # リダイレクト追跡
curl -o file.html https://example.com # ファイル保存
curl -O https://example.com/file.html # 元のファイル名で保存
POST
curl -X POST https://example.com/api/x \
-H "Content-Type: application/json" \
-d '{"name":"test"}'
# フォームデータ
curl -X POST https://example.com/form \
-d "name=test&email=a@b.com"
診断
curl -sI -w "Status: %{http_code} / Size: %{size_download} / Time: %{time_total}s\n" \
https://example.com -o /dev/null
curl -v https://example.com # 詳細ログ
curl --tlsv1.2 --tls-max 1.2 ... # TLS 1.2 強制
curl -C - -o file.zip https://... # resume ダウンロード
curl --retry 5 --retry-delay 3 ... # 自動リトライ
7. JSON 操作 (jq / 代替)
jq(インストール済の場合)
cat data.json | jq '.' # pretty print
echo '{"a":1}' | jq '.a' # 値抽出
cat data.json | jq '.items[] | .name' # 配列展開
cat data.json | jq -r '.x' # raw(クォート無し)
jq が無い時(grep + sed)
echo '{"name":"foo"}' | grep -o '"name":"[^"]*' | sed 's/"name":"//'
PowerShell で JSON
# JSON → オブジェクト
$obj = Get-Content data.json -Raw | ConvertFrom-Json
$obj.name
# オブジェクト → JSON
@{ name = "foo"; age = 30 } | ConvertTo-Json
8. Node.js / npm
基本
node --version
npm --version
node script.js # 実行
npm init -y # package.json 作成
npm install # 依存インストール
npm install <package> # 追加
npm install -D <package> # 開発依存
npm uninstall <package>
npm run <script> # package.json の scripts 実行
Lambda zip 作成
cd backend/functions/contact
zip -r ../../../function.zip index.mjs node_modules/
# Terraform の archive_file data source を使うのが楽
9. ファイル・diff・grep
# 検索
grep -r "pattern" . # 再帰
grep -ri "pattern" . --include="*.tf" # ファイル種別指定
grep -v "pattern" file # 除外
grep -c "pattern" file # マッチ数
# ファイル操作
find . -type f -name "*.tf" # ファイル検索
find . -type d -name "node_modules" -prune # 除外
wc -l file # 行数
# diff
diff file1 file2
diff -r dir1 dir2
# tail / head
head -20 file
tail -20 file
tail -f log.txt # リアルタイム監視
10. ネットワーク診断
# DNS
nslookup example.com
nslookup -type=CNAME lab.iigtn.com 8.8.8.8
nslookup -type=MX iigtn.com
nslookup -type=NS iigtn.com
# 疎通
ping -c 4 example.com # bash
ping example.com # PowerShell(無限)
ping -n 4 example.com # PowerShell の回数指定
# ルート
tracert example.com # PowerShell
traceroute example.com # bash
11. その他のお役立ち
SHA256 ハッシュ
sha256sum file # bash
Get-FileHash -Algorithm SHA256 -Path file # PowerShell
UUID 生成
# bash (uuidgen)
uuidgen
# PowerShell
[guid]::NewGuid().ToString()
# Node.js
node -e "console.log(require('crypto').randomUUID())"
日時
date -u +"%Y-%m-%dT%H:%M:%SZ" # bash ISO 8601 UTC
Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ" # PowerShell
base64
# bash
echo "text" | base64
echo "dGV4dAo=" | base64 -d
# PowerShell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("text"))
[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("dGV4dA=="))
シリーズ完結
これで全 21 記事の構築日誌シリーズは完結です。AWS サーバレス + Terraform + GitHub Actions OIDC でポートフォリオサイトを 0 から構築するすべての過程と、ハマりどころ・学びを記録しました。
本シリーズが、これから AWS サーバレスを始める方の参考になれば嬉しいです。気付いた点・指摘・案件のご相談は 問い合わせフォーム からどうぞ。
📚 全記事一覧: Blog 目次
📚 用語集
- cheatsheet (チートシート)
- 頻出コマンド・構文を 1 ページにまとめたリファレンス。手元に置いて参照する用。
- man / --help
- コマンドのオンラインドキュメント。
command --helpやman commandで読める。 - パイプ (|)
- コマンドの出力を次のコマンドの入力に渡す。
cat file | grep pattern等。 - リダイレクト (>, >>, <)
- 標準出力をファイルに書く(
>上書き />>追記)、ファイルを標準入力に流す(<)。 - シェル変数 (PowerShell の $env: / bash の $)
- シェル内で値を保持する変数。環境変数は子プロセスにも引き継がれる。
- jq
- JSON 操作コマンドラインツール。クエリ言語で複雑な抽出・変換ができる。Linux/Mac は標準パッケージで入る、Windows は winget で。
- idempotent (冪等)
- 「何度実行しても同じ結果」となる性質。Terraform / setup スクリプト / update 系コマンドに重要。
- silent / quiet モード (curl -s 等)
- 進捗表示を抑制するオプション。スクリプト内でコマンドを使う時に出力をクリーンにする。
- resume ダウンロード (-C -)
- curl で「途中まで取れたファイルの続きから取得」する機能。HTTP Range リクエストを使う。
- BOM 無し UTF-8
- UTF-8 ファイルの先頭に BOM(
EF BB BF)を付けない形式。HCL / YAML / JSON のパーサが嫌うので、設定ファイルでは BOM 無しで書く。 - MSYS_NO_PATHCONV
- Git Bash で「Unix パスを Windows パスに自動変換する」機能を無効化する環境変数。AWS CLI 等で
/aws/...形式のリソース名を渡すときに必要。 - winget
- Windows 標準のパッケージマネージャ。
winget installでツールをインストール。 - HTTP Range リクエスト
- HTTP のヘッダで「ファイルのこの範囲だけください」と指定する機能。レジューム ダウンロードや動画ストリーミングで使われる。
- SHA256 ハッシュ
- 256 ビットのハッシュ値。ファイルの改ざん検知・パスワード保管・JWT 署名等で使われる。
- UUID v4
- ランダムベースの 128 ビット一意識別子。衝突確率は実質 0。データベースの主キーや一意 ID として使う。
- ISO 8601
- 日時の国際標準形式。
2026-04-26T13:00:00Zのような表現。プログラム間の日時授受の標準。 - base64
- バイナリデータをテキスト文字列で表現する変換方式。HTTP / メール / JSON 等のテキスト前提のプロトコルで使う。