Skip to content

Instantly share code, notes, and snippets.

View amcginlay's full-sized avatar

Alan McGinlay amcginlay

View GitHub Profile
@amcginlay
amcginlay / simpleweb.sh
Last active July 17, 2019 15:43
AWS EC2 Simple Web Server
#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
echo "<html><h1>This is Webserver X</h1></html>" > /var/www/html/index.html
@amcginlay
amcginlay / wordpress.sh
Last active February 27, 2024 12:07
AWS EC2 Wordpress
#!/bin/bash
yum update -y
yum install httpd php php-mysql -y
cd /var/www/html
echo "healthy" > healthy.html
wget https://wordpress.org/wordpress-5.1.1.tar.gz
tar -xzf wordpress-5.1.1.tar.gz
cp -r wordpress/* /var/www/html/
rm -rf wordpress
rm -rf wordpress-5.1.1.tar.gz
@amcginlay
amcginlay / mountdisk.sh
Last active November 13, 2020 17:51
Mounting A Linux Disk Device (EBS)
sudo su - # operation requires root privileges
lsblk # to see devices and mounts, MOUNTPOINT is empty for the new device
NEW_DEVICE=xvdf # change as appropriate
# to mount a new device
file -s /dev/${NEW_DEVICE} # will display "data" if no file system is present
mkfs -t ext4 /dev/${NEW_DEVICE} # will install ext4 on device
mkdir /filesystem
mount /dev/${NEW_DEVICE} /filesystem
@amcginlay
amcginlay / mysql.sh
Last active August 6, 2019 12:15
AWS EC2 MySQL
#!/bin/bash
yum update -y
yum install httpd php php-mysql -y
chkconfig httpd on
service httpd start
echo "<?php phpinfo();?>" > /var/www/html/index.php
cd /var/www/html
wget https://s3.amazonaws.com/acloudguru-production/connect.php
@amcginlay
amcginlay / codedeploy.sh
Last active August 6, 2019 12:14
Install CodeDeploy agent on your EC2 instance
#Install CodeDeploy agent on your EC2 instance:
sudo yum update -y
sudo yum install ruby
sudo yum install wget
cd /home/ec2-user
wget https://aws-codedeploy-eu-central-1.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent status
#Create your application.zip and load it into CodeDeploy:
@amcginlay
amcginlay / amazon-linux-docker.sh
Created August 20, 2019 21:45
Install docker on an Amazon LInux EC2 instance
# as per https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
sudo yum update -y
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
@amcginlay
amcginlay / ubuntu-linux-docker.sh
Last active November 27, 2019 19:23
Install docker on an Ubuntu instance
# Ubuntu ONLY! Amazon Linux instructions here:
# (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html#install_docker)
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -a -G docker ubuntu
sudo reboot
@amcginlay
amcginlay / amazon-linux-nodejs-server
Last active October 15, 2019 17:20
nodejs server user data - example request: curl localhost/?workload=1000
#!/bin/bash
#############
# 1. Copy this script into EC2 User Data
# 2. Enable Cloudwatch detailed monitoring
# Usage: "curl localhost:80/?workload=1000"
#############
yum update -y
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
@amcginlay
amcginlay / kinesis-data-stream-demo
Last active November 11, 2019 12:14
Kinesis data stream demo
# assumes a data stream named "demo-stream" with one shard exists
# inspect data stream and copy identity SHARD_ID variable (e.g. ShardId-????)
aws kinesis list-streams
STREAM_NAME=demo-stream
aws kinesis describe-stream --stream-name ${STREAM_NAME}
SHARD_ID=shardId-000000000000
# add four records
@amcginlay
amcginlay / kinesis-firehose-demo
Last active October 15, 2019 17:18
Kinesis Firehose demo
# assumes a kinesis firehose delivery system is in place (e.g. demo-firehose-stream)
# NodeJS Lambda function to append CRs as follows with a timeout > 1 min
# Configure this to deposit results in S3
console.log('Loading function');
exports.handler = async (event, context) => {
/* Process the list of records and transform them */