nealalan.github.io/tf-201812-nealalan.com

Project Goal

Prereqs

Files

This repo contains two use to contain two files:

Steps / Commands

I used…

  1. git clone this repo
  2. terraform init
  3. terraform plan
  4. terraform apply
  5. ssh -i priv_key.pem ubuntu@ip
  6. curl https://raw.githubusercontent.com/nealalan/tf-201812-nealalan.com/master/install.sh > install.sh
  7. chmod +x ./install.sh
  8. .install.sh

Optional:

Result

My server is at static IP 18.223.13.99 serving https://nealalan.com and https://neonaluminum.com with redirects from all http:// addresses

NEXT STEPS

As you move around you’ll need to log in to the AWS Console and add your local IP address to the EC2: Network ACLs. Here’s an example of one I had in the past… Also, I now have the flexibility to totally recreate the websever through a few small script changes if I make major site changes, add a new domain name or need to upgrade to the latest LTS of Ubuntu.

Installing MariaDQ

And setting it to have a Root PW…

$ sudo apt install mariadb-client
$ sudo apt install mariadb-server
$ sudo passwd root (NealAlanDreher12)
$ sudo mysql -u root
# Disable plugin authentication for root
> use mysql;
> update user set plugin='' where User='root';
> flush privileges;
> exit
$ sudo systemctl restart mariadb.service
$ sudo mysql_secure_installation
# verity root auth works
$ sudo mysql -u root
$ sudo mysql -u root -p

Fixing Errors

Within a few days I messed up my Ubuntu instance. The solution was clearly going to take longer than 15 minutes. So here’s what I did, thanks to terraform:

  1. Grab what is managed by terraform
  2. Mark the Ubuntu instance as tainted for destruction
    terraform taint aws_instance.wb
    
  3. Verify what will happen (a side effect was my ACLs and SGs will be cleaned up since I was running an outdated lab that requried me to open some ports)
    $ terraform plan
    

  4. Run!
    $ terraform apply
    
  5. Setup Ubuntu to host my webserver again
    $ curl https://raw.githubusercontent.com/nealalan/tf-201812-nealalan.com/master/install.sh > install.sh
    $ chmod +x ./install.sh
    $ .install.sh
    
  6. Consider using virtuanenv or even running another EC2 instance when I want to plan with some labs?!?!?! I can alwauys assign a subdomain to a lab instance.

[edit]