|
1 | | -# Welcome to your CDK TypeScript project |
| 1 | +# ODK Central CDK Deployment |
2 | 2 |
|
3 | | -This is a blank project for CDK development with TypeScript. |
| 3 | +This repository contains an AWS CDK stack to deploy a **minimal instance of [ODK Central](https://docs.getodk.org/central-install/)** on a single EC2 instance. |
4 | 4 |
|
5 | | -The `cdk.json` file tells the CDK Toolkit how to execute your app. |
| 5 | +The stack provisions: |
6 | 6 |
|
7 | | -## Useful commands |
| 7 | +- A public EC2 instance running Ubuntu with Docker and Docker Compose |
| 8 | +- Automatic installation and launch of ODK Central |
| 9 | +- Route 53 DNS record pointing to the instance |
| 10 | +- ACM certificate for HTTPS |
| 11 | +- Optional environment variable injection from AWS Secrets Manager |
| 12 | +- Configurable disk size and AMI |
8 | 13 |
|
9 | | -* `npm run build` compile typescript to js |
10 | | -* `npm run watch` watch for changes and compile |
11 | | -* `npm run test` perform the jest unit tests |
12 | | -* `npx cdk deploy` deploy this stack to your default AWS account/region |
13 | | -* `npx cdk diff` compare deployed stack with current state |
14 | | -* `npx cdk synth` emits the synthesized CloudFormation template |
| 14 | +Once the stack is running, you can access ODK Central via the provided domain name. |
| 15 | +You'll also need to connect to the instance via one of the AWS connection methods (SSH, SSM, etc.) to complete the setup. |
| 16 | +Follow the ODK Central guide on [setting up users](https://docs.getodk.org/central-install-digital-ocean/#logging-into-central) to set up an admin user. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 📦 Prerequisites |
| 21 | + |
| 22 | +- Node.js (>= 16) |
| 23 | +- AWS CDK v2 |
| 24 | +- AWS CLI with appropriate credentials (or use `--profile`) |
| 25 | +- A Route 53 public hosted zone |
| 26 | +- An EC2 key pair (to SSH in if needed) |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## 🛠 Configuration |
| 31 | + |
| 32 | +Edit your `cdk.json` file to set the deployment context: |
| 33 | + |
| 34 | +```json |
| 35 | +{ |
| 36 | + "context": { |
| 37 | + "domainName": "oxrse.uk", |
| 38 | + "fullDomainName": "odk-central-test.oxrse.uk", |
| 39 | + "secretName": "odk-central/env-vars", |
| 40 | + "keyName": "your-keypair-name", |
| 41 | + "instanceVolumeSize": 30, |
| 42 | + "ubuntuAmiId": "ami-079b5e5b29763ec7c" |
| 43 | + } |
| 44 | +} |
| 45 | +```` |
| 46 | + |
| 47 | +| Key | Description | |
| 48 | +| -------------------- | ----------------------------------------------------------------------------- | |
| 49 | +| `domainName` | Root domain (must exist in Route 53) | |
| 50 | +| `fullDomainName` | Fully-qualified domain name (used in DNS and SSL cert) | |
| 51 | +| `secretName` | (Optional) Name of an AWS Secrets Manager secret with env vars (JSON format) | |
| 52 | +| `keyName` | Name of your existing EC2 key pair | |
| 53 | +| `instanceVolumeSize` | Root volume size in GB | |
| 54 | +| `ubuntuAmiId` | AMI ID for a basic Ubuntu image (no LVM), recommended for clean disk resizing | |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## 🚀 Deploy |
| 59 | + |
| 60 | +```bash |
| 61 | +cdk deploy --profile your-aws-profile |
| 62 | +``` |
| 63 | + |
| 64 | +This will: |
| 65 | + |
| 66 | +1. Lookup your Route 53 zone |
| 67 | +2. Launch a t3.micro EC2 instance |
| 68 | +3. Install Docker, Docker Compose, and ODK Central |
| 69 | +4. Configure HTTPS via ACM |
| 70 | +5. Inject environment variables from Secrets Manager (if configured) |
| 71 | +6. Set up a DNS A record pointing your FQDN to the instance |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## 🔐 Secrets Format |
| 76 | + |
| 77 | +If you use the `secretName` context key, the secret's value should be a **JSON object** of key-value pairs. For example: |
| 78 | + |
| 79 | +```json |
| 80 | +{ |
| 81 | + "DOMAIN": "odk-central-test.oxrse.uk", |
| 82 | + "EMAIL": "admin@example.com", |
| 83 | + "SSL_TYPE": "letsencrypt" |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +These will be made available to the instance as shell environment variables and appended to ODK Central’s `.env`. |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## 🧼 Cleanup |
| 92 | + |
| 93 | +To destroy all provisioned resources: |
| 94 | + |
| 95 | +```bash |
| 96 | +cdk destroy --profile your-aws-profile |
| 97 | +``` |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## 📝 Notes |
| 102 | + |
| 103 | +* This deployment is **not hardened for production** — it’s suitable for short-term testing and evaluation. |
| 104 | +* The EC2 instance is assigned a public IP and open security group (ports 22, 80, 443). |
| 105 | +* No NAT Gateway or private subnets are used — it’s a flat public deployment. |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## 📎 License |
| 110 | + |
| 111 | +MIT — © University of Oxford, 2025 |
0 commit comments