amazon-web-servicesamazon-ec2ec2-api-tools

AWS start instance from cmd line specifying args to launch script


I need to be able to startup AWS EC2 instances quickly from one of my AMI images and at launch run a script to bootstrap the instance. I know I can do this with user data but I need to be able to pass the script an argument that will be different each time the instance is started.

If I use Start-EC2Instance from AWS Tools I cant see a way to either pass the user data or pass agrs to the launch script.

Any help would be much appreciated.

Thanks


Solution

  • You are looking at the wrong command. Take a look at New-EC2Instance

    Synopsis
    
    Invokes the RunInstances method against Amazon Elastic Compute Cloud.
    Syntax
    
    New-EC2Instance
    -ImageId <String>
    ....
    -UserData <String>
    -UserDataFile <String>
    ....
    Description
    
    Launches a specified number of instances of an AMI for which you have permissions.