[{"data":1,"prerenderedAt":87},["ShallowReactive",2],{"pattern-apigw-apikey-tenantid-cdk":3},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":10,"deploy":12,"description":16,"extension":17,"framework":18,"gitHub":19,"highlight":6,"introBox":25,"language":33,"level":34,"meta":35,"patternArch":36,"resources":65,"s3URL":6,"services":6,"stem":82,"testing":83,"videoId":6,"__hash__":86},"patterns\u002Fpatterns\u002Fapigw-apikey-tenantid-cdk.json","Amazon API Gateway with AWS Lambda authorizer, & Amazon DynamoDB for Tenant API Key Authentication",null,{"text":8},[9],"Delete the CDK stack: \u003Ccode>cdk destroy\u003C\u002Fcode>",[11],"content\u002Fcontributors\u002Flavanya-tangutur.json",{"text":13},[14,15],"npm install","cdk deploy","Implement a secure tenant-based API key authorization system using Amazon Cognito, Amazon API Gateway, AWS Lambda Authorizer, and Amazon DynamoDB.","json","AWS CDK",{"template":20},{"repoURL":21,"templateURL":22,"projectFolder":23,"templateFile":24},"https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-patterns\u002Ftree\u002Fmain\u002Fapigw-apikey-tenantid-cdk","serverless-patterns\u002Fapigw-apikey-tenantid-cdk","apigw-apikey-tenantid-cdk","src\u002Flib\u002Fapigw-dynamodb-apikey-stack.ts",{"headline":26,"text":27},"How it works",[28,29,30,31,32],"This pattern demonstrates how to implement a secure tenant-based API key authorization system using Amazon Cognito, Amazon API Gateway, Lambda Authorizer, and Amazon DynamoDB.","Amazon Cognito authenticates users and issues JWTs (ID tokens) containing a custom tenantId claim.","The client sends the JWT in the Authorization header. API Gateway forwards the token to the Lambda authorizer, which validates and decodes the JWT, extracts the custom:tenantId claim, and queries DynamoDB to retrieve the corresponding API key.","The authorizer returns a policy document with the usageIdentifierKey set to the API key, enabling API Gateway usage plan integration.","The API Gateway then allows or denies access to the protected endpoint based on the policy returned by the authorizer.","TypeScript","200",{},{"icon1":37,"icon2":42,"icon3":46,"icon4":51,"line1":55,"line2":59,"line3":62},{"x":38,"y":39,"service":40,"label":41},12,50,"cognito","Amazon Cognito",{"x":43,"y":39,"service":44,"label":45},42,"apigw","Amazon API Gateway",{"x":47,"y":48,"service":49,"label":50},82,30,"lambda","Lambda authorizer",{"x":47,"y":52,"service":53,"label":54},70,"dynamodb","Amazon DynamoDB",{"from":56,"to":57,"label":58},"icon1","icon2","1. JWT (tenantId)",{"from":57,"to":60,"label":61},"icon3","2. Authorize",{"from":57,"to":63,"label":64},"icon4","3. Lookup API key",{"bullets":66},[67,70,73,76,79],{"text":68,"link":69},"Lambda authorizers for Amazon API Gateway","https:\u002F\u002Fdocs.aws.amazon.com\u002Fapigateway\u002Flatest\u002Fdeveloperguide\u002Fapigateway-use-lambda-authorizer.html",{"text":71,"link":72},"Amazon API Gateway - REST APIs","https:\u002F\u002Fdocs.aws.amazon.com\u002Fapigateway\u002Flatest\u002Fdeveloperguide\u002Fapigateway-rest-api.html",{"text":74,"link":75},"Amazon Cognito Developer Guide","https:\u002F\u002Fdocs.aws.amazon.com\u002Fcognito\u002Flatest\u002Fdeveloperguide\u002Fwhat-is-amazon-cognito.html",{"text":77,"link":78},"Amazon DynamoDB Developer Guide","https:\u002F\u002Fdocs.aws.amazon.com\u002Famazondynamodb\u002Flatest\u002Fdeveloperguide\u002FIntroduction.html",{"text":80,"link":81},"API Gateway Usage Plans","https:\u002F\u002Fdocs.aws.amazon.com\u002Fapigateway\u002Flatest\u002Fdeveloperguide\u002Fapi-gateway-api-usage-plans.html","patterns\u002Fapigw-apikey-tenantid-cdk",{"text":84},[85],"See the GitHub repo for detailed testing instructions.","IN63XWcDjzvE3EAgxWPYY1DeTmV7bEEkQ-bHyN4JP68",1788278255466]