RPG based on a board game.
Setting up the development environment is required to make the experiments. Markdown Cheat Sheet
- Install "pipenv" Windows
- Copy Pipfile and "pfile.lock" to project directory.
- Open command line in project directory.
- Execute
pipenv install --ignore-pipfile
All these configuration is done in the Amazon Console and it is adviced to select a 3-5 letters prefix to distinguish the settings created in this section from any other setting that were already in the console:
- First of all, create a virtual private cloud (VCP), mine has the following values ---make sure the intended Availability Zone is selected:
- IPv4 CIDRs: 10.1.0.0/16
- IPv6 CIDRs:
- Once VPC is created, go to the "Your VPCs" page and make sure "Edit DNS hostnames" and "Edit DNS resolution" are both Enabled (from "Actions" menu)
- Create an "Internet Gateway" (look for that name in the VPCs page) and assign it to the VPC:https://console.aws.amazon.com/vpc/home?region=us-east-1#RouteTables:
- Create a Route Table and associate it to the VPN:
- Routes:
- Destination:10.1.0.0/16 (see how it corresponds to the VPC CIDR); Target: local (this will route traffic in the EC2 network)
- Destination: 0.0.0.0/0 (everybody); Target: Select the Internate Gateway from previous step (this will rout traffic comming from Internet).
- Create a Network ACL:
- Add an Inbound rule to allow HTTP(port 80) and HTTPs(port 443) traffic.
- Add an Outbound rule to provide the same access.
- This step is key to allow access to the EC2 instance: Create a "Security Group". Since VPC works with IPv4 addresses only select IPv4 rules remove any IPv6 one:
- Add an Inbound rule to allow HTTP(port 80) and HTTPs(port 443) traffic.
- Add an Outbound rule to provide the same access.
- Add another set of Inbound/Outbound rules for SSH(port 22).
- Create a couple subnets for the VPC:
- Subnet to enable external access:
- Name: public
- IPv4 CIDRs: 10.1.1.0/24
- Associate to the VPC, Route Table and Network ACL created in previous steps. Important: By associating this subnet to the Route Table,the subnet will be accessible from the Internet.
- Subnet for internal networking only:
- Name: private
- IPv4 CIDRs: 10.1.1.0/24
- Associate the VPC and Network ACL created in previous steps. Do NOT associate the private network to the Route Table. That way it will be hidden from the outside world.
This part is done in the Instances view of AWS Console: https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Instances:v=3
- Go to "AMI Catalog" in the "Images" section of left panel and chose an Amazon Machine Image (AMI). I chosed an Ubuntu based one.
- Select the VPC created in previous section, the public subnet and for Auto-assign Public IP choose Enable.
- Be careful and select just the free-tier image, nothing more sophisticated is required; I selected t2.micro image type.
- When prompted what credentials to use, chose the RSA keys of your preference or create a new one. Ths step is required to access the VPC for development and maintenance. The document referenced in this link shows how to access the EC2 instance using PuTTY: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html
For now just login to the EC2 instance, install flask and provide a basic web page:
- Login (see previous section)
- Install required software
sudo apt update
sudo apt install python3-pip
pip3 install flask
sudo pip3 install flask
- Create a sample flask application (save it as app.py):
from flask import Flask
app = Flask(__name__)
# Defining the home page of our site
@app.route("/") # this sets the route to this page
def home():
return "Hello! this is the main page <h1>HELLO</h1>" # some basic inline html
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
- Start the sample application
sudo flask run --host="0.0.0.0" --port=80
- Go to the EC2 instance and open the public DNS/IP