Sample of an AWS EC2
userdata script that install
apache and automatically creates an
index.html file as a landing webpage with information about the instance -
region. This could also be used with launch configuration on an Auto Scaling Group (
ASG) to use as multiple instance on Elastic Load Balancing load balancer (
ALB) to easy show the usage of multiple instances behind the load balancer.
At your own risk, always review what you are running.
To run this userdata script, add the below into the EC2 userdata
#!/bin/bash curl https://raw.githubusercontent.com/AntonioFeijaoUK/aws-ec2-userdata-samples/master/sample01-hello-world-region-az.sh | bash
Repository is here https://github.com/AntonioFeijaoUK/aws-ec2-userdata-samples
Other samples on AWS
Sample EC2 with webserver - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html
SAmple EC2 metadata - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html
If you tried it and helped you understand better how it works, please leave a comment.