AWS EC2

Hunter Long edited this page Dec 4, 2018 · 11 revisions

Running Statping on the smallest EC2 server is very quick using the AWS AMI Image. When the AMI image boots it will automatically run the init.sh script to update Docker containers and remove unused containers/images. The server will also re-download the init.sh script to make sure it is up-to-date with the latest updates and bug fixes.

AMI Image

Choose the correct AMI Image ID based on your AWS region.

  • us-east-1 ami-b3be85cc
  • us-east-2 ami-cc7a40a9
  • us-west-1 ami-6d1ffd0e
  • us-west-2 ami-7be8a103

Then set the image with a environment variable: AMI_IMAGE=ami-7be8a103

EC2 Server Features

Running your Statping server on a small EC2 instance is perfect for most users. Below you'll find some commands to get up and running in seconds.

  • Super cheap on the t2.nano (~$4.60 monthly)
  • Small usage, 8gb of hard drive
  • Automatic SSL certificate if you require it
  • Automatic upgrades for Ubuntu packages
  • Automatic reboot when the server needs it
  • Automatic database cleanup, so you'll never be at 100% full.
  • Automatic docker containers/images removal

Create Security Groups

Using the AWS CLI you can copy and paste the commands below to auto create everything for you. The server opens port 80 and 443.

aws ec2 create-security-group --group-name StatpingPublicHTTP --description "Statping HTTP Server on port 80 and 443"
# will response back a Group ID. Copy ID and use it for --group-id below.
GROUPS=sg-7e8b830f
aws ec2 authorize-security-group-ingress --group-id $GROUPS --protocol tcp --port 80 --cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress --group-id $GROUPS --protocol tcp --port 443 --cidr 0.0.0.0/0

Create EC2 without SSL

Once your server has started, go to the EC2 Public DNS endpoint. You should be redirected to /setup to continue your installation process! The database information is already inputed for you.

GROUPS=sg-7e8b830f
KEY=MYKEYHERE
AMI_IMAGE=ami-7be8a103

aws ec2 run-instances \
    --image-id $AMI_IMAGE \
    --count 1 --instance-type t2.nano \
    --key-name $KEY \
    --security-group-ids $GROUPS

Create EC2 with Automatic SSL Certification

Start a Statping server with an SSL cert that will automatically regenerate when it's near expiration time. You'll need to point your domain's A record (IP address) or CNAME (public DNS endpoint) to use this feature.

wget https://raw.githubusercontent.com/hunterlong/statping/master/dev/ec2-ssl.sh
# edit the contents inside of ec2-ssl.sh then continue
LETSENCRYPT_HOST="status.MYDOMAIN.com"
LETSENCRYPT_EMAIL="noreply@MYEMAIL.com"

Edit ec2-ssl.sh and insert your domain you want to use, then run command below. Use the Security Group ID that you used above for --security-group-ids

GROUPS=sg-7e8b830f
AMI_IMAGE=ami-7be8a103
KEY=MYKEYHERE

aws ec2 run-instances \
    --user-data file://ec2-ssl.sh \
    --image-id $AMI_IMAGE \
    --count 1 --instance-type t2.nano \
    --key-name $KEY \
    --security-group-ids $GROUPS

EC2 Server Specs

  • t2.nano ($4.60 monthly)
  • 8gb SSD Memory
  • 0.5gb RAM
  • Docker with Docker Compose installed
  • Running Statping, NGINX, and Postgres
  • boot scripts to automatically clean unused containers.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.