Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ ARG runtime
RUN mkdir -p /build/python/lib/$runtime/site-packages
WORKDIR /build

# Install dependencies
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt -t ./python/lib/$runtime/site-packages

# Install datadog_lambda
COPY datadog_lambda ./python/lib/$runtime/site-packages/datadog_lambda
# Install datadog_lambda and dependencies from local
COPY . .
RUN pip install . -t ./python/lib/$runtime/site-packages

# Remove *.pyc files
RUN find ./python/lib/$runtime/site-packages -name \*.pyc -delete
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Replace `<AWS_REGION>` with the AWS region where your Lambda function is publish
arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Python37:1
```

### PyPI

When developing your Lambda function locally where AWS Layer doesn't work, the Datadog Lambda layer can be installed from [PyPI](https://pypi.org/project/datadog-lambda/) by `pip install datadog-lambda` or adding `datadog-lambda` to your project's `requirements.txt`.

The minor version of the `datadog-lambda` package always match the layer version. E.g., datadog-lambda v0.5.0 matches the content in layer version 5.


### Environment Variables

The Datadog API must be defined as an environment variable via [AWS CLI](https://docs.aws.amazon.com/lambda/latest/dg/env_variables.html) or [Serverless Framework](https://serverless-stack.com/chapters/serverless-environment-variables.html):

* DD_API_KEY or DD_KMS_API_KEY (if encrypted by KMS)
Expand Down
4 changes: 3 additions & 1 deletion datadog_lambda/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = "4"
# The minor version corresponds to the Lambda layer version.
# E.g.,, version 0.5.0 gets packaged into layer version 5.
__version__ = '0.5.0'
3 changes: 0 additions & 3 deletions requirements-dev.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

24 changes: 24 additions & 0 deletions scripts/pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019 Datadog, Inc.

# Builds the lambda layer and upload to Pypi
set -e

# Clear previously built distributions
if [ -d "dist" ]; then
echo "Removing folder 'dist' to clear previously built distributions"
rm -rf dist;
fi

# Install build tools
pip install --upgrade setuptools wheel twine

# Build distributions
python setup.py sdist bdist_wheel

# Upload distributions
python -m twine upload dist/*
1 change: 0 additions & 1 deletion scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ do
echo "Running tests against python${python_version}"
docker build -t datadog-lambda-layer-python-test:$python_version \
-f tests/Dockerfile . \
--quiet \
--build-arg python_version=$python_version
docker run -v `pwd`:/datadog-lambda-layer-python \
-w /datadog-lambda-layer-python \
Expand Down
20 changes: 18 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
from os import path
from io import open

from datadog_lambda import __version__

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

setup(
name='ddlambda',
version='0.2.0',
name='datadog_lambda',
version=__version__,
description='The Datadog AWS Lambda Layer',
long_description=long_description,
long_description_content_type='text/markdown',
Expand All @@ -24,4 +26,18 @@
keywords='datadog aws lambda layer',
packages=['datadog_lambda'],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4',
install_requires=[
'aws-xray-sdk==2.4.2',
'datadog==0.28.0',
'wrapt==1.11.1',
'setuptools==40.8.0',
'boto3==1.9.160'
],
extras_require={
'dev': [
'nose2==0.9.1',
'flake8==3.7.7',
'requests==2.21.0'
]
}
)
11 changes: 6 additions & 5 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ FROM python:$python_version

ENV PYTHONDONTWRITEBYTECODE True

COPY .flake8 .flake8
COPY requirements.txt requirements.txt
COPY requirements-dev.txt requirements-dev.txt
RUN pip install -r requirements.txt
RUN pip install -r requirements-dev.txt
RUN mkdir -p /test
WORKDIR /test

# Install datadog-lambda with dev dependencies from local
COPY . .
RUN pip install .[dev]