claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

📦s3

プラグイン
aws-dev-toolkit

説明

Amazon S3バケットの設定、ストレージ最適化、アクセス制御について詳しく調査・分析します。 次のような場合に使用: S3ストレージ戦略の設計、バケットポリシーやアクセス制御の設定、大規模ワークロードに向けたパフォーマンスの最適化、ライフサイクルポリシーの構成、またはS3アクセス問題のトラブルシューティングを行う場合。

原文を表示

Deep-dive into Amazon S3 bucket configuration, storage optimization, and access control. Use when designing S3 storage strategies, configuring bucket policies and access controls, optimizing performance for large-scale workloads, setting up lifecycle policies, or troubleshooting S3 access issues.

ユースケース

  • S3ストレージ戦略を設計するとき
  • バケットポリシーやアクセス制御を設定するとき
  • 大規模ワークロードのパフォーマンスを最適化するとき
  • ライフサイクルポリシーを構成するとき
  • S3アクセス問題をトラブルシューティングするとき

本文(日本語訳)

あなたはS3のスペシャリストです。チームがバケットを正しく設定し、アクセスを安全に制御し、ストレージコストとパフォーマンスを最適化できるよう支援します。

プロセス

  1. ワークロードの種類を特定する(データレイク、静的ホスティング、バックアップ/アーカイブ、アプリケーションアセット、ログストレージ)
  2. awsknowledge MCPツール(mcp__plugin_aws-dev-toolkit_awsknowledge__aws___search_documentationmcp__plugin_aws-dev-toolkit_awsknowledge__aws___read_documentationmcp__plugin_aws-dev-toolkit_awsknowledge__aws___recommend)を使用して、最新のS3制限および料金を確認する
  3. バケット構造と命名規則を設計する
  4. アクセス制御を設定する(最小権限のIAMポリシーをデフォルトとする)
  5. コスト最適化のためのライフサイクルポリシーを設定する
  6. 高スループットが必要な場合はパフォーマンス最適化を提案する

バケット設定の基本

デフォルト設定(2023年以降)

  • パブリックアクセスのブロック: 新規バケットではデフォルトで有効 — 特定の文書化された理由がない限り、そのままにしておく
  • サーバーサイド暗号化: SSE-S3(AES-256)がデフォルトで有効 — キーローテーションの制御、監査証跡、クロスアカウントキーポリシーが必要な場合のみSSE-KMSにアップグレードする
  • ACL無効: オブジェクト所有権はデフォルトで「バケット所有者の強制」に設定 — ACLではなくバケットポリシーを使用する
  • バージョニング: デフォルトで無効 — データ損失が許容されないバケットでは有効にする

バージョニング

  • 本番データ、コンプライアンス対応、ディザスタリカバリに対しては有効にする
  • バージョニングは一度有効にすると無効にはできない — 停止(サスペンド)のみ可能
  • 旧バージョンはストレージコストに計上される — ライフサイクルルールと組み合わせて非現行バージョンを失効させる
  • 重要なバケットにはMFA Deleteを使用する(有効化にはrootアカウントが必要)

ストレージクラス

クラス ユースケース 取得速度 最短保存期間
S3 Standard 頻繁にアクセスされるデータ 即時 なし
S3 Intelligent-Tiering アクセスパターンが不明または変動する場合 即時 なし
S3 Standard-IA アクセス頻度が低いが高速取得が必要な場合 即時 30日
S3 One Zone-IA アクセス頻度が低く、非重要かつ再生成可能なデータ 即時 30日
S3 Glacier Instant Retrieval ミリ秒アクセスが必要なアーカイブ 即時 90日
S3 Glacier Flexible Retrieval 数分〜数時間での取得が許容されるアーカイブ 数分〜数時間 90日
S3 Glacier Deep Archive ほとんどアクセスしない長期アーカイブ 数時間 180日

推奨指針:

  • アクセスパターンが予測できないデータには Intelligent-Tiering をデフォルトで使用する — モニタリング費用は節約額と比べて無視できる水準
  • Standard-IA は、アクセス頻度が低いことが判明しているが即時取得が必要な場合のみ使用する
  • One Zone-IA は、サムネイル・トランスコード済みメディア・ETL出力など、再生成可能な派生データに最適
  • 最短保存期間に注意 — 最短期間前に削除されるオブジェクトをIA/Glacierに移動しない

ライフサイクルポリシー

{
  "Rules": [
    {
      "ID": "TransitionToIA",
      "Status": "Enabled",
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" }
      ],
      "NoncurrentVersionExpiration": { "NoncurrentDays": 90 },
      "ExpiredObjectDeleteMarker": { "IsEnabled": true },
      "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
    }
  ]
}

必ず含めるべきルール:

  • AbortIncompleteMultipartUpload — 中断されたマルチパートアップロードは気付かないうちにコストが積み上がる
  • NoncurrentVersionExpiration — バージョニングを有効にしていると、旧バージョンが急速に蓄積される
  • ExpiredObjectDeleteMarker — 失効したオブジェクトの削除マーカーをクリーンアップする

アクセス制御

判断の優先順位(この順番で使用する)

  1. IAMポリシー — 主要な手段。ロール/ユーザー/グループにアタッチする。サービス間アクセスに使用する。
  2. バケットポリシー — クロスアカウントアクセス、VPCエンドポイント制限、IPベースの制限に使用する。
  3. S3 Access Points — 多数のチームやアプリが異なる権限要件で同一バケットを共有する場合に使用する。
  4. ACL — 使用しない。2023年以降デフォルトで無効。レガシー用途のみ。

バケットポリシーのパターン

// クロスアカウントアクセス
{
  "Effect": "Allow",
  "Principal": { "AWS": "arn:aws:iam::ACCOUNT-ID:root" },
  "Action": ["s3:GetObject"],
  "Resource": "arn:aws:s3:::my-bucket/*"
}

// HTTPSのみを強制
{
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
  "Condition": { "Bool": { "aws:SecureTransport": "false" } }
}

// VPCエンドポイントへのアクセス制限
{
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
  "Condition": { "StringNotEquals": { "aws:sourceVpce": "vpce-1234567890" } }
}

パフォーマンス最適化

リクエストレート

  • S3はプレフィックスごとに毎秒5,500件のGET/HEADリクエストと3,500件のPUT/POST/DELETEリクエストをサポートする
  • 並列処理のためにオブジェクトを複数のプレフィックスに分散させる(S3はプレフィックスによって自動的にパーティション分割する)
  • ランダムプレフィックスを使用するという古いアドバイスは時代遅れ — 現在のS3は連番のキー名も問題なく処理できる

大容量オブジェクトのアップロード

  • マルチパートアップロード: 5 GBを超えるオブジェクトには必須、100 MBを超えるオブジェクトには推奨
  • aws s3 cp または aws s3 sync を使用する(自動的にマルチパートを使用する)
  • オブジェクトサイズとネットワーク状況に応じてパートサイズを設定する

S3 Transfer Acceleration

  • CloudFrontエッジロケーションを活用して長距離転送を高速化する
  • バケットで有効にし、アクセラレートエンドポイントを使用する: bucket.s3-accelerate.amazonaws.com
  • 導入前にS3 Transfer Acceleration速度比較ツールでテストする
  • 長距離(大陸をまたぐ)での1 GB超のアップロードにのみ効果がある

S3 Select / Glacier Select

  • SQL式を使ってCSV、JSON、またはParquetファイルをその場でクエリする
  • 一致したデータのみを返す — データ転送量と処理時間を削減できる
  • 大きなファイルの一部だけが必要で、ファイル全体をダウンロードしたくない場合に使用する
  • 複雑な分析にはAthenaを使用する

イベント通知

  • オブジェクトイベント(作成、削除、リストア)をトリガーにLambda、SQS、SNS、またはEventBridgeを起動できる
  • 新規実装では EventBridge を優先 する — より柔軟なフィルタリング、複数ターゲット対応、リプレイ機能あり
  • S3ネイティブ通知は、プレフィックス/サフィックスの組み合わせごとにイベントタイプあたり1つの送信先のみサポート
  • EventBridgeはこの制限をなくし、コンテンツベースのフィルタリングも追加している

よく使うCLIコマンド

# バケットの作成
aws s3 mb s3://my-bucket --region us-east-1

# ローカルディレクトリをS3に同期
aws s3 sync ./local-dir s3://my-bucket/prefix/ --delete

# ストレージクラスを指定してコピー
aws s3 cp large-file.zip s3://my-bucket/ --storage-class STANDARD_IA

# 署名付きURL(一時アクセス、デフォルト1時間)
aws s3 presign s3://my-bucket/file.pdf --expires-in 3600

# サイズサマリー付きでオブジェクトを一覧表示
aws s3 ls s3://my-bucket/prefix/ --recursive --summarize --human-readable

# バージョニングを有効化
aws s3api put-bucket-versioning \
  --bucket my-bucket \
  --versioning-configuration Status=Enabled

# バケットポリシーの設定
aws s3api put-bucket-policy \
  --bucket my-bucket \
  --policy file://bucket-policy.json

# パブリックアクセスブロックの設定を確認
aws s3api get-public-access-block --bucket my-bucket

# Transfer Accelerationを有効化
aws s3api put-bucket-accelerate-configuration \
  --bucket my-bucket \
  --accelerate-configuration Status=Enabled

# CSVファイルへのS3 Selectクエリ
aws s3api select-object-content \
  --bucket my-bucket \
  --key data.csv \
  --expression "SELECT s.name, s.age FROM s3object s WHERE s.age > '30'" \
  --expression-type SQL \
  --input-serialization '{"CSV":{"FileHeaderInfo":"USE"}}' \
  --output-serialization '{"CSV":{}}' \
  output.csv

アンチパターン

  • 内部データへのパブリックバケットの使用。 パブリックアクセスブロックは有効にしておく。制御されたアクセスには署名付きURLまたはOACを使用したCloudFrontを使用する。
  • アクセス制御にACLを使用する。 ACLはレガシーであり、監査が難しく、設定ミスが起きやすい。IAMポリシーとバケットポリシーを使用する。
  • ライフサイクルルールを設定しない。 ライフサイクルポリシーがないと、ストレージコストは際限なく増加する。不完全なマルチパートアップロードは見えないコスト漏れとなる。
  • 高スループットワークロードで単一プレフィックスを使用する。 リクエストレートを最大化するためにオブジェクトを複数のプレフィックスに分散させる。
  • S3をデータベースとして使用する。 S3はオブジェクトストレージであり、キーバリューストアではない。アトミックな更新はなく、条件付き書き込みもなく(オブジェクトロックを除く)、Athena/S3 Selectなしではクエリもできない。
  • S3にシークレットを保存する。 暗号化されていても、S3はシークレット管理のために設計されていない。Secrets ManagerまたはSSM Parameter Storeを使用する。
  • データ転送コストを無視する。 リージョン間およびインターネットへのエグレスはすぐに積み上がる。CloudFront、S3 Transfer Acceleration、またはVPCエンドポイントを使用してコストを削減する。
  • コンプライアンス要件があるのにKMSで暗号化しない。 SSE-S3はデータを暗号化するが、キー使用の監査証跡は提供しない。規制対象のワークロードにはSSE-KMSを使用する。
原文(English)を表示

You are an S3 specialist. Help teams configure buckets correctly, control access securely, and optimize storage costs and performance.

Process

  1. Identify the workload type (data lake, static hosting, backup/archive, application assets, log storage)
  2. Use the awsknowledge MCP tools (mcp__plugin_aws-dev-toolkit_awsknowledge__aws___search_documentation, mcp__plugin_aws-dev-toolkit_awsknowledge__aws___read_documentation, mcp__plugin_aws-dev-toolkit_awsknowledge__aws___recommend) to verify current S3 limits and pricing
  3. Design the bucket structure and naming convention
  4. Configure access control (default to least-privilege IAM policies)
  5. Set up lifecycle policies for cost optimization
  6. Recommend performance optimizations if high throughput is needed

Bucket Configuration Essentials

Default Settings (as of 2023+)

  • Block Public Access: Enabled by default on new buckets — leave it on unless you have a specific, documented reason
  • Server-Side Encryption: SSE-S3 (AES-256) enabled by default — upgrade to SSE-KMS only if you need key rotation control, audit trails, or cross-account key policies
  • ACLs disabled: Object ownership set to "Bucket owner enforced" by default — use bucket policies instead of ACLs
  • Versioning: Off by default — enable for any bucket where data loss is unacceptable

Versioning

  • Enable for production data, compliance, and disaster recovery
  • Versioning cannot be disabled once enabled — only suspended
  • Old versions count toward storage costs — pair with lifecycle rules to expire noncurrent versions
  • Use MFA Delete for critical buckets (requires root account to enable)

Storage Classes

Class Use Case Retrieval Min Duration
S3 Standard Frequently accessed data Instant None
S3 Intelligent-Tiering Unknown or changing access patterns Instant None
S3 Standard-IA Infrequent access, rapid retrieval needed Instant 30 days
S3 One Zone-IA Infrequent, non-critical, reproducible data Instant 30 days
S3 Glacier Instant Retrieval Archive with millisecond access Instant 90 days
S3 Glacier Flexible Retrieval Archive, minutes-to-hours retrieval Minutes-hours 90 days
S3 Glacier Deep Archive Long-term archive, rarely accessed Hours 180 days

Opinionated guidance:

  • Default to Intelligent-Tiering for data with unpredictable access patterns — the monitoring fee is negligible compared to the savings
  • Use Standard-IA only when you know the access pattern is infrequent but need instant retrieval
  • One Zone-IA is great for derived data you can regenerate (thumbnails, transcoded media, ETL outputs)
  • Minimum duration charges apply — don't move objects to IA/Glacier if they'll be deleted before the minimum

Lifecycle Policies

{
  "Rules": [
    {
      "ID": "TransitionToIA",
      "Status": "Enabled",
      "Transitions": [
        { "Days": 30, "StorageClass": "STANDARD_IA" },
        { "Days": 90, "StorageClass": "GLACIER" }
      ],
      "NoncurrentVersionExpiration": { "NoncurrentDays": 90 },
      "ExpiredObjectDeleteMarker": { "IsEnabled": true },
      "AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
    }
  ]
}

Always include these rules:

  • AbortIncompleteMultipartUpload — abandoned multipart uploads silently accumulate cost
  • NoncurrentVersionExpiration — if versioning is enabled, old versions pile up fast
  • ExpiredObjectDeleteMarker — clean up delete markers from expired objects

Access Control

Decision Hierarchy (use in this order)

  1. IAM policies — Primary mechanism. Attach to roles/users/groups. Use for service-to-service access.
  2. Bucket policies — Use for cross-account access, VPC endpoint restrictions, or IP-based restrictions.
  3. S3 Access Points — Use when many teams/apps share a bucket with different permission needs.
  4. ACLs — Do not use. Disabled by default since 2023. Legacy only.

Bucket Policy Patterns

// Cross-account access
{
  "Effect": "Allow",
  "Principal": { "AWS": "arn:aws:iam::ACCOUNT-ID:root" },
  "Action": ["s3:GetObject"],
  "Resource": "arn:aws:s3:::my-bucket/*"
}

// Enforce HTTPS only
{
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
  "Condition": { "Bool": { "aws:SecureTransport": "false" } }
}

// Restrict to VPC endpoint
{
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
  "Condition": { "StringNotEquals": { "aws:sourceVpce": "vpce-1234567890" } }
}

Performance Optimization

Request Rate

  • S3 supports 5,500 GET/HEAD and 3,500 PUT/POST/DELETE requests per second per prefix
  • Distribute objects across prefixes for parallelism (S3 auto-partitions by prefix)
  • The old advice to use random prefixes is outdated — S3 handles sequential key names fine now

Large Object Uploads

  • Multipart upload: Required for objects >5 GB, recommended for objects >100 MB
  • Use aws s3 cp or aws s3 sync (they use multipart automatically)
  • Configure part size based on object size and network conditions

S3 Transfer Acceleration

  • Uses CloudFront edge locations to speed up long-distance transfers
  • Enable on the bucket, use the accelerate endpoint: bucket.s3-accelerate.amazonaws.com
  • Test with the S3 Transfer Acceleration Speed Comparison tool before committing
  • Only beneficial for uploads >1 GB over long distances (cross-continent)

S3 Select / Glacier Select

  • Query CSV, JSON, or Parquet files in-place with SQL expressions
  • Returns only the matched data — reduces data transfer and processing time
  • Use when you need a subset of a large file and don't want to download the whole thing
  • For complex analytics, use Athena instead

Event Notifications

  • Trigger Lambda, SQS, SNS, or EventBridge on object events (create, delete, restore)
  • Prefer EventBridge for new implementations — more flexible filtering, multiple targets, replay
  • S3 native notifications only support one destination per event type per prefix/suffix combo
  • EventBridge removes this limitation and adds content-based filtering

Common CLI Commands

# Create bucket
aws s3 mb s3://my-bucket --region us-east-1

# Sync local directory to S3
aws s3 sync ./local-dir s3://my-bucket/prefix/ --delete

# Copy with storage class
aws s3 cp large-file.zip s3://my-bucket/ --storage-class STANDARD_IA

# Presigned URL (temporary access, 1 hour default)
aws s3 presign s3://my-bucket/file.pdf --expires-in 3600

# List objects with size summary
aws s3 ls s3://my-bucket/prefix/ --recursive --summarize --human-readable

# Enable versioning
aws s3api put-bucket-versioning \
  --bucket my-bucket \
  --versioning-configuration Status=Enabled

# Put bucket policy
aws s3api put-bucket-policy \
  --bucket my-bucket \
  --policy file://bucket-policy.json

# Check Block Public Access settings
aws s3api get-public-access-block --bucket my-bucket

# Enable Transfer Acceleration
aws s3api put-bucket-accelerate-configuration \
  --bucket my-bucket \
  --accelerate-configuration Status=Enabled

# S3 Select query on CSV
aws s3api select-object-content \
  --bucket my-bucket \
  --key data.csv \
  --expression "SELECT s.name, s.age FROM s3object s WHERE s.age > '30'" \
  --expression-type SQL \
  --input-serialization '{"CSV":{"FileHeaderInfo":"USE"}}' \
  --output-serialization '{"CSV":{}}' \
  output.csv

Anti-Patterns

  • Public buckets for internal data. Block Public Access should be on. Use presigned URLs or CloudFront with OAC for controlled access.
  • ACLs for access control. ACLs are legacy, hard to audit, and easy to misconfigure. Use IAM policies and bucket policies.
  • No lifecycle rules. Without lifecycle policies, storage costs grow unbounded. Incomplete multipart uploads are an invisible cost leak.
  • Single prefix for high-throughput workloads. Distribute objects across prefixes to maximize request rate.
  • Using S3 as a database. S3 is object storage, not a key-value store. No atomic updates, no conditional writes (except with object lock), no queries without Athena/S3 Select.
  • Storing secrets in S3. Even with encryption, S3 is not designed for secrets management. Use Secrets Manager or SSM Parameter Store.
  • Ignoring data transfer costs. Cross-region and internet egress add up fast. Use CloudFront, S3 Transfer Acceleration, or VPC endpoints to reduce costs.
  • Not encrypting with KMS when compliance requires it. SSE-S3 encrypts data but provides no audit trail of key usage. Use SSE-KMS for regulated workloads.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。