You need to create high-available micro-service under AWS.
Service has to listen on TCP port and return back to the client morse-code of clients IP address. AWS infrastructure have to
- be multi-region (f.e. us-east-1, eu-west-1, ap-southeast-1) and to respond from the nearest to client location
- be easy scalable
Answer should contain
- source code of micro-service
- terraform files or set of AWS cli instruction for the creation of infrastructure (if not all requirements are solvable by terraform - You shall describe additional steps)
- Clone repo
- Export AWS credentials:
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export AWS_DEFAULT_REGION=""
- Run terraform provision in terraform dir
terraform plan
terraform apply -auto-approve
- Login to instances
- Clone repo to instances
- Run listener on instances
python3 socket_listener.py
- Connect to load balancer endpoint
nc balancer-lb-tf-709a4a973898cb2c.elb.us-east-1.amazonaws.com 11000
#Result
On server:
ubuntu@ip-172-31-80-130:~$ python3 socket_listener.py
Sending b'.---- --... ..--- .-.-.- ...-- .---- .-.-.- ----. ..... .-.-.- .---- ----- -.... ' to 172.31.95.106
Sending b'----. ....- .-.-.- .---- ..... ---.. .-.-.- ---.. ..... .-.-.- .---- ...-- .---- ' to 94.158.85.131
Sending b'.---- --... ..--- .-.-.- ...-- .---- .-.-.- ----. ..... .-.-.- .---- ----- -.... ' to 172.31.95.106
On client:
➜ ~ nc balancer-lb-tf-709a4a973898cb2c.elb.us-east-1.amazonaws.com 11000
----. ....- .-.-.- .---- ..... ---.. .-.-.- ---.. ..... .-.-.- .---- ...-- .----