I encountered an issue with CodeDeploy where deployments are failing, and the error message is as follows:
AfterInstall Failed
Event details
Error code
ScriptFailed
Script name
shell/after.sh
Message
Script at specified location: shell/after.sh run as user ubuntu failed with exit code 1
Logs
LifecycleEvent - AfterInstall
Script - shell/after.sh
[stderr]Traceback (most recent call last):
[stderr] File "/usr/bin/aws", line 19, in <module>
[stderr] import awscli.clidriver
[stderr] File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 17, in <module>
[stderr] import botocore.session
[stderr] File "/usr/lib/python3/dist-packages/botocore/session.py", line 29, in <module>
[stderr] import botocore.credentials
[stderr] File "/usr/lib/python3/dist-packages/botocore/credentials.py", line 35, in <module>
[stderr] from botocore.config import Config
[stderr] File "/usr/lib/python3/dist-packages/botocore/config.py", line 16, in <module>
[stderr] from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
[stderr] File "/usr/lib/python3/dist-packages/botocore/endpoint.py", line 22, in <module>
[stderr] from botocore.awsrequest import create_request_object
[stderr] File "/usr/lib/python3/dist-packages/botocore/awsrequest.py", line 24, in <module>
[stderr] import botocore.utils
[stderr] File "/usr/lib/python3/dist-packages/botocore/utils.py", line 32, in <module>
[stderr] import botocore.httpsession
[stderr] File "/usr/lib/python3/dist-packages/botocore/httpsession.py", line 10, in <module>
[stderr] from urllib3.util.ssl_ import (
[stderr]ImportError: cannot import name 'PROTOCOL_TLS' from 'urllib3.util.ssl_' (/home/ubuntu/.local/lib/python3.10/site-packages/urllib3/util/ssl_.py)
I noticed this issue might be related to my recent installation of zaproxy (OWASP ZAP), which may have introduced some Python packages incompatible with the system environment, such as urllib3. My local Python packages are installed in /home/ubuntu/.local/lib/python3.10/, and this seems to be conflicting with the system's global package versions.
Could the installation of zaproxy be causing the CodeDeploy deployment failures? How can I resolve the Python package version conflict to ensure both zaproxy and AWS CLI work correctly? Is there a way to isolate the zaproxy environment to prevent it from affecting other system tools?
The installation of zaproxy caused a conflict with the Python package. I have deleted all the extra zaproxy related packages. Codedeploy has returned to normal. I still need to find a way to isolate zaproxy.