Closed4

Amazon Bedrock AgentCore ワークショップを試したメモ

dehio3dehio3

Lab 2: AgentCore Runtime - クラウドへのデプロイ 🚀

Step 4: エージェントの起動 : agentcore launch

agentcore launchにて発生したエラー

❌ Launch failed: An error occurred (AccessDenied) when calling the PutBucketLifecycleConfiguration 
operation: User: 
arn:aws:sts::123456789012:assumed-role/BedrockAgentCoreCodeEdito-CodeEditorInstanceBootstr-wOh3uiC2rdp0/i-0cd
231d18c8e842fa is not authorized to perform: s3:PutLifecycleConfiguration on resource: 
"arn:aws:s3:::bedrock-agentcore-codebuild-sources-123456789012-us-west-2" because no identity-based policy 
allows the s3:PutLifecycleConfiguration action
❌ Launch failed: An error occurred (AccessDeniedException) when calling the CreateProject operation: User: 
arn:aws:sts::123456789012:assumed-role/BedrockAgentCoreCodeEdito-CodeEditorInstanceBootstr-wOh3uiC2rdp0/i-0cd
231d18c8e842fa is not authorized to perform: codebuild:CreateProject on resource: 
arn:aws:codebuild:us-west-2:123456789012:project/bedrock-agentcore-cost_estimator_agent-builder because no 
identity-based policy allows the codebuild:CreateProject action
❌ Launch failed: An error occurred (AccessDeniedException) when calling the StartBuild operation: User: 
arn:aws:sts::123456789012:assumed-role/BedrockAgentCoreCodeEdito-CodeEditorInstanceBootstr-wOh3uiC2rdp0/i-0cd
231d18c8e842fa is not authorized to perform: codebuild:StartBuild on resource: 
arn:aws:codebuild:us-west-2:123456789012:project/bedrock-agentcore-cost_estimator_agent-builder because no 
identity-based policy allows the codebuild:StartBuild action
❌ Launch failed: An error occurred (AccessDeniedException) when calling the UpdateProject operation: User: 
arn:aws:sts::123456789012:assumed-role/BedrockAgentCoreCodeEdito-CodeEditorInstanceBootstr-wOh3uiC2rdp0/i-0cd
231d18c8e842fa is not authorized to perform: codebuild:UpdateProject on resource: 
arn:aws:codebuild:us-west-2:123456789012:project/bedrock-agentcore-cost_estimator_agent-builder because no 
identity-based policy allows the codebuild:UpdateProject action

CodeEditor EC2インスタンスのIAM Roleのインラインポリシー(WorkshopSpecificPolicy)に以下のポリシーステートメントを追加

{
    "Action": [
        "s3:PutLifecycleConfiguration",
        "codebuild:CreateProject",
        "codebuild:StartBuild",
        "codebuild:UpdateProject"
    ],
    "Resource": "*",
    "Effect": "Allow"
}
dehio3dehio3

Lab 4: Gateway - 外部サービスを MCP に変換し接続する 🔌

Step 2: AWS Lambda のデプロイ

AgentCoreGatewayFunctionの作成でエラー

Resource handler returned message: "Specified ReservedConcurrentExecutions for function decreases account's UnreservedConcurrentExecution below its minimum value of [10]. (Service: Lambda, Status Code: 400, Request ID: e6edc20e-d446-4f1a-9c09-3554fddb6bac) (SDK Attempt Count: 1)" (RequestToken: f3feac55-a817-cd1b-5ca6-605f2e53eb3e, HandlerErrorCode: InvalidRequest)

エラーの原因
Lambda関数に設定されたReservedConcurrentExecutions(予約済み同時実行数)が、アカウントのUnreservedConcurrentExecution(未予約同時実行数)を最小値の10以下に減らしてしまうため、作成が失敗した。
AWSアカウントには同時実行数の上限がある。その上限から予約済み同時実行数を引いた残りが「未予約同時実行数」で、最低10以上である必要がある。

現在の同時実行数上限を確認
$ aws lambda get-account-settings
{
    "AccountLimit": {
        "TotalCodeSize": 80530636800,
        "CodeSizeUnzipped": 262144000,
        "CodeSizeZipped": 52428800,
        "ConcurrentExecutions": 10,
        "UnreservedConcurrentExecutions": 10
    },
    "AccountUsage": {
        "TotalCodeSize": 9681,
        "FunctionCount": 4
    }
}
  • ConcurrentExecutions: 10(同時実行数の上限)
  • UnreservedConcurrentExecutions: 10(未予約同時実行数)

Lambda関数に任意のReservedConcurrentExecutionsを設定すると、未予約同時実行数が10以下になってしまい、AWSの最小要件(10以上)を満たせていない。

ReservedConcurrentExecutionsの設定をコメントアウトし、AWSコンソールからAWS-Cost-Estimator-Tool-Markdown-To-Emailスタックを削除して再デプロイ。

https://github.com/aws-samples/sample-amazon-bedrock-agentcore-onboarding/blob/9a4b187c4b6f3174fa65dde15a64d26f1fccb882/04_gateway/template.yaml#L25

このスクラップは16時間前にクローズされました