Skip to content

Commit

Permalink
Merge pull request #17 from arnavrneo/dev
Browse files Browse the repository at this point in the history
[README]
  • Loading branch information
arnavrneo authored Apr 11, 2024
2 parents 791260d + e72347c commit 8626503
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 35 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# url.ly - a url-shortener service

This project aims to implement a decoupled & scalable architecture for url shortener service.

# Architecture

This project uses:
- `Nextjs` as its frontend;
- `Golang` & `Expressjs` as the backend servers configured with Nginx for load-balancing;
- `MongoDB` as non-relational db for authentication
- `Redis` as in-memory key-value db for url keys management

- For scalability and portability, both the frontend and backend are containerized using Docker and can be spun-up easily using docker-compose.
- Ansible playbooks and roles are used for automating the service setup & infrastructure creation of single (or multiple) EC2 on AWS. They are used for:
- Creation of a security group (with relevant properties) for EC2 instances
- Creation of EC2 instances & attaching of the defined security group
- Installation of Docker on those instances
- Running of the url-shortener service through user input
86 changes: 51 additions & 35 deletions url-shortener/playbook/1_create_ec2.yaml
Original file line number Diff line number Diff line change
@@ -1,68 +1,84 @@
---
-
-
name: Create EC2 instances
hosts: localhost_group
connection: local
hosts: localhost
become: true
connection: local
gather_facts: false

vars_prompt:
- name: aws_profile
- name: aws_profile
prompt: "Enter aws profile: "
private: False
private: false

- name: region
prompt: "Enter region: "
private: False
private: false
default: us-east-1


- name: sec_group
prompt: "Enter security group id: "
private: false
# default: "sg-012wxxxxx"

- name: sg_desc
prompt: "Desc about Security Group: "
private: false
default: Custom Security Group

- name: image
prompt: "Enter ami-id: "
private: False
default: ami-080e1f13689e07408
private: false
default: ami-080e1f13689e07408 # ubuntu

- name: instance_type
prompt: "Enter instance type: "
private: False
private: false
default: t2.micro

- name: sec_group
prompt: "Enter security group id: "
private: False
#default: "sg-012wxxxxx"

- name: key_name
prompt: "Enter key name: "
private: false
default: ansible

- name: count
prompt: "Enter count of instances: "
private: false
default: 1


tasks:
- name: Create SG
- name: Create Security Group
amazon.aws.ec2_security_group:
name: "{{ sec_group }}"
description: "Test sg"
region: "{{ region }}"
aws_profile: "{{ aws_profile }}"
rules:
- proto: tcp
ports:
- 22
cidr_ip: 0.0.0.0/0
rule_desc: allow_ssh
name: "{{ sec_group }}"
description: "{{ sg_desc }}"
region: "{{ region }}"
aws_profile: "{{ aws_profile }}"
rules:
- proto: tcp
ports:
- 22
cidr_ip: 0.0.0.0/0
rule_desc: allow_ssh

- proto: tcp
ports:
- proto: tcp
ports:
- 3000
cidr_ip: 0.0.0.0/0
rule_desc: frontend-exposed


cidr_ip: 0.0.0.0/0
rule_desc: frontend-exposed

- name: Create an instance
amazon.aws.ec2_instance:
key_name: ansible
key_name: "{{ key_name }}"
aws_profile: "{{ aws_profile }}"
instance_type: "{{ instance_type }}"
region: "{{ region }}"
image_id: "{{ image }}"
security_group: "{{ sec_group }}"
network:
assign_public_ip: true
assign_public_ip: true
wait: true
exact_count: 1
exact_count: "{{ count }}"
tags:
Ansible: urlShortenerServer

Expand Down

0 comments on commit 8626503

Please sign in to comment.