{"action":"created","issue":{"url":"https://api.github.com/repos/servant-app/JAWS/issues/25","labels_url":"https://api.github.com/repos/servant-app/JAWS/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/servant-app/JAWS/issues/25/comments","events_url":"https://api.github.com/repos/servant-app/JAWS/issues/25/events","html_url":"https://github.com/servant-app/JAWS/issues/25","id":99385989,"number":25,"title":"To API Gateway or to not?","user":{"login":"hj1980","id":164054,"avatar_url":"https://avatars.githubusercontent.com/u/164054?v=3","gravatar_id":"","url":"https://api.github.com/users/hj1980","html_url":"https://github.com/hj1980","followers_url":"https://api.github.com/users/hj1980/followers","following_url":"https://api.github.com/users/hj1980/following{/other_user}","gists_url":"https://api.github.com/users/hj1980/gists{/gist_id}","starred_url":"https://api.github.com/users/hj1980/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hj1980/subscriptions","organizations_url":"https://api.github.com/users/hj1980/orgs","repos_url":"https://api.github.com/users/hj1980/repos","events_url":"https://api.github.com/users/hj1980/events{/privacy}","received_events_url":"https://api.github.com/users/hj1980/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/servant-app/JAWS/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-06T08:32:59Z","updated_at":"2015-08-06T17:09:51Z","closed_at":null,"body":"We're in the process of building a Lambda (DynamoDB, S3 etc) based 'API'. Initially, we looked at:\r\nClient (cordova + angular + RESTish client) ->\r\nServer (AWS API Gateway) ->\r\nLambda (Actual code) ->\r\nDynamoDB etc.\r\n\r\nAs Cognito Identity seems to be a pretty reasonable choice for auth even if not using Cognito Sync, and given the integration to Lambda (with \"identity\" in the context hash) perhaps it can actually be used like this (RPC ish):\r\nClient (as before, but with AWS SDK calling lambda.invoke) ->\r\nServer (Lambda function) ->\r\nDynamoDB etc.\r\n\r\nThe pros:\r\n- No messing around with API Gateway for server side.\r\n- Easier client side updates - no need to generate client SDK for each API Gateway update (although this is still needed for Lambda as mentioned below)\r\n- Immediate support (now) for a calling user's context. API Gateway doesn't currently provide that easily / at all. I last checked ~1 week ago.\r\n- No need to roll own auth (JWT etc) for a lot of stuff, just use Cognito.\r\n\r\nThe cons:\r\n- Still need some CI deployment mechanism. This could be codepipeline that ultimately pushes to S3 bucket that's used as the Lambda source, then calling the SDK's Lamba update function.\r\n- Versioning? Perhaps it needs to be looked at like the client providing some semver value in the hash and the Lambda function maintaining backwards compatibility either by including all code for different versions, or by directing (proxying) the request to a subsequent Lambda function. Or, maybe naming and direct calls like: GetItems-1_0 (\"Function name must contain only letters, numbers, hyphens, or underscores.\"), skipping the patch version as only major/minor versions should change the return value. Or, maybe the client first looks at a well-known location (S3 json file for example) and obtains the list of correct endpoints it should be using for it's current semver level.\r\n- Security? If the user context isn't checked correctly (by user code), then there's a problem!\r\n- Rate limiting?? This could be an issue. API Gateway provides it, but Lambda doesn't appear to. Maybe AWS will address this as required.\r\n\r\n\r\nIMHO, I think it's common to implement overkill. The particular app we're working on is complex enough already, so unless API Gateway is *really* required, we'd prefer to skip it for my our use case.\r\nThat being said, I'd love to work with JAWS if it fits properly!\r\n\r\nThoughts?\r\n\r\n@ac360 \r\n"},"comment":{"url":"https://api.github.com/repos/servant-app/JAWS/issues/comments/128446367","html_url":"https://github.com/servant-app/JAWS/issues/25#issuecomment-128446367","issue_url":"https://api.github.com/repos/servant-app/JAWS/issues/25","id":128446367,"user":{"login":"kabaka","id":278887,"avatar_url":"https://avatars.githubusercontent.com/u/278887?v=3","gravatar_id":"","url":"https://api.github.com/users/kabaka","html_url":"https://github.com/kabaka","followers_url":"https://api.github.com/users/kabaka/followers","following_url":"https://api.github.com/users/kabaka/following{/other_user}","gists_url":"https://api.github.com/users/kabaka/gists{/gist_id}","starred_url":"https://api.github.com/users/kabaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kabaka/subscriptions","organizations_url":"https://api.github.com/users/kabaka/orgs","repos_url":"https://api.github.com/users/kabaka/repos","events_url":"https://api.github.com/users/kabaka/events{/privacy}","received_events_url":"https://api.github.com/users/kabaka/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T17:09:51Z","updated_at":"2015-08-06T17:09:51Z","body":"We recently went through a similar thought process and settled on using API Gateway. The rationale was entirely for the sake of response caching. Even if a response is only cached for a few minutes, that has saved us many lambda invocations and database lookups, and made the application more responsive to the end-user.\r\n\r\nThis may not be true for all applications — but for ours, very rapid response times for small, seldom-changing data far outweighs the cons, not to mention to difference in provisioned throughput for DynamoDB and whatnot. I don't think the importance of cache can really be overstated for any application.\r\n\r\nAside from that, you can continue to use Cognito/IAM for a lot of authentication tasks even if using API Gateway. I know there are some limitations on how useful that is right now, but those issues are rapidly being addressed."}}