diff --git a/cloudformation-telemetry/deploy.sh b/cloudformation-telemetry/deploy.sh deleted file mode 100644 index 52494af..0000000 --- a/cloudformation-telemetry/deploy.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -rm src/external/*.pyc -rm src/*.pyc -rm telemetry.zip - -if [ ! -f telemetry.zip ]; then - echo "creating zip file" - mkdir python - cd python - pip3 install crhelper -t . - pip3 install sumologic-appclient-sdk -t . - pip3 install future_fstrings -t . - pip3 install setuptools -t . - cp -v ../* . - zip -r ../telemetry.zip . - cd .. - rm -r python -fi diff --git a/cloudformation-telemetry/install_python_dependencies.sh b/cloudformation-telemetry/install_python_dependencies.sh new file mode 100644 index 0000000..552385e --- /dev/null +++ b/cloudformation-telemetry/install_python_dependencies.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Pull the Amazon Linux image from Docker Hub +docker pull amazonlinux + +# Run the Amazon Linux container in detached mode +docker run -d --name telemetry amazonlinux tail -f /dev/null + +# Install Python, pip, and other dependencies inside the container +docker exec -it telemetry /bin/bash -c "yum update -y && yum install -y python3-pip zip && python3 -m pip install virtualenv" + +# Create a virtual environment and install dependencies +docker exec -it telemetry /bin/bash -c "python3 -m venv temp-venv && source temp-venv/bin/activate && mkdir telemetry && cd telemetry && pip install crhelper sumologic-appclient-sdk future_fstrings setuptools -t ." + +# Copy python file from host to container +docker cp ./lambda_function.py telemetry:/telemetry + +# Zip the contents of the telemetry directory +docker exec -it telemetry /bin/bash -c "cd telemetry && ls -l && zip -r ../telemetry.zip ." + +# Copy the telemetry.zip file from the container to the host +docker cp telemetry:/telemetry.zip ./telemetry.zip + +# Stop and remove the container +docker stop telemetry +docker rm telemetry \ No newline at end of file