Home > Net >  userdata partially working but not installing boto3 on ec2 launch, have to explicitly install it
userdata partially working but not installing boto3 on ec2 launch, have to explicitly install it

Time:01-18

the userdata script for my ec2:

#!/bin/bash
curl https://raw.githubusercontent.com/erjan/MyVoteAWS/main/vote-processor/processor.py > /home/ec2-user/processor.py
cd /home/ec2-user/
sudo chmod  x processor.py
sudo yum -y install python3-pip
sudo yum -y install python3 python3-setuptools
pip3 install boto3 --user                   #this is not executed
./processor.py

the file processor.py is pulled from my github, i do see it, but its not launched cuz it needs boto3 - gives error

"Import error: no boto3 module found"

i have to wait till it shows '2/2 checks passed' in the aws gui, then connect, then do explicitly type "pip3 install boto3 --user", then i see progress bar downloading boto3, then my script processor.py works.

but it does not work out of box from userdata. What is the reason?

CodePudding user response:

Please run your script using python3

python3 processor.py

Otherwise it runs probably under python2, which does not have boto3 installed.

  • Related