You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+152Lines changed: 152 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,3 +29,155 @@ Validate that:
29
29
30
30
State is one of: active, offline, retired
31
31
32
+
# Project Usage
33
+
34
+
## Run with Docker Compose (default)
35
+
36
+
```bash
37
+
cp .env.example .env
38
+
# edit .env and set POSTGRES_PASSWORD
39
+
docker compose up --build
40
+
```
41
+
42
+
This starts `api` and `db`. The `tests` service runs once with verbose output and exits; it does not stop the stack. If you want the stack to stop right after tests, run:
43
+
44
+
```bash
45
+
docker compose up --build --abort-on-container-exit --exit-code-from tests
46
+
```
47
+
48
+
API is available at `http://localhost:8000`.
49
+
50
+
## CLI
51
+
52
+
```bash
53
+
python -m cli list
54
+
python -m cli get 1
55
+
python -m cli create srv-1 10.0.0.1 active
56
+
python -m cli update 1 srv-1b 10.0.0.2 offline
57
+
python -m cli delete 1
58
+
```
59
+
60
+
# Tests
61
+
62
+
Tests run automatically during `docker compose up --build`. You can also run them locally:
- Requires AWS CLI, Docker, and an existing ECS cluster/service.
112
+
- Task definition template lives in `deploy/aws/task-def.json`.
113
+
- The script builds and pushes the image to ECR, then updates the ECS service.
114
+
- This path expects an explicit `DATABASE_URL` (no Secrets Manager integration). Use the Terraform path if you want Secrets Manager + full infra provisioning.
115
+
116
+
# AWS Terraform Deployment (provision everything)
117
+
118
+
This path provisions the VPC, subnets, ALB, ECS Fargate, ECR repo, and RDS PostgreSQL via Terraform.
119
+
You only provide AWS credentials and a DB password.
120
+
121
+
Minimal (uses defaults):
122
+
123
+
```bash
124
+
./scripts/deploy_terraform_aws.sh
125
+
```
126
+
127
+
Optional overrides:
128
+
129
+
```bash
130
+
export AWS_REGION=us-east-1
131
+
export PROJECT_NAME=inventory
132
+
export DB_USERNAME=inventory
133
+
# Optional: pin Postgres engine version (otherwise latest available in region)
- The RDS password is generated randomly and stored in AWS Secrets Manager.
157
+
- ECS pulls `DATABASE_URL` directly from Secrets Manager at runtime.
158
+
- Terraform state will contain the generated secret value; store state securely (e.g., S3 + KMS).
159
+
- SSL/TLS requires a valid ACM certificate for your domain. For the automatic smoke test over HTTPS, set `API_DOMAIN_NAME` + `ROUTE53_ZONE_ID` so the script can hit a matching cert.
160
+
- RDS deletion protection and performance insights are enabled for security; disable them before `terraform destroy` if needed (cost impact).
161
+
162
+
# Terraform Security Checks
163
+
164
+
Run Terraform linting + security scans:
165
+
166
+
```bash
167
+
./scripts/terraform_security_checks.sh
168
+
```
169
+
170
+
This runs:
171
+
-`terraform fmt -check` and `terraform validate`
172
+
-`tfsec` and `checkov` via Docker for security posture checks
173
+
174
+
Notes:
175
+
- Some tfsec checks are intentionally suppressed for the public ALB and optional HTTP-only mode when ACM is not provided.
176
+
177
+
# Terraform Provider Version Check
178
+
179
+
To check for provider updates and refresh the lockfile:
0 commit comments