EC2 userdata service

Similar to instance metadata, userdata is a facility that exists on every EC2 instance. You can use instance userdata to run a script when an instance is launched. In this example, we’ll launch a new instance and configure it to run a script – the one that we created in the last section. So, when the instance launches, it should upload a file to our S3 bucket with its instance ID.