code:
import boto.ec2
conn_ec2 = boto.ec2.connect_to_region('us-east-1')
my_code = """#!/usr/bin/env python
import sys
sys.stdout = open('file', 'w')
print 'test'
"""
reservation = conn_ec2.run_instances(image_id = 'ami-a73264ce',
key_name = 'backendkey',
instance_type = 't1.micro',
security_groups = ['backend'],
instance_initiated_shutdown_behavior = 'terminate',
user_data = my_code)
The instance starts up with the correct settings (this is public Ubuntu 12.04, 64-bit, image), and I can use SSH in it normally. The user script data seems to load correctly: I see this in /var/lib/cloud/instance/user-data.txt(and also in /var/lib/cloud/instance/scripts/part-001) and on the EC2 console.
But what he, the script does not seem to be running. After this answer, I checked the file /var/log/cloud-init.log, but it does not seem to contain error messages related to my script (well, maybe I am missing something - this is the essence of the contents of cloud-init.log).
What am I missing?