0

I have create EC2 instance(name: firstinstance) and install my application on it. Then I have created AMI image using the above instance Then I have created EC2 instance(name: secondinstance) from AMI image

But now I want to update the yml configuration file in EC2(secondinstance). I don't want to do it during creation of secondinstance using userdata. My AMI image automatically run the provided script after creation of EC2 instance using that Image. How can I do it?

I have tried setting the following in User data of firstinstance. It doesn't get created in secondinstance

touch /tmp/testfile.txt

Whenever anyone create the EC2 instance using AMI image, that instance should run the provided script after creation of that instance

Galet
  • 5,853
  • 21
  • 82
  • 148
  • What's wrong with using UserData on the `secondinstance`? – Marcin Dec 01 '20 at 09:45
  • @Marcin Many users will use my AMI image like secondinstance. User shouldn't do that. AMI image should take care of script to run post creation of EC2 instance – Galet Dec 01 '20 at 09:51
  • I see. Then you have to make custom solution for that. There are may ways allowing you to run scripts on first boot only, e.g. [here](https://serverfault.com/questions/853396/run-script-on-first-boot). So before you make your AMI, you set it up witch such script. Then any new instance from the AMI will run the script only once. – Marcin Dec 01 '20 at 09:58

0 Answers0