Create EC2 instance without starting

amazon-ec2, amazon-web-services, aws-cli

Solution

So as I was telling to @pt12lol in the comments, this is exactly what userdata is for.

From Amazon's documentation:

When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2: shell scripts and cloud-init directives. You can also pass this data into the launch wizard as plain text, as a file (this is useful for launching instances via the command line tools), or as base64-encoded text (for API calls).

User-datas can be passed to the instance at creation time, for instance using the `--user-data` flag in the `aws` cli or the Userdata text box in AWS console.

Problem

I would like to create some EC2 instance, but before it starts do some stuff using instance ID generated for this instance. Is there any option in `aws ec2 run-instances` or another `aws ec2` command for creating an AWS EC2 instance without starting it? A workaround would be generating UUID to tag this instance and associate this UUID instead of instance ID, or stopping just after run instance, but I would prefer some smarter solution.

Original source