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.
For the No reboot setting, you can select the Enable check box to prevent Amazon EC2 from shutting down and rebooting the instance. If you choose to enable No reboot, we can't guarantee the file system integrity of the created image.
Windows: Admin password (for which private key is required to decrypt) is not needed because some other user is an admin. Caution: If you launch an instance with no keypair and don't have any of the above mentined ways to access the instance, you have to relaunch the instance with a keypair.
There is no option under EC2 to create an instance without starting it. Once you create an instance it will automatically will move from pending to running state
Docs - http://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With