Skip to content

Infrastructure

Krzysztof Czopek edited this page Jul 4, 2022 · 1 revision

Overview

Name generator is a containerized Python web-server application running on an EC2 instance managed by ECS. It reads input data from an S3 bucket during startup.

CloudFormation

All AWS resources are defined in namehash/infra GitHub repository. The most important part of it is the {RootStack} variable, which is used throughout AWS to differentiate this service deployments. For the rest of this doc, we will assume {RootStack} === prod-name-generator.

Any changes to the infrastructure should be done by generating a change-set, inspecting it, and only then executing it. Be aware that infrastructure changes might destroy and recreate some resources - this might result in some relationships being broken, e.g. due to hard-coded IP addresses etc.

ECR

Docker image resides in ECR at 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator. A tag should be equal to the name of the {RootStack} it should be running on.

ECS

There is an ECS service defined as ${RootStack}-server, that is running tasks (at least 1 healthy) based on the NameGenerator task definition, which includes a docker container with the aforementioned ECR image.

S3

TODO

CloudWatch

All logs are gathered in the {RootStack} log group.

Deployment

To deploy changes made to the generator, follow these steps.

  1. Login to AWS ECR in Docker using aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator
  2. Build the image and tag it with appropriate tag, e.g. docker build -t 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator:prod-name-generator
  3. Push it to the ECR docker push 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator:prod-name-generator
  4. Force ECS service do redeploy image by running aws ecs update-service --cluster prod-name-generator --service prod-name-generator-server --force-new-deployment
Clone this wiki locally