Skip to content

Instantly share code, notes, and snippets.

@horatiu-udrea
Last active March 6, 2021 08:20
Show Gist options
  • Save horatiu-udrea/c15518c6c5f74c8bdd3e2bddbd14541e to your computer and use it in GitHub Desktop.
Save horatiu-udrea/c15518c6c5f74c8bdd3e2bddbd14541e to your computer and use it in GitHub Desktop.
AWS Infrastructure proposal.md

1. Initial considerations

Some of the services that AWS provides could help us drastically reduce the time needed for application configuration, maintenance and deployment.

2. Conditions and invariants

Most of our existing and upcoming applications:

  • Use a frontend static website written in Angular/TypeScript and a dockerized backend written in Django/Python
  • Are not optimized for serverless computing
  • Make use of a PostgreSQL database

3. Overview of relevant AWS services

4. Infrastructure overview

See attached image

5. Usage Description

5.1. DNS

Route 53 will resolve the IPs of Load Balancer and static websites provided by CloudFront

5.2. CDN

CloudFront will serve the static websites stored in S3 buckets.

5.3. S3

Statics websites will be stored in S3 buckets, each site in each own separate bucket.
Deployment will be done through GitHub Actions

5.4. Load Balancer

The Load Balancer will be the access gateway to the EC2 virtual machines and the dockerized backends stored in them.
It will be managed by ECS, so no manual configuration is needed for networking, ports etc.

5.5. EC2

We will create an ECS cluster to hold all the backends.
For reduced cost, the cluster can be comprised of only one EC2 instance, same as before.

5.6. ECR

The docker images can be uploaded and stored to ECR to be easily used by ECS. This will be done through GitHub Actions.

5.7. RDS

It's not really a good idea to maintain a Postgres database by ourselves in a docker container. Making bakups is hard, error-prone and data loss might be disastrous. A managed RDS instance with automated backups and updates is the best way to go. All the instances can connect to it and have their own database there.

5.8. ECS

The Elastic Container Service is has 3 parts:

  • Cluster: A collection of virtual machines where containers can be run
  • Tasks: Definition of containers that need to run.
  • Service: Actually running and maintaining a task definition

ECS can also create a Load Balancer that links all the containers created by the running services.

Basically every Traefik configuration, docker network management, Docker compose manual ups and downs can be managed through a few clicks in the user interface.

5.9. Secrets manager

All the credentials will be stored in the Secrets Manager and the applications will have access to them through docker environment variables.

6. Cost considerations

Easier maintenance and configuration comes at a price. It should be worth it though.

  • An RDS managed instance can be reserved for 3 years and paid upfront, which will drastically reduce the cost.
  • For EC2 instances you pay based on the time it's running.
  • For the Load Balancer we pay a bit for keeping it running and also for how much traffic we get.
  • Secrets manager is very cheap and can be replaced with Parameter Store which is free.
  • ECS is free, only paying for the resources we create.

There are the rest of the costs that we already have, like CloudFront, Route 53, ECR where we pay for how much we store and same for S3.
Monthly estimates can be calculated using the AWS Pricing Calculator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment