Over the 4 years I implementing Client + AWS SDK on my serverless approach. Direct hit to all microservices we have such as Lambda, DynamoDB, S3, SQS, etc.
To work with this approach, we have to strong understand about IAM Role Policy including its statements concept, Authentication Token, AWS Credential, and Token - Credential exchange.
For me, using SDK is better to implement serverless rather than API Gateway. Why I prefer to implementing SDK instead of API on my serverless infra?
- API Gateway is Costly
- Network hop-less
- In fact, SDK is commonly contain an API to communicate with other applications Class base and simple call such as dynamodb.put(params).promise(), lambda.invoke(params).promise(), s3.putObject(params).promise(), etc. We can see a sample API call like fetch(URL).promise(), the term is not really different
- API is more complex and some case can't or shouldn't be handled with
- SDK is not scalable? No, I dont think so. Because it's class base, it's so scalable.
- Slimming the infra and code writing, i.e to work with s3 no need deploy API+Lambda
- Speed up the process, i.e storing data to dynamodb no need business logic through API+lambda
- Easy maintaining, we only maintain our client code
- Role Policy is more scalable; etc