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 3Deploying 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 <code>lambda</code> (https://docs.aws.amazon.com/cli/latest/reference/lambda/index.html) and <code>apigateway</code> (https://docs.aws.amazon.com/cli/latest/reference/apigateway/index.html) services.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset