How to use User Data? and Advantages of User Data?
AWS allows to run some commands/scripts at launch time of an instance which is known as user data. For example, you want to have certain packages installed or some configuration files to be present on the instance after the launch, user data is the thing you need. Whatever commands you specify in the user data gets executed and you get the stuff when instance is launched.
Let's try an example, install LAMP stack
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
sudo apt install php-cli -y
echo "<?php phpinfo(); ?>" | sudo tee -a /var/www/html/info.php
sudo apt install stress -y
No comments:
Post a Comment