ocadotechnology / rapid-router

A Blockly and python based educational game aimed at students age 5-14.
https://www.codeforlife.education
Other
57 stars 75 forks source link

Setup AWS resources #1684

Closed SKairinos closed 1 month ago

SKairinos commented 1 month ago

We wish to deploy the contributor service on AWS as it's Ocado's approved cloud platform. Ocado has a platform called chancellor, which helps orchestrate your cloud resources on AWS. Using chancellor, we need the following resources to be allocated on AWS:

  1. PostgreSQL database
  2. An app/service deployment for contributor-backend

Laura got this guidance when chatting with Ocado's tech support.

Once you allocate these services online, deploy the contributor-backend service to AWS and connect the service to the DB.

SalmanAsh commented 1 month ago

Useful Notes Till now chancellor token can be retrieved from the OTP UI: https://otpui.devtools.osp.tech/settings if you'll be using this in a gitlab pipeline you might want to set up a servec user for your team There's a Chancellor API which returns all the AWSS Account details, including business https://chancellor.pages.tech.lastmile.com/docs/api/provisioning/aws-account If you creating a brand new application deploying to the atmosphere dev (dev-atm)) account will be OK as your first deploy. You create an appId in registry first, then an application context in atm-dev, then an RDS for your application context Chancellor Docs - Core Concepts To deploy the Contributor service on AWS using Chancellor, follow these steps: Step 1: Provision a PostgreSQL Database Access Chancellor to provision a RDS on AWS : There is no UI. The API, CLI, and Terraform are your options. For the CLI option, you have to set up Nexus Credentials. You can achieve these using Aldi. Once ALDI set is completed. You will find the credentials in file .config/NuGet/NuGet.Config. If chancellor command is not found: do (find ~/.local/bin -name 'chancellor'). Configure the Database: Engine: PostgreSQL Once you've created an RDS you'll be able to see it in the AWS Console when you login with your Developer Role https://aws.oca.do/ Step 2: Deploy Contributor-Backend Service Step 3: Connect the Service to the Database Step 4: Post-Deployment (edited)

SalmanAsh commented 1 month ago

Deploy to GCP

NOTE: You might want to add the following features in the dev container: "ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {}, "ghcr.io/dhoeric/features/google-cloud-cli:1": {},

Step 1: Set Up Google Cloud SQL Proxy -Download the Cloud SQL Proxy curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.12.0/cloud-sql-proxy.linux.amd64 -Make the Cloud SQL Auth Proxy executable chmod +x cloud-sql-proxy

Step 2: Authenticate the Proxy with Google CLI gcloud auth login gcloud auth application-default login

Step 3: Run the Cloud SQL Proxy ./cloud-sql-proxy INSTANCE_CONNECTION_NAME ./cloud-sql-proxy decent-digit-629:europe-west1:contributor (use this for contributor backend developent)

Step 4: Install the psql client from the package manager.

sudo apt-get update
sudo apt-get install postgresql-client

Step 5: Connect to your database using the psql client.

psql "host=127.0.0.1 port=5432 sslmode=disable dbname=DB_NAME user=postgres"
psql "host=127.0.0.1 port=5432 sslmode=disable dbname=development user=postgres"              

(use this for contributor backend developent)

Step 6: Deploy the Django Application (contributor).

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": "development",
        "USER": "postgres",
        "PASSWORD": "",  ###
        "HOST": "127.0.0.1",
        "PORT": "5432",
    }
}

Step 7: Migrate the DB. python manage.py migrate

SalmanAsh commented 1 month ago

One Potential solution: Pull Mirror