diff --git a/sample_aws_container/Dockerfile b/sample_aws_container/Dockerfile new file mode 100644 index 0000000..987d97c --- /dev/null +++ b/sample_aws_container/Dockerfile @@ -0,0 +1,10 @@ +FROM amazon/aws-lambda-python + +COPY requirements.txt . +COPY src/ . + +RUN pip install --upgrade pip \ + && pip install -r requirements.txt + +CMD ["sample.main"] + diff --git a/sample_aws_container/requirements.txt b/sample_aws_container/requirements.txt new file mode 100644 index 0000000..040746e --- /dev/null +++ b/sample_aws_container/requirements.txt @@ -0,0 +1 @@ +lightrun==1.2.2 \ No newline at end of file diff --git a/sample_aws_container/src/sample.py b/sample_aws_container/src/sample.py new file mode 100644 index 0000000..f63e8b5 --- /dev/null +++ b/sample_aws_container/src/sample.py @@ -0,0 +1,21 @@ +LIGHTRUN_KEY = 'LIGHTRUN_KEY' +LIGHTRUN_SERVER = 'LIGHTRUN_SERVER_URL' + +def import_lightrun(): + try: + import lightrun + lightrun.enable(com_lightrun_server=LIGHTRUN_SERVER, company_key=LIGHTRUN_KEY) + except ImportError as e: + print("Error importing Lightrun: ", e) + +def start_fibonacci(n): + if n in {0, 1}: + return n + return start_fibonacci(n - 1) + start_fibonacci(n - 2) + +def main(event, context): + import_lightrun() + num = event['num'] + + print("Calculating Fibonacci of {}...".format(num)) + return start_fibonacci(num)