Developer Guide || AWS Setup Using ECS - SVF-tools/WebSVF GitHub Wiki
We recommend to use Elastic Container Service (ECS), if you require multiple user to have their own instances of WebSVF running.
ECS enable developers to make their application highly scalable, fast, and easy to manage using containers. Detailed information about ECS can be found here
Tasks within ECS are handled using AWS SDK for Javascript which are created programatically during user signup.
To Setup WebSVF on AWS ECS, you can follow the below steps:
Task Definition is where you will configure your container. You will be able to select the docker image, CPU and memory allocation, launch type, IAM roles etc.
Once you are in your Elastic Container Service page on AWS, click Task Definitions and then click "Create Task Definition".
After you have chosen to "create a new task definition", you will be prompted to select between EC2 and Fargate. Select EC2.
It will then finally take you to a page where you can configure your container. For WebSVF, you can replicate the below information on each field:
- Task Definition Name: Name of your choice
- Requires Compatibilities: EC2
- Task Role: Leave Blank i.e None
- Network Mode: default
- Task Execution Role: Create New Role
- Task Memory: 2024 (or more)
- Task CPU: 1024 (or more)
Also add the container by clicking on "Add Container". This is where you specify what container you will be running.
- Container Name: Name of your choice
- Image: winoooops/websvf-docker
- Container Port: 8080
Everything else for Task Definitions can have the default value
Then, click on "Create".
Cluster is basically just a group of tasks or services. More about clusters can be found here
To create a cluster, click on "Clusters" and then click on "Create Clusters".
You enter the values below for each fields:
-
Select Cluster Template
- EC2 Linux + Networking
-
Configure Cluster
- Cluster Name: Name of your Choice
- EC2 Instance Type: t2.medium i.e. minimum requirement is 4GB memory and 2 vCPU
- Keypair: Select an existing keypair (if any) or create a new one. Do not leave as "None"
- VPC: Select VPC (if any) or create a new one
- Subnets: Add all subnets from the dropdown
-
Security Group: Create a new Security Group
- Security Group needs to have all the TCP ports allowed from Anywhere (0.0.0.0/0)
- **Container Instance IAM Role: Create new role
Everything else for Clusters can be left as default
Click on "Create"
After your Task Definition and Cluster have been setup, you will need to configure the Launch Template for EC2 Instances that our containers will be running on.
Launch Templates are necessary in order to auto-scale our EC2 instances where are containers will be running.
Without Launch Instances, you will need to select the EC2 parameters every time you create a new EC2 Instance. More information about Launch Instances can be found here
To configure Launch Template, you will need to go the EC2 page, click on Launch Template and follow the below steps:
- Find the Launch Template that was created was ECS service associated with the cluster you created for WebSVF. It usually named as "EC2ConatinerService-<clustername>-......"
- Click on the Launch Template and ensure the configuration is correct. Check the "Instance type" and ensure t2.medium (or more) is selected.
- Optional: Test the Launch Template by create a new EC2 instance using this Launch template on AWS console.
That's it! AWS configuration set up is done. Everything else such as creating tasks upon new user signup, create new Instances to scale up our application is done using AWS SDK for Javascript.
- Clone the repository
- Navigate to "src/landing-page" and Remove "homepage" from package.json to run it on local host
- run
yarn install
to install all packages - run
yarn start
to run app on localhost - change the AWS credentials