1 Answer
- Newest
- Most votes
- Most comments
1
Based on the details provided, here are a few thoughts on approaches you could take:
- Implementing validation logic directly in each Lambda function would work but has the downside of duplicating code as you mentioned. This could become difficult to maintain over time.
- Creating a common data access layer (DAL) using a microservices architecture with service discovery (Cloud Map) is a good option. This centralizes the validation logic while keeping the APIs decoupled. The Lambda functions would make requests to the DAL microservice.
- Another approach could be creating reusable Lambda layers with the shared validation code. The layers could be implemented in a language-agnostic way using something like protocol buffers. The API Lambda functions would import the common layer.
- For simplicity, you could also consider a monolithic DAL deployed as an API Gateway private API. The validation functions would live here and be called by the public APIs.
In general, centralizing the shared logic in a reusable way (layers, microservice) while keeping the APIs decoupled is preferable to duplication. It improves maintainability. I'd evaluate the tradeoffs of the microservices vs monolithic approach based on your specific needs and growth expectations. Let me know if any part needs more explanation or if you have additional questions!
answered 7 months ago
Relevant content
- Accepted Answerasked 2 years ago
- Accepted Answerasked 4 years ago
- AWS OFFICIALUpdated 10 days ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 months ago