Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue in running user-data script AWS EC2

Is it possible to run python script through AWSCLI (user-data). I tried but it didn't run and i have following in my logs

boot.log:2015-08-07 10:08:30,660 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: './step-1
cloud-init.log:2015-08-07 10:08:30,660 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: './step-1'
cloud-init-output.log:2015-08-07 10:08:30,660 - __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart) userdata: './step-1'

Note step-1 is my script which i am trying to pass as user-data . Also my script is present in same directory from where i am running command so it should pick

like image 614
pkm Avatar asked Aug 07 '15 10:08

pkm


1 Answers

The default interpreter seems to be Python. So if you simply want to execute a shell script you'll need to start with a hash-bang, for example:

#!/bin/bash 
/yourpath/step-1

Please note, in order to debug this, try: cat /var/log/cloud-init-output.log And see: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-shell-scripts

like image 63
Axel Podehl Avatar answered Sep 17 '22 14:09

Axel Podehl