Published 1月 08, 2020 by with 0 comment

Amazon EC2 - Labs - 02 - User Data


AWS > Compute > Amazon Elastic Compute Cloud (EC2):
When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts.

You can auto run update, install sofrware, run individual command when instance boot up.

To retrieve user data from within a running instance, use the following URL.
http://169.254.169.254/latest/user-data

Lab Configuration:
#!/bin/bash
# software update
yum update -y
# Install httpd
yum install -y httpd
# Enable httpd service
service httpd start
# Make sure http always on next reboot
chkconfig httpd on
# Touch a index.html and Remove the "*"
cd /var/www/html
echo "<*html><*h1>Hello World!<*/h1><*/html>" > index.html
# Make a bucket
aws s3 mb s3://weoirsdlkfjxc
# Backup the index.html to S3 bucket
aws s3 cp index.html s3://weoirsdlkfjxc



Reference:
1. AWS Documentation - Running Commands on Your Linux Instance at Launch:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

2. Udemy - AWS Solutions Architect - Associate:
https://www.udemy.com/aws-certified-solutions-architect-associate/


最初發表 / 最後更新: 2020.01.08 / 2020.01.08

0 comments:

張貼留言