Skip to content

Commit

Permalink
Merge pull request #214 from solarwinds/NH-65069-layer-content-update
Browse files Browse the repository at this point in the history
NH-65069 Lambda layer 0.8 MB decrease
  • Loading branch information
tammy-baylis-swi authored Nov 15, 2023
2 parents 5712a32 + 29e600c commit 70b3c78
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ package: sdist check-sdist-local manylinux-wheels check-wheel-local
# Build APM Python AWS lambda layer as zip artifact
# with extension compatible with current environment
# (x86_64 OR aarch64)
target_dir := "./tmp"
target_dir := "./tmp-lambda"
aws-lambda: check-zip wrapper
@if [ -f ./dist/solarwinds_apm_lambda_${platform}.zip ]; then \
echo -e "Deleting old solarwinds_apm_lambda_${platform}.zip"; \
rm ./dist/solarwinds_apm_lambda_${platform}.zip; \
fi
rm -rf ./tmp
rm -rf ${target_dir}
@echo -e "Creating target directory ${target_dir} for AWS Lambda layer artifacts."
mkdir -p ${target_dir}/python
@echo -e "Install upstream dependencies to include in layer"
Expand All @@ -201,32 +201,29 @@ aws-lambda: check-zip wrapper
@echo -e "Install solarwinds_apm to be packed up in zip archive to target directory."
@/opt/python/cp38-cp38/bin/pip3.8 install . -t ${target_dir}/nodeps --no-deps
@echo -e "Removing non-lambda C-extension library files generated by pip install under target directory."
@rm ${target_dir}/nodeps/solarwinds_apm/extension/*.so*
@rm -rf ${target_dir}/nodeps/solarwinds_apm/extension/*.so*
@echo -e "Building AWS Lambda version of C-extensions for all supported Python versions in target directory."
@set -e; for PYBIN in cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311; do /opt/python/$${PYBIN}/bin/python setup.py build_ext_lambda -b ${target_dir}/nodeps; done
@echo -e "Copying AWS Lambda specific Oboe library liboboe-1.0-lambda-${platform}.so into target directory."
@cp solarwinds_apm/extension/liboboe-1.0-lambda-${platform}.so ${target_dir}/nodeps/solarwinds_apm/extension/liboboe.so
@echo -e "Moving no-deps dependencies, needed for full opentelemetry/instrumentation path"
@cp -r ${target_dir}/nodeps/* ${target_dir}/python && rm -rf ${target_dir}/nodeps
@cp -r ${target_dir}/nodeps/* ${target_dir}/python
@rm -rf ${target_dir}/nodeps
@echo -e "Copying OpenTelemetry lambda wrapper and entry script into target directory."
@cp lambda/otel_wrapper.py ${target_dir}/python/otel_wrapper.py
@cp lambda/otel-instrument ${target_dir}/otel-instrument
@chmod 755 ${target_dir}/otel-instrument
@echo -e "Removing unnecessary boto, six, setuptools, urllib3 installations"
@rm -rf ${target_dir}/python/boto*
@rm -rf ${target_dir}/python/six*
@rm -rf ${target_dir}/python/setuptools*
@rm -rf ${target_dir}/python/urllib3*
@find ${target_dir}/python -type d -name '__pycache__' | xargs rm -rf
@if [[ ! -d dist ]]; then mkdir dist; fi
@pushd ./tmp && zip -r ../dist/solarwinds_apm_lambda_${platform}.zip . && popd
@rm -rf ./tmp ./build
@pushd ${target_dir} && zip -r ../dist/solarwinds_apm_lambda_${platform}.zip . && popd
@rm -rf ${target_dir} ./build
@echo -e "\nDone."

#----------------------------------------------------------------------------------------------------------------------#
# variable and recipe definitions for distribution/ publishing workflow
#----------------------------------------------------------------------------------------------------------------------#

# Go through the build process and publish AWS Lambda layer RC version
publish-lambda-layer-rc: aws-lambda
@python3.8 publish_lambda_layer.py rc
@echo -e "Done: Built the AWS Lambda layer and uploaded it to AWS."

#----------------------------------------------------------------------------------------------------------------------#
# recipes for local development
#----------------------------------------------------------------------------------------------------------------------#
Expand Down

0 comments on commit 70b3c78

Please sign in to comment.