I have been asked to do some basic integration testing on a lambda which will basically just cal the lambda and verify everything went smoothly. The only issue is, the lambda I am trying to test is invoked by AWS Config as a custom rule. It doesn't return anything. The logic inside the handler is calling EC2 describe instances, doing a check to see if it is considered compliant/non-compliant, and doing a put_evalutions to add the results to aws config. How would you test that when it returns nothing?
Asked
Active
Viewed 96 times
-1
-
1What does the Lambda function do if it fails? And are you invoking it directly, or via API Gateway? – jarmod Jul 12 '21 at 14:10
-
To test a Lambda function in this situation, use logging and then check the log files. – smac2020 Jul 12 '21 at 14:14
1 Answers
1
You could write a simple "test program" that does this using the AWS SDK or you use the test framework in the language of your choice to handle this.
The test program would do this:
- Create a new EC2 instance.
- Run the Lambda under test.
- Check the AWS Config evaluations.
- Delete EC2 instance.
Every test case in your program has different configuration for the EC2 instance (step 1) and has to check the AWS Config if the evaluations are as expected.

Jens
- 20,533
- 11
- 60
- 86