Comment 6 for bug 461156

Revision history for this message
Scott Moser (smoser) wrote : Re: User data is not base64 decoded before being presented to the instance

A bit more data...
I'm fairly sure that the correct thing to do here is just to remove the following two lines from main() in euca-run-instances:
| if user_data:
| user_data = base64.urlsafe_b64encode(user_data)

Also 'import base64' on line 37 could then be removed as this is the only place base64 is used.

The reason we dont need this encoding is that boto is doing it for us.

In euca-run-instances, the following are the lines that matter:

| if user_data:
| user_data = base64.urlsafe_b64encode(user_data)
| euca_conn = euca.make_connection()
| try:
| reservation = euca_conn.run_instances(image_id = image_id,
| min_count = min_count,
| max_count = max_count,
| key_name = keyname,
| security_groups = group_names,
| user_data = user_data,
...

euca.make_connection in euca2ools/euca2ools/__init__.py returns a connection that is created with:
   return boto.connect_ec2()

Then, we call euca_conn.run_instances. run_instances in boto/ec2/connection.py does:
| if user_data:
| params['UserData'] = base64.b64encode(user_data)

So, the user data is getting encoded twice.