aws:script: bootstrap_instance.sh

#!/bin/bash
IMAGE=ami-09479453c5cde9639
SSH_KEY_NAME=key1
INSTANCE_TYPE=m1.small
# INSTANCE_TYPE=t2.large
SECURITY_GROUP=sg-88a7d0c8
CODE_NAME_TAG=ins5

aws ec2 run-instances \
--image-id $IMAGE \
--key-name $SSH_KEY_NAME \
--instance-type $INSTANCE_TYPE \
--security-group-ids $SECURITY_GROUP  \
--tag-specifications "ResourceType=instance,Tags=[{Key=ScriptName,Value=$CODE_NAME_TAG}]" \
--user-data file://bootstrap_scrip.txt

bootstrap_scrip.txt

#!/bin/bash
yum update -y
yum install -y httpd24 php70 mysql56-server php70-mysqlnd
service httpd start
chkconfig httpd on
groupadd www
usermod -a -G apache ec2-user
chown -R root:www /var/www
chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php