mardi 3 décembre 2019

How can I most effectively mock API Gateway, DynamoDB, and Cognito for integration testing an SPA?

I have a React-based SPA that I'm trying to test against a versioned backend with its own Database.

In production, the part of the backend is exposed to the outside world via AWS services, like API Gateway. We also use DynamoDB for storing some API-level user details, and Cognito w/ User Pools for authentication. Calls are made to API Gateway, which after authenticating with a Key, makes VPC-link calls to the backend (all of our applications are in a private VPC). Here's a diagram illustrating the relationship:

relationship diagram

This is fine when deployed, but I'd want to be able to reproduce this setup locally for development and testing purposes (not deployment). From the reading I was doing about AWS SAM, it seems like it might be the best tool for the job. But getting started with it has been difficult as I'm not sure what the relationship between all the methods/endpoints that I defined and individual Lambda functions that I have to define for SAM as part of my API.

I have a swagger template, so that should make things easier. But I'm not sure how to handle things like Proxying the calls to my backend, setting up authentication, etc. and the SAM documentation seems lacking in regards to this.

Anyone have any tips or experiences?

Many thanks!

Aucun commentaire:

Enregistrer un commentaire