aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

--user-data doens't work for me

Open dgolja opened this issue 12 years ago • 2 comments

Hey guys,

I have trouble running aws ec2 run-instances with --user-data.

I did try to pass a bash script as an argument to --user-data, but nothing get executed after ec2 get booted. So for example

aws ec2 run-instances ... --user-data PATH_TO_BAS_FILE, doesn't do nothing.

Also I did try with the same bash file encoded in base64, but again nothing.

Even I tried to pass the encoded base64 bash script as an argument, but again nothing. (example aws ec2 run-instances ... --user-data IyEvYmluL2Jhc2g....),

However If I run the same script via the AWS console as an user data everything works fine.

From the documentation it only says:

--user-data (blob)

Specifies additional information to make available to the instance(s). This parameter must be passed as a Base64-encoded string.

So I am a bit confused now, because doesn't really make sense to pass the entire cloud init bash script as an base64 encoded string (doesn't work anyway). Wouldn't make much more sense to pass an path to the file ?

Anyone any hint or maybe a working example.

Tnx...

dgolja avatar Dec 29 '13 11:12 dgolja

Try something like this:

USER_DATA=cat userdata.sh ''' The cat userdata.sh should be enclosed in backticks.

Then you should be able to pass the --user-data $USER_DATA just fine

digitaljedi2 avatar Dec 29 '13 13:12 digitaljedi2

Hey,

actually I just found the "solution" tnx to https://github.com/aws/aws-cli/issues/366. The issue is that the documentation is wrong. As soon I used file:// everything worked like a charm :)

dgolja avatar Dec 29 '13 13:12 dgolja