Managing CS-AWS Docker Compose

Our CS Docker Compose test instance is hosted on an Amazon EC2 server instance. The instance was setup following the instructions found on Sourcegraph.com. To manage cloud resources and networking you must have Sourcegraph AWS/EC2 IAM credentials, learn more here. You can access the instance from the Url below:

https://cse-aws-test.sgdev.org/

(note the URL reflects the former title on the team)

SSH into instance to run Docker CLI commands

To access the CS-AWS server and run Docker commands you’ll need to create a Secure Shell (SSH) connection. Instructions to configure this connection are found below:

  1. Create a directory from which you’ll run commands to access CS AWS:
    $ mkdir cse-aws
  2. Within cse-aws create a file cse-aws.pem:
    $ touch cse-aws.pem
  3. Populate cse-aws.pem with its RSA private key by copying the key from 1Password into the file with your editor of choice. Copy the whole block including -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----.
  4. Finally set its permissions such that only the root user can read it:
    $ chmod 400 cse-aws.pem

Now that you’ve set up your SSH access credentials you can use the following command from inside the directory containing the cse-aws.pem:

ssh -i "cse-aws.pem" ec2-user@ec2-3-133-49-142.us-east-2.compute.amazonaws.com

You may also add the pem key to a .ssh directory and use the following command:

ssh -i .ssh/cse-aws.pem ec2-user@ec2-3-133-49-142.us-east-2.compute.amazonaws.com

Upgrading CS-AWS

Note: When connecting to the EC2 server via SSH, your user does not have permissions to run many git commands. You’ll need to run git commands with sudo or switch to the root user with sudo su. Note that docker-compose is not available to the root user, use exit to switch back to ec2-user and run compose commands.

Upgrading CS-AWS follows the standard procedure for upgrading a compose instance. The EC2 instance points at a fork of deploy-sourcegraph-docker. Any customizations should be applied to the override file rather than the default docker-compose.yaml file. Learn more about docker compose override files.

DNS

DNS for cse-aws is handled by our GCP terraform infrastructure: https://github.com/sourcegraph/infrastructure/blob/main/dns/sgdev.tf#L332-L338 application of changes here requires terraform apply to take effect on our GCP infrastructure