generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Right now there are no unit tests for the rootfs image scanning Lambda. While this is non-critical infrastructure and the function is fairly simple, unit test coverage for the function would surely be an enhancement to the overall testing profile of this package.
A solution could define a class like this with a boto3 resource to be easily mocked:
class SnsTopicClass:
"""
AWS SNS Topic Resource Class
"""
def __init__(self, sns_topic_resource):
self.resource = sns_topic_resource["resource"]
self.topic_arn = sns_topic_resource["topic_arn"]
self.topic = self.resource.Topic(self.topic_arn)
# [1] Globally scoped resources
# Initialize the resources once per Lambda execution environment by using global scope.
_LAMBDA_SNS_TOPIC_RESOURCE = { "resource" : resource('sns'),
"topic_arn" : os.environ.get("SNS_ARN","NONE") }Alternatively, given this project is mainly TypeScript, the lambda function could be rewritten in TS to get the built in benefit of all testing tooling already living with the project, i.e. not having to maintain a python virtual environment or similar for testing this both locally for devs and in the actual pipeline defined in this project.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request