[{"data":1,"prerenderedAt":91},["ShallowReactive",2],{"pattern-agentcore-identity-cognito-multi-tenant-python-cdk":3,"pattern-group-agentcore-identity-cognito-multi-tenant-python-cdk":6},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":10,"deploy":12,"description":19,"extension":20,"framework":21,"gitHub":22,"highlight":6,"introBox":26,"language":33,"level":34,"meta":35,"patternArch":36,"patternGroup":6,"patternGroupLabel":6,"resources":69,"stem":83,"testing":84,"videoId":6,"__hash__":90},"patterns\u002Fpatterns\u002Fagentcore-identity-cognito-multi-tenant-python-cdk.json","Multi-tenant Amazon Bedrock AgentCore Runtime with Amazon Cognito",null,{"text":8},[9],"Delete the stack: \u003Ccode>cdk destroy\u003C\u002Fcode>",[11],"content\u002Fcontributors\u002Fsudhansu-mohapatra.json",{"text":13},[14,15,16,17,18],"python3 -m venv .venv","source .venv\u002Fbin\u002Factivate","pip3 install -r requirements.txt","export CDK_DEFAULT_REGION=us-west-2","cdk deploy","Authenticate an Amazon Bedrock AgentCore Runtime agent with Amazon Cognito and enforce per-tenant data isolation using Amazon Bedrock AgentCore Identity JWT authorization.","json","AWS CDK",{"template":23},{"patternPath":24,"templateFile":25},"agentcore-identity-cognito-multi-tenant\u002Fpython\u002Fcdk","infra\u002Fagentcore_identity_stack.py",{"headline":27,"text":28},"How it works",[29,30,31,32],"This pattern secures an Amazon Bedrock AgentCore Runtime agent with Amazon Cognito as the OAuth 2.0 \u002F JWT identity provider.","Two Cognito groups represent two tenants. AgentCore Identity validates the inbound Cognito JWT with a custom JWT authorizer before the request reaches the agent.","The agent reads the caller's tenant from the validated `cognito:groups` claim and gives the model one Amazon DynamoDB tool bound to that tenant. The tool queries a single table partitioned by `tenant_id`.","Because the tenant comes from the token and not the prompt, the agent can only read the caller's own tenant data, even if a prompt asks for another tenant's.","Python","300",{},{"icon1":37,"icon2":41,"icon3":45,"icon4":49,"icon5":53,"line1":56,"line2":60,"line3":63,"line4":66},{"x":38,"y":38,"service":39,"label":40},20,"icon-internet","Client",{"x":38,"y":42,"service":43,"label":44},68,"cognito","Amazon Cognito User pool",{"x":46,"y":38,"service":47,"label":48},53,"bedrock-agentcore","Amazon Bedrock\nAgentCore Runtime",{"x":50,"y":38,"service":51,"label":52},88,"dynamodb","Amazon DynamoDB\nTenant table",{"x":50,"y":42,"service":54,"label":55},"bedrock","Amazon Bedrock",{"from":57,"to":58,"label":59},"icon1","icon2","Get token",{"from":57,"to":61,"label":62},"icon3","Bearer JWT",{"from":61,"to":64,"label":65},"icon4","Query own tenant",{"from":61,"to":67,"label":68},"icon5","Model",{"bullets":70},[71,74,77,80],{"text":72,"link":73},"Configure inbound JWT authorizer for AgentCore","https:\u002F\u002Fdocs.aws.amazon.com\u002Fbedrock-agentcore\u002Flatest\u002Fdevguide\u002Finbound-jwt-authorizer.html",{"text":75,"link":76},"Amazon Bedrock AgentCore Identity","https:\u002F\u002Fdocs.aws.amazon.com\u002Fbedrock-agentcore\u002Flatest\u002Fdevguide\u002Fidentity.html",{"text":78,"link":79},"Amazon Cognito as an identity provider for AgentCore","https:\u002F\u002Fdocs.aws.amazon.com\u002Fbedrock-agentcore\u002Flatest\u002Fdevguide\u002Fidentity-idp-cognito.html",{"text":81,"link":82},"SaaS multi-tenancy on AWS","https:\u002F\u002Fdocs.aws.amazon.com\u002Fwhitepapers\u002Flatest\u002Fsaas-architecture-fundamentals\u002Ftenant-isolation.html","patterns\u002Fagentcore-identity-cognito-multi-tenant-python-cdk",{"text":85},[86,87,88,89],"Seed data: \u003Ccode>cd test && .\u002Fseed_tenant_data.sh &lt;TenantTableName&gt; us-west-2\u003C\u002Fcode>","Get a token for a tenant user: \u003Ccode>.\u002Fget_token.sh\u003C\u002Fcode>","Invoke the agent: \u003Ccode>export AGENT_ARN=&lt;AgentRuntimeArn&gt; && export BEARER_TOKEN=&lt;token&gt; && python test_multi_tenant.py \"List my orders\"\u003C\u002Fcode>","Repeat for a second tenant user and confirm each caller only sees its own tenant's data.","iDFXwkgQn515bC6EZW4o1EtJw6cLPgTvLeXJSMG-5HU",1795189146009]