📔 Helpful gists

September 12, 2019

Table of Contents

  1. Proxy React App
  2. Resize EC2

Proxy React App

Add the "proxy" property to package.json:

  • {
    "name": "app",
    "version": "1.0.0",
    "private": true,
    "dependencies": {
      "react": "^16.9.0",
      "react-dom": "^16.9.0",
      "react-scripts": "3.1.1"
    },
    "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test --env=jsdom",
      "eject": "react-scripts eject"
    },
    "proxy": "http://localhost:<PORT-OF-API-HERE>"
    }

Edit http requests to follow

  • axios.get("http://localhost:<PORT-OF-API-HERE>/example");
    // or
    fetch("http://localhost:<PORT-OF-API-HERE>/example");

To

  • axios.get("/example");
    // or
    fetch("/example");

Resize EC2 Root

  • Power down services

    • Disable anything that has a + or is listed as start/running with the appropriate commands.
    • Obviously environements will differ
    • #Check services and shutdown any needed
      sudo service --status-all
  • Create a snapshot of the EBS volume you need to resize.
  • Create the new volume with the id of the snapshot you created in the previous step.

    • Make sure to create the new volume in the same datacenter.
  • Attach new EBS Volume

    • Detach the old volume and attach the new volume to the root filesystem /dev/sda1
    • After you do this you will need to go to the Elastic IP tab and reattach the EIP to the EC2 instance.
    • Once everything is reattached you are good to restart the EC2 instance.
  • Resizing

    • Restart and reconnect to the EC2 instance
    • Run sudo df -h
    • graham@node:~$ sudo df -h
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sda1        15G  9.5G  4.0G  71% /
    • Run resize2fs /dev/sda1
    • Re-Run sudo df -h
    • graham@node:~$ sudo df -h
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sda1        30G  9.5G  20.5G  31% /
    • After this you’re good to restart services and start your application.