Integration testing using real test data
Now that we understand the real test data, we will look at how we can test a deployed Lambda function. First, you will need to install and set up the AWS CLI and configure the AWS Credentials as shown at the end of Chapter 1, Serverless Microservices Architectures and Patterns:
$ sudo pip3 sudo install awscli
$ aws configure
We will redeploy the serverless microservice stack we deployed in Chapter 3, Deploying Your Serverless Stack, so that we can test it. Use the following commands:
$ cd ./serverless-microservice-data-api/bash/apigateway-lambda-dynamodb
$ ./build-package-deploy-lambda-dynamo-data-api.sh
This will rebuild the Lambda ZIP package as the code if there have been any changes. Then it will package and deploy the code and SAM configuration. Finally, it will create the API Gateway, Lambda function, and DynamoDB table.
For testing, we will be using the AWS CLI, which can invoke all of the AWS-managed services. Here we are interested in the <...