Permalink
Browse files

Encode user_data in Base64 before sending it to boto

Boto tries to decode the user_data as Base64. If it fails, it will use
the field as clear-text. However, there are cases where a clear-text can
be interpreted as valid Base64 (if the padding is correct) and end up
being decoded as a binary string.
  • Loading branch information...
1 parent bbbb038 commit 1f9f1579f20db6bd30b4f5be0096f8761dddbf11 @priteau priteau committed Mar 8, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 pyhantom/system/epu/epu_client.py
@@ -248,7 +248,8 @@ def get_launch_configs(self, user_obj, names=None, max=-1, startToken=None):
ot_lc.SecurityGroups = AWSListType('SecurityGroups')
contextualization = dt_descr.get('contextualization')
if contextualization is not None and contextualization.get('method') == 'userdata':
- ot_lc.UserData = contextualization.get('userdata')
+ # UserData should be base64-encoded to be properly decoded by boto
+ ot_lc.UserData = base64.b64encode(contextualization.get('userdata'))
else:
ot_lc.UserData = None

0 comments on commit 1f9f157

Please sign in to comment.