in Education by
I want to automate the launch of a set of Linux EC2 instances. Basically, I want to write a script/program that would : Instantiate N occurrences of a given AMI of mine. For each started instance, it would upload a customized script and let the script run into the instance. Using VMWare, I would typically do that using vmrun or the Vix SDK. What are the options in Amazon AWS/EC2? Select the correct answer from above options

1 Answer

0 votes
by
The answer depends a bit on what AMI you are running as the features provided is entirely AMI dependent. The Amazon Linux AMIS and also the official Ubuntu AMIs have the cloud-init package installed. This incorporates a range of ways you'll be able to trigger startup actions, but the one that matches your request most closely (and my favourite because I invented it) is the concept of a user-data script. You can merely pass any script (starting with the 2 characters #!) as the user-data once beginning the EC2 instances. It will be run as root on the first boot of the instance. You also needed to run over one EC2 instance with a similar script. The ec2-run-instances command and also the related Apis and web console enable you to specify any range of instances, to begin with, constant user-data. For example: ec2-run-instances \ --instance-count 10 \ --user-data-file $MYSCRIPT \ --key $USER \ $SOMEAMI If you are currently running an AMI that does not have cloud-init installed, you could do one of: Switch to an AMI that has cloud-init installed, or Build a custom version of your AMI that has cloud-init installed, or Write a more sophisticated wrapper script that creates a record of all of the instance ids once they're beginning, waits for all of the instances to move to the running state, waits for the sshd to accept connections, uploads your startup script to each instance, and runs the startup script on each instance.

Related questions

0 votes
    How should I use the new AWS EC2 classes (r3, i2) with my existing AMI without recreating the whole system ... only PVM AMI images. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    Any easy way to move and custom AMI image between regions? (North Virginia -> Singapore) I know you can mess up with ... way to do it? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm creating an AMI for a server with 100G files. It's been like an hour and it's still not finished. (The ... it? What should I do? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm creating an AMI for a server with 100G files. It's been like an hour and it's still not finished. (The ... it? What should I do? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I want to migrate my webapp from Amazon EC2 to ECS. I ECS I have to allocate memory and vCPU for the ... needed for the process? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    When you setup an Auto Scaling groups in AWS EC2 Min and Max bounds seem to make sense: The minimum number of ... is larger than Min? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I want to list the public IP addresses of my EC2 instances using Bash, separated by a delimiter (space or ... something else entirely? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I ... user's guide. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have a local git repo and when I do a git push, I need the repo to be pushed to my EC2 instance. ... heads/*:refs/remotes/origin/* Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I installed Ubuntu 12.04 on my instance and am trying to install packages using apt-get, but I am getting the ... do I fix this? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    We currently use multiple web servers accessing one MySQL server and fileserver. Looking at moving to the cloud, ... another solution? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    I am trying to use aws container service as per the documentation in http://docs.aws.amazon.com/AmazonECS/latest/ ... in a console? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Bit confused here, I have an on-demand instance but do I get charged even when I stop the instance? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    How can I delete instance in Amazon EC2. I have terminated the instance but still it was showing in ... instance gets terminated Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I want to change the time zone set in my Amazon EC2 instance running Ubuntu Linux to local time. My Question ... zone in Amazon EC2? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...