Skip to content

Deploying the Full Stack#

First Time Setup#

Copilot is an official AWS tool used to quickly stand-up infrastructure in the cloud. For this project, it is responsible for setting up a backend service for running simulations (so no inbound internet-access, only outbound) an S3 bucket, and the distributed queuing system. In the future it may also include an API for generating jobs etc, but for now, it will be expected that such work is hosted locally. Note that it is also possible (and easier) to run with a managed version of the distributed queuing system hosted by Hatchet, which substantially simplifies the setup. Separate docs for that can be found below.

Prereqs#

  1. Install Docker.
  2. Install AWS CLI & AWS Copilot.
  1. Configure an AWS CLI profile if you have not done so already: aws configure --profile <your-profile-name>
  2. You will need a domain in order to access your hosted queue which you can configure CNAME records for. Some Route53 specific instructions may be added in the future, but for now it is assumed that you will manually configure the CNAME records at the indicated point in the process.
  3. Clone the repository: git clone https://github.com/szvsw/epengine.
  4. Move into the repository: cd epengine

Standing up the environment#

  1. copilot app init
  2. see app init help for more details like --permissions-boundary if needed
  3. copilot env init --name prod
  4. (see see init help for more details, as well as init manifest help for specs for VPCs etc.)
  5. TODO: instructions about CERTIFICATE_ARN env var interpolation.
  6. The next command will deploy an Aurora Serverless PostgresSql database, S3 bucket, and RabbitMQ broker.
  7. You may wish to turn on RabbitMQ console public accessibilty (ADD HOW)
  8. You may wish to set the instance sizes for RabbitMQ.
  9. You may wish to update the scaling capacities for Aurora Serverless.
  10. copilot env deploy --name prod
  11. copilot svc init --name hatchet-engine
  12. TODO: instructions about API_DOMAIN env var interpolation.
  13. copilot svc deploy --name hatchet-engine --env prod
  14. TODO: instructions about the FS_ID and FSAP_ID env var interpolation.
  15. copilot svc init --name hatchet-api
  16. copilot svc deploy --name hatchet-api --env prod
  17. Create a CNAME record to point at the load balancer (TODO: how to find the load balancer address).
  18. Visit your domain and either login with a new account & make a tenant, or login with the default creds: admin@example.com / Admin123!!
  19. Make an api token (General Settings > API Tokens). TODO: (automate token creation steps with a task run)
  20. copilot secret init --name HATCHET_CLIENT_TOKEN --overwrite then paste in your secret.
  1. copilot svc init --name hatchet-worker
  2. Authenticate to AWS ECR (TODO: add instructions).
  1. copilot svc deploy --name hatchet-worker --env prod

Scaling workers up and down#

In copilot/hatchet-worker/manifest.yml, you can edit the worker count configuration to determine how many workers you would like, if scaling should be done based off of CPU utilization, etc.

After making changes, run copilot svc deploy --name hatchet-worker --env prod.

Cleanup#

  1. Empty your buckets if they have files in them.
  2. copilot app delete