EC2 and AMI create automation with a file to run

55 views Asked by At

In AWS, can I automate the following steps?

  1. Create an instance
  2. With scp, transfer a binary file to run a proxy server on top of this instance
  3. ssh into the instance
  4. update the crontab in the instance
  5. Create an image from this instance

This is a simple job; I might just do it manually but using API call, I can do this totally automatically?

I already know how to do step 1 and 5 but how do I automate 2, 3, 4?

Thanks!

1

There are 1 answers

0
helloV On BEST ANSWER
  1. Launch the instance and wait for the status to become running
  2. scp: Get the IP/PublicDNS (as long as you can access the instance) and invoke scp -i

scp -i your-private-key proxy_binary user@IP:dest-dir

  1. and
  2. You have to use expect to automate 3 and 4. Google for expect to automate ssh and configure a machine. If you are not familiar with expect, there is some learning curve.