Amazon Web Services (AWS) : EC2-User Data
EC2 - user data is one of the seldom used features, yet a powerful feature.
It is basically a simple script which can is executed at boot time by the system, the script has sudo
It can be used for -
• Installing updates
• Installing software
• Downloading common files from the internet
• Anything you can think of
It is configured in Advanced section of the Instance Launch Page.
Below is an example of apache Service install and launch using an ec2-script.
#!/bin/bash yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "Heloo World" > /var/www/html/index.html/index.html
It is basically a simple script which can is executed at boot time by the system, the script has sudo
It can be used for -
• Installing updates
• Installing software
• Downloading common files from the internet
• Anything you can think of
It is configured in Advanced section of the Instance Launch Page.
Below is an example of apache Service install and launch using an ec2-script.
#!/bin/bash yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "Heloo World" > /var/www/html/index.html/index.html
The greatest of the use of EC2-user data is when using load balancing, starting parallel instances and any boot time action you want to perform (manually or automatically).
Remember - the header #!/bin/bash is mandatory and without it your script will not work.
Remember - the header #!/bin/bash is mandatory and without it your script will not work.