デプロイ手順

May 8, 2026 · View on GitHub

前提条件

  • AWS CLI
  • Node.js 20~
  • npm
  • Docker CLI

1. CDK 依存インストール

npm ci

2. cdk.json のパラメータ確認

cdk.jsoncontext セクションで以下を確認・変更:

パラメータ説明デフォルト
allowOriginCORS 許可オリジン*
allowedCidrsWAF IP 制限 (CIDR)["0.0.0.0/1", "128.0.0.0/1"] (全許可)
bedrockModelIdBedrock モデル IDglobal.anthropic.claude-sonnet-4-6
csvInputBucketName既存 CSV バケット名 (省略時は新規作成)。既存バケットを指定した場合、Admin UI のローカルアップロード機能は無効化され、「既存 S3 パス指定」のみ利用可能になります(ブラウザ直 PUT に必要な CORS 設定を行わない前提のため)未設定
sqlResultThresholdAgent SQL 結果の行数上限200
enablePromptCacheBedrock Prompt Cache の有効/無効true
stackPrefixスタック名のプレフィックス。同一 AWS アカウントに複数環境をデプロイする場合に指定 (例: Dev, Stg, TeamA, TeamB)"" (空文字)
testAgentUserAgent UserPool に自動作成するテストユーザー名。空文字の場合は作成しない。メールアドレスではなくユーザー名とすること。パスワードは CDK が自動生成して Secrets Manager に保管する"" (空文字)
testAdminUserAdmin UserPool に自動作成するテストユーザー名。空文字の場合は作成しない。メールアドレスではなくユーザー名とすること。パスワードは CDK が自動生成して Secrets Manager に保管する"" (空文字)

アクセス元IPアドレスを縛るには allowedCidrs を実際の IP 範囲に制限してください。

3. CDK Bootstrap (初回のみ)

初めて CDK を利用する場合、bootstrap が必要です

npm run cdk bootstrap

4. デプロイ

npm run cdk -- deploy --all

2 つのスタックがデプロイされます:

  • DwhAgentWafStack (us-east-1) — CloudFront 用 WAF
  • DwhAgentStack (デフォルトリージョン) — 全リソース

デプロイ完了後、以下の出力値を確認:

DwhAgentStack.AgentFrontendUrl = https://dxxxxx.cloudfront.net
DwhAgentStack.AgentCognitoUserPoolId = ap-northeast-1_XXXXX
DwhAgentStack.AdminFrontendUrl = https://dyyyy.cloudfront.net
DwhAgentStack.AdminCognitoUserPoolId = ap-northeast-1_YYYYY
DwhAgentStack.CsvBucketName = dwhagentstack-csvstoragecsvinputbucketXXXXX-XXXXX

5. Cognito ユーザー作成

Agent 用と Admin 用で別々の UserPool です。ユーザー作成には 2 通りの方法があります。

方法 A: テストユーザーを CDK で自動作成(開発環境向け)

cdk.jsontestAgentUser / testAdminUser に username を指定してデプロイすると、 それぞれの UserPool にテストユーザーが自動作成されます。 パスワードは CDK が自動生成して Secrets Manager に保管します。

"testAgentUser": "agentuser",
"testAdminUser": "adminuser"

デプロイ後、以下の出力値を確認:

DwhAgentStack.AgentBackendCognitoTestUserSecretName = ...
DwhAgentStack.AdminBackendCognitoTestUserSecretName = ...

Secrets Manager からパスワードを取得:

aws secretsmanager get-secret-value \
  --secret-id <TestUserSecretName> \
  --query SecretString --output text | jq -r .password

注意: この機能は開発環境専用です。本番では testAgentUser / testAdminUser を 空文字のままにしてください。

方法 B: AWS CLI で手動作成

# Agent UserPool にユーザー作成
aws cognito-idp admin-create-user \
  --user-pool-id <AgentCognitoUserPoolId> \
  --username <username> \
  --temporary-password '<temoprary password>' \
  --user-attributes Name=email,Value=<email>

# Admin UserPool にユーザー作成
aws cognito-idp admin-create-user \
  --user-pool-id <AdminCognitoUserPoolId> \
  --username <admin_username> \
  --temporary-password '<temoprary password>' \
  --user-attributes Name=email,Value=<admin_email>

6. Bedrock AgentCore Observability の有効化

マネジメントコンソールを開き、Configure をクリックして、Transaction Search を有効化してください。Trace indexing rate は開発環境では 100% にすることもお勧めです。

7. 動作確認

OPERATION.md を参照してください。

Appendix: スタック削除

npm run cdk -- destroy --all