claude-skills/

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

last sync 22h ago
スキルOfficialdevelopment

🧱aws-blocks

プラグイン
aws-core

説明

AWS Blocks(Infrastructure-from-Codeフレームワーク)を使用したフルスタックアプリケーション構築をガイドします。 次のような場合に使用: - API の作成 - Building Block の選定(KVStore、DistributedTable、Database、AuthBasic、AuthCognito、Realtime、AsyncJob、FileBucket など) - ローカル開発環境での実行 - AWS Blocks アプリケーションのデプロイ また、よくあるミスを防ぐバリデーション済みのバージョン固有パターンを用いて、AWS Blocks に関するトピックもカバーします。 以下のいずれかに該当する場合にトリガー: - ユーザーが AWS Blocks に言及している - プロジェクトに `aws-blocks/` ディレクトリが存在する - コードが `@aws-blocks` パッケージをインポートしている

原文を表示

Guides building full-stack applications with AWS Blocks — an Infrastructure-from-Code framework. Applies when creating APIs, selecting Building Blocks (KVStore, DistributedTable, Database, AuthBasic, AuthCognito, Realtime, AsyncJob, FileBucket, etc.), running local development, or deploying AWS Blocks applications. Also covers AWS Blocks topics with validated, version-specific patterns that prevent common mistakes. Triggers when user mentions AWS Blocks; project has aws-blocks/ directory; code imports @aws-blocks packages.

ユースケース

  • APIを作成するとき
  • Building Blockを選定するとき
  • ローカル開発環境で実行するとき
  • AWS Blocksアプリケーションをデプロイするとき

本文(日本語訳)

AWS Blocks アプリケーション開発

パッケージ命名規則: すべてのパッケージは @aws-blocks スコープ配下で公開されています(例: @aws-blocks/core@aws-blocks/blocks@aws-blocks/bb-kv-store)。

概要

AWS Blocks は Infrastructure-from-Code フレームワークです。 各 Building Block が CDK・SDK・ローカルモックを単一の API にバンドルしており、 ストレージ・認証・リアルタイム通信・バックグラウンドジョブ・ファイル管理・AI/検索・メール・オブザーバビリティをカバーする 18 種類以上の Building Block を提供しています。 これらすべては、AWS 認証情報なしにローカルで動作します。

主な特徴:

  • aws-blocks/ ディレクトリ一つでバックエンド全体を定義
  • フロントエンドのインポートは完全に型付け済み — クライアント生成は不要
  • すべての Building Block が AWS なしでローカル動作(モックは .bb-data/ に永続化)
  • npm run sandbox でエフェメラルな個別テスト環境を、npm run deploy で最小権限の認証情報を使用した長期稼働環境をデプロイ可能

新規プロジェクトのスキャフォールディング

npx @aws-blocks/create-blocks-app my-app
cd my-app

既存プロジェクトへの追加:

npx @aws-blocks/create-blocks-app .

既存のプロジェクトを自動検出し、コードと並行して aws-blocks/ ワークスペースを追加します。

Amplify Gen 2 プロジェクトへの追加:

npx @aws-blocks/create-blocks-app .

CLI が amplify/backend.ts を検出した場合、AWS Blocks を Amplify バックエンドに自動統合します。

テンプレートを指定して作成:

npx @aws-blocks/create-blocks-app my-app --template demo
cd my-app

利用可能なテンプレート

テンプレート 説明
default Vite + lit-html スターターアプリ。基本的なアプリアーキテクチャとパターンを示すための、認証・データ永続化・リアルタイム機能を含む(--template 省略時に使用)
bare Vite + lit-html スターター。単一の "hello world" API メソッドとシンプルなフロントエンドのみ
react React + Vite スターター。単一の API エンドポイントと型付き React フロントエンド
backend バックエンド専用 — フロントエンドなし。単一エンドポイントを持つ AWS Blocks API のみ
demo Todo アプリ。AuthBasic・KVStore・DistributedTable・Zod スキーマ・インデックス・認証保護された CRUD を含む
auth-cognito AuthCognito によるパスワードレス メール OTP の完全実装。ロール・デバイス管理・Authenticator UI を含む
nextjs Next.js + React スターター。AWS Blocks バックエンド統合付き(SSR + Server Components 対応)

開発ワークフロー

スキャフォールディング後は、node_modules/@aws-blocks/blocks/README.md を参照してください。 完全な開発ワークフローとして以下の内容が記載されています:

  • コアコンセプト(アーキテクチャ、Building Block の選択方法)
  • プロジェクト構成と Scope の整理
  • エラーハンドリングのパターン
  • スキーマバリデーション
  • ローカル開発
  • ベストプラクティスとよくある間違い
  • デプロイ用 IAM ロールのセットアップとセキュリティガイダンス

特定の Building Block を実装する場合は、該当パッケージの README で詳細な API リファレンスを確認してください (例: node_modules/@aws-blocks/bb-kv-store/README.md)。 これらはインストール済みバージョンの公式ドキュメントです。


セキュリティに関する考慮事項

  • 公開すべきでないすべてのメソッドで await auth.requireAuth(context) を使用すること — ApiNamespace のメソッドは**デフォルトで認証なし(未認証)**です
  • API キーや認証情報には new AppSetting(scope, id, { secret: true }) を使用すること — ハードコードや .env ファイルの使用は禁止
  • ユーザーデータを受け取る KVStore / AppSetting には必ずスキーマを設定すること — RPC レイヤーは構造を検証しますが、ビジネスロジックは検証しません
  • 広範な * IAM ポリシーを追加しないこと — 各 Building Block はすでに自身のリソースにスコープされた最小権限を付与しています
  • FileBucket の blockPublicAccess を変更しないこと — 公開ファイルは CloudFront 経由で配信してください
  • 本番環境では CORS_ALLOWED_ORIGINS を明示的に設定すること — ワイルドカードは避けてください
  • クロスドメインデプロイの場合は、auth コンストラクタに crossDomain: true を渡すこと (SameSite=None; Secure; Partitioned が有効になります)
  • 本番環境のアラート用に、Hosting で monitoring: { enabled: true, snsTopicArn: '...' } を有効化すること
  • 公開向けアプリには CDK 経由で WAF および API Gateway スロットリングを追加すること — デフォルトでは含まれていません
  • Logger はシリアライゼーションの安全性(循環参照・型変換)を提供しますが、 機密コンテンツの自動リダクションは行いません — 生の認証情報・トークン・シークレットを Logger メソッドに渡さないこと。 ログ出力前にコンテキストオブジェクトをサニタイズしてください
原文(English)を表示

AWS Blocks Application Development

Package naming: All packages are published under the @aws-blocks scope (e.g., @aws-blocks/core, @aws-blocks/blocks, @aws-blocks/bb-kv-store).

Overview

AWS Blocks is an Infrastructure-from-Code framework where Building Blocks bundle CDK, SDK, and local mocks into a single API. It provides 18+ Building Blocks covering storage, authentication, real-time communication, background jobs, file management, AI/search, email, and observability — all working locally without AWS credentials.

Key characteristics:

  • One aws-blocks/ directory defines the entire backend
  • Frontend imports are fully typed — no client generation needed
  • All Building Blocks work locally without AWS (mocks persist to .bb-data/)
  • Deploy ephemeral, individual testing environments with npm run sandbox and long-lived environments with npm run deploy using least-privilege credentials

Scaffolding a New Project

npx @aws-blocks/create-blocks-app my-app
cd my-app

To add AWS Blocks to an existing project:

npx @aws-blocks/create-blocks-app .

This detects the existing project and adds an aws-blocks/ workspace alongside your code.

To add AWS Blocks to an Amplify Gen 2 project:

npx @aws-blocks/create-blocks-app .

When the CLI detects amplify/backend.ts, it automatically integrates AWS Blocks with your Amplify backend.

With a specific template:

npx @aws-blocks/create-blocks-app my-app --template demo
cd my-app

Available Templates

Template Description
default Vite + lit-html starter app with basic authentication, data persistence, and realtime to help demonstrate basic app architecture and patterns (used when --template is omitted)
bare Vite + lit-html starter with a single "hello world" API method and a bare frontend
react React + Vite starter with a single API endpoint and typed React frontend
backend Backend-only — no frontend, just the AWS Blocks API with a single endpoint
demo Todo app with AuthBasic, KVStore, DistributedTable, Zod schemas, indexes, and auth-protected CRUD
auth-cognito Full AuthCognito passwordless email-OTP with roles, device management, and Authenticator UI
nextjs Next.js + React starter with AWS Blocks backend integration (SSR + Server Components)

Development Workflow

After scaffolding, refer to node_modules/@aws-blocks/blocks/README.md for the complete development workflow including:

  • Core concepts (Architecture, Building Block selection)
  • Project structure and Scope organization
  • Error handling patterns
  • Schema validation
  • Local development
  • Best practices and common mistakes
  • Deployment IAM role setup and security guidance

When implementing a specific Building Block, read its package README for the detailed API reference (e.g., node_modules/@aws-blocks/bb-kv-store/README.md). These are the authoritative docs for your installed version.

Security Considerations

  • Use await auth.requireAuth(context) in every method that shouldn't be public — ApiNamespace methods are unauthenticated by default
  • Use new AppSetting(scope, id, { secret: true }) for API keys and credentials — never hardcode or use .env files
  • Always attach a schema to KVStore/AppSetting that accepts user data — the RPC layer validates structure but not business logic
  • Do not add broad * IAM policies — each Building Block already grants least-privilege scoped to its own resources
  • Never change blockPublicAccess on FileBucket — serve public files through CloudFront instead
  • Configure CORS_ALLOWED_ORIGINS explicitly for production — avoid wildcards
  • For cross-domain deployments, pass crossDomain: true to auth constructors (enables SameSite=None; Secure; Partitioned)
  • Enable monitoring: { enabled: true, snsTopicArn: '...' } on Hosting for production alerts
  • Add WAF and API Gateway throttling via CDK for public-facing apps — not included by default
  • Logger provides serialization safety (circular refs, type coercion) but does NOT redact sensitive content — never pass raw credentials, tokens, or secrets to Logger methods; sanitize context objects before logging

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