CloudFront 実務Tips
CloudFront 実務Tips
Section titled “CloudFront 実務Tips”AWS CLI
Section titled “AWS CLI”# ディストリビューション作成aws cloudfront create-distribution \ --origin-domain-name my-bucket.s3.amazonaws.com \ --default-root-object index.html
# ディストリビューション一覧aws cloudfront list-distributions
# キャッシュ無効化aws cloudfront create-invalidation \ --distribution-id E1234567890ABC \ --paths "/*"
# 特定パス無効化aws cloudfront create-invalidation \ --distribution-id E1234567890ABC \ --paths "/images/*" "/css/style.css"S3 + CloudFront設定
Section titled “S3 + CloudFront設定”{ "Version": "2012-10-17", "Statement": [ { "Sid": "CloudFrontAccess", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity E1234567890ABC" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-bucket/*" } ]}ベストプラクティス
Section titled “ベストプラクティス”パフォーマンス: - 適切なTTL設定 - Gzip圧縮有効化 - HTTP/2、HTTP/3有効化 - バージョニング(キャッシュバスティング)
セキュリティ: - HTTPS必須 - WAF統合 - OAI使用(S3オリジン) - Signed URL(プライベートコンテンツ)
コスト最適化: - キャッシュ最大化 - Invalidation最小化 - プライスクラス選択トラブルシューティング
Section titled “トラブルシューティング”# ディストリビューション状態確認aws cloudfront get-distribution \ --id E1234567890ABC
# キャッシュ統計aws cloudfront get-distribution-statistics \ --distribution-id E1234567890ABC
# CloudFrontログ(S3)aws s3 ls s3://my-cloudfront-logs/