grada-run 0.0.1 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/.github/workflows/deploy-docs.yml +37 -0
  2. package/.github/workflows/iac-validation.yml +303 -0
  3. package/.github/workflows/publish.yml +68 -0
  4. package/.github/workflows/sync-bedrock-models.yml +57 -0
  5. package/.github/workflows/test.yml +43 -0
  6. package/.muserules +31 -0
  7. package/LICENSE +21 -0
  8. package/README.md +193 -3
  9. package/apps/docs/.astro/collections/docs.schema.json +644 -0
  10. package/apps/docs/.astro/content-assets.mjs +4 -0
  11. package/apps/docs/.astro/content-modules.mjs +4 -0
  12. package/apps/docs/.astro/content.d.ts +179 -0
  13. package/apps/docs/.astro/data-store.json +1 -0
  14. package/apps/docs/.astro/dev.json +14 -0
  15. package/apps/docs/.astro/settings.json +5 -0
  16. package/apps/docs/.astro/types.d.ts +2 -0
  17. package/apps/docs/astro.config.mjs +97 -0
  18. package/apps/docs/package.json +17 -0
  19. package/apps/docs/src/content/docs/adrs/0001-s3-native-state-locking.md +37 -0
  20. package/apps/docs/src/content/docs/adrs/0002-eject-mechanism-pure-iac.md +39 -0
  21. package/apps/docs/src/content/docs/adrs/0003-sync-ai-context-strategy.md +48 -0
  22. package/apps/docs/src/content/docs/adrs/0004-iac-driven-diagnostic-context.md +37 -0
  23. package/apps/docs/src/content/docs/adrs/0005-ecs-fargate-alb-runtime-target.md +38 -0
  24. package/apps/docs/src/content/docs/adrs/0006-github-oidc-no-stored-keys.md +37 -0
  25. package/apps/docs/src/content/docs/adrs/0007-framework-detection-with-fallback.md +37 -0
  26. package/apps/docs/src/content/docs/adrs/0008-secrets-names-in-git-values-in-aws.md +37 -0
  27. package/apps/docs/src/content/docs/adrs/0009-regenerate-with-backup-on-rerun.md +37 -0
  28. package/apps/docs/src/content/docs/adrs/0010-advisory-only-security-scans.md +37 -0
  29. package/apps/docs/src/content/docs/cli/add.md +84 -0
  30. package/apps/docs/src/content/docs/cli/apply.md +32 -0
  31. package/apps/docs/src/content/docs/cli/db.md +200 -0
  32. package/apps/docs/src/content/docs/cli/destroy.md +31 -0
  33. package/apps/docs/src/content/docs/cli/diagnose.md +37 -0
  34. package/apps/docs/src/content/docs/cli/doctor.md +28 -0
  35. package/apps/docs/src/content/docs/cli/domain.md +57 -0
  36. package/apps/docs/src/content/docs/cli/drift.md +40 -0
  37. package/apps/docs/src/content/docs/cli/eject.md +29 -0
  38. package/apps/docs/src/content/docs/cli/exec.md +49 -0
  39. package/apps/docs/src/content/docs/cli/gc.md +37 -0
  40. package/apps/docs/src/content/docs/cli/init.md +72 -0
  41. package/apps/docs/src/content/docs/cli/logs.md +39 -0
  42. package/apps/docs/src/content/docs/cli/rollback.md +51 -0
  43. package/apps/docs/src/content/docs/cli/secrets.md +73 -0
  44. package/apps/docs/src/content/docs/cli/sleep.md +53 -0
  45. package/apps/docs/src/content/docs/cli/status.md +34 -0
  46. package/apps/docs/src/content/docs/cli/sync-ai.md +27 -0
  47. package/apps/docs/src/content/docs/guides/architecture.md +87 -0
  48. package/apps/docs/src/content/docs/guides/aws-credentials.md +72 -0
  49. package/apps/docs/src/content/docs/guides/background-workers.md +45 -0
  50. package/apps/docs/src/content/docs/guides/cicd-pipeline.md +64 -0
  51. package/apps/docs/src/content/docs/guides/database-connections.md +64 -0
  52. package/apps/docs/src/content/docs/guides/docker-compose.md +37 -0
  53. package/apps/docs/src/content/docs/guides/dockerfiles.md +46 -0
  54. package/apps/docs/src/content/docs/guides/ephemeral-pr-previews.md +39 -0
  55. package/apps/docs/src/content/docs/guides/examples.md +50 -0
  56. package/apps/docs/src/content/docs/guides/frameworks.md +88 -0
  57. package/apps/docs/src/content/docs/guides/headless.md +75 -0
  58. package/apps/docs/src/content/docs/guides/quickstart.md +52 -0
  59. package/apps/docs/src/content/docs/guides/rerun-init.md +43 -0
  60. package/apps/docs/src/content/docs/guides/secrets-management.md +83 -0
  61. package/apps/docs/src/content/docs/guides/understanding-your-bill.md +63 -0
  62. package/apps/docs/src/content/docs/index.mdx +103 -0
  63. package/apps/docs/src/content/docs/migrations/astro-vercel-to-aws.md +55 -0
  64. package/apps/docs/src/content/docs/migrations/heroku-procfile-to-aws.md +41 -0
  65. package/apps/docs/src/content/docs/migrations/nextjs-vercel-to-aws.md +51 -0
  66. package/apps/docs/src/content/docs/migrations/sveltekit-vercel-to-aws.md +63 -0
  67. package/apps/docs/src/content/docs/roadmap.md +97 -0
  68. package/apps/docs/src/content/docs/testing-strategy.md +32 -0
  69. package/apps/docs/src/content.config.ts +7 -0
  70. package/apps/docs/src/custom.css +14 -0
  71. package/apps/docs/tsconfig.json +6 -0
  72. package/bin/cli.js +140 -0
  73. package/package.json +105 -6
  74. package/scripts/sync-bedrock-models.js +22 -0
  75. package/scripts/test-iac.js +261 -0
  76. package/specs/add-redis-sqs-bedrock.md +128 -0
  77. package/specs/add-storage-dynamodb.md +106 -0
  78. package/specs/bedrock-model-catalog.md +131 -0
  79. package/specs/ci-pipeline.md +17 -0
  80. package/specs/cost-transparency.md +115 -0
  81. package/specs/custom-domains-and-ses.md +153 -0
  82. package/specs/database-suite-expansion.md +151 -0
  83. package/specs/db-connect.md +69 -0
  84. package/specs/db-lifecycle-migrations.md +159 -0
  85. package/specs/dependency-aware-init.md +176 -0
  86. package/specs/deploy-stack-to-grada-run-rebrand.md +45 -0
  87. package/specs/deployment-safety.md +170 -0
  88. package/specs/diagnose.md +16 -0
  89. package/specs/docs-hub.md +16 -0
  90. package/specs/dx-polish.md +46 -0
  91. package/specs/exec.md +25 -0
  92. package/specs/finops-cron-drift.md +161 -0
  93. package/specs/gc.md +26 -0
  94. package/specs/integration-suite.md +16 -0
  95. package/specs/logs.md +32 -0
  96. package/specs/rollback-live-polling.md +40 -0
  97. package/specs/secrets-pull-audit.md +51 -0
  98. package/specs/serverless-lambda-target.md +133 -0
  99. package/specs/status.md +31 -0
  100. package/specs/telemetry-and-spawn-hardening.md +69 -0
  101. package/specs/telemetry-hardening.md +35 -0
  102. package/src/commands/add.js +1111 -0
  103. package/src/commands/apply.js +214 -0
  104. package/src/commands/db/backup.js +229 -0
  105. package/src/commands/db/connect.js +304 -0
  106. package/src/commands/db/enable-vector.js +344 -0
  107. package/src/commands/db/import.js +604 -0
  108. package/src/commands/db/migrate.js +477 -0
  109. package/src/commands/db/restore.js +361 -0
  110. package/src/commands/db.js +87 -0
  111. package/src/commands/destroy.js +217 -0
  112. package/src/commands/diagnose.js +460 -0
  113. package/src/commands/doctor.js +109 -0
  114. package/src/commands/domain.js +685 -0
  115. package/src/commands/drift.js +243 -0
  116. package/src/commands/eject.js +127 -0
  117. package/src/commands/exec.js +222 -0
  118. package/src/commands/gc.js +250 -0
  119. package/src/commands/init.js +649 -0
  120. package/src/commands/logs.js +256 -0
  121. package/src/commands/rollback.js +323 -0
  122. package/src/commands/secrets.js +485 -0
  123. package/src/commands/sleep.js +347 -0
  124. package/src/commands/status.js +309 -0
  125. package/src/commands/sync-ai.js +115 -0
  126. package/src/commands/wake.js +337 -0
  127. package/src/core/parser.js +126 -0
  128. package/src/core/telemetry.js +244 -0
  129. package/src/data/bedrock-models.json +896 -0
  130. package/src/utils/addons.js +126 -0
  131. package/src/utils/ai-rules.js +59 -0
  132. package/src/utils/args.js +91 -0
  133. package/src/utils/aws.js +178 -0
  134. package/src/utils/backup.js +69 -0
  135. package/src/utils/bedrock-catalog.js +511 -0
  136. package/src/utils/capabilities.js +500 -0
  137. package/src/utils/command.js +65 -0
  138. package/src/utils/db-tunnel.js +164 -0
  139. package/src/utils/detector.js +298 -0
  140. package/src/utils/dockerCompose.js +65 -0
  141. package/src/utils/domains.js +73 -0
  142. package/src/utils/ecs-runner.js +289 -0
  143. package/src/utils/ecs.js +92 -0
  144. package/src/utils/frameworks.js +55 -0
  145. package/src/utils/generator.js +527 -0
  146. package/src/utils/hcl.js +426 -0
  147. package/src/utils/lambda-ecr.js +185 -0
  148. package/src/utils/prompts.js +278 -0
  149. package/src/utils/rds.js +131 -0
  150. package/src/utils/resolvers.js +174 -0
  151. package/src/utils/sleep-state.js +140 -0
  152. package/src/utils/sleep-targets.js +139 -0
  153. package/src/utils/system.js +42 -0
  154. package/src/utils/terraform.js +70 -0
  155. package/src/utils/visualizer.js +381 -0
  156. package/src/utils/warnings.js +49 -0
  157. package/templates/README.md +150 -0
  158. package/templates/docker/django.Dockerfile +40 -0
  159. package/templates/docker/go.Dockerfile +23 -0
  160. package/templates/docker/nestjs.Dockerfile +33 -0
  161. package/templates/docker/nextjs.Dockerfile +55 -0
  162. package/templates/docker/node.Dockerfile +24 -0
  163. package/templates/docker/nuxt.Dockerfile +47 -0
  164. package/templates/docker/python.Dockerfile +38 -0
  165. package/templates/docker/rails.Dockerfile +59 -0
  166. package/templates/docker/static.Dockerfile +32 -0
  167. package/templates/docker/svelte.Dockerfile +52 -0
  168. package/templates/github/deploy-lambda.yml +120 -0
  169. package/templates/github/deploy.yml +138 -0
  170. package/templates/github/drift.yml +112 -0
  171. package/templates/github/preview-lambda.yml +86 -0
  172. package/templates/github/preview.yml +69 -0
  173. package/templates/github/teardown.yml +43 -0
  174. package/templates/terraform/addons/bedrock.tf +34 -0
  175. package/templates/terraform/addons/cron-lambda.tf +78 -0
  176. package/templates/terraform/addons/cron.tf +101 -0
  177. package/templates/terraform/addons/dynamodb.tf +73 -0
  178. package/templates/terraform/addons/redis.tf +64 -0
  179. package/templates/terraform/addons/s3.tf +143 -0
  180. package/templates/terraform/addons/ses.tf +73 -0
  181. package/templates/terraform/addons/sqs.tf +67 -0
  182. package/templates/terraform/backend.tf +22 -0
  183. package/templates/terraform/cloudfront-lambda.tf +80 -0
  184. package/templates/terraform/cloudfront.tf +80 -0
  185. package/templates/terraform/database-aurora-postgresql.tf +92 -0
  186. package/templates/terraform/database-mysql.tf +72 -0
  187. package/templates/terraform/database.tf +71 -0
  188. package/templates/terraform/main-lambda.tf +229 -0
  189. package/templates/terraform/main.tf +296 -0
  190. package/templates/terraform/network.tf +95 -0
  191. package/templates/terraform/oidc.tf +64 -0
  192. package/templates/terraform/secrets.tf +31 -0
  193. package/templates/terraform/worker.tf +69 -0
  194. package/tests/__snapshots__/generator.test.js.snap +9633 -0
  195. package/tests/add.test.js +2037 -0
  196. package/tests/ai.test.js +94 -0
  197. package/tests/apply.test.js +488 -0
  198. package/tests/args.test.js +86 -0
  199. package/tests/aws.test.js +244 -0
  200. package/tests/capabilities.test.js +307 -0
  201. package/tests/cli.test.js +29 -0
  202. package/tests/command.test.js +100 -0
  203. package/tests/commands-import.test.js +74 -0
  204. package/tests/db.test.js +2704 -0
  205. package/tests/destroy.test.js +391 -0
  206. package/tests/detector.test.js +79 -0
  207. package/tests/diagnose.test.js +779 -0
  208. package/tests/doctor.test.js +202 -0
  209. package/tests/domain.test.js +899 -0
  210. package/tests/drift.test.js +243 -0
  211. package/tests/ecs.test.js +130 -0
  212. package/tests/eject.test.js +65 -0
  213. package/tests/exec.test.js +380 -0
  214. package/tests/gc.test.js +496 -0
  215. package/tests/generator.test.js +794 -0
  216. package/tests/headless.test.js +562 -0
  217. package/tests/lambda-ecr.test.js +185 -0
  218. package/tests/logs.test.js +447 -0
  219. package/tests/parser.test.js +160 -0
  220. package/tests/rds.test.js +244 -0
  221. package/tests/resolvers.test.js +282 -0
  222. package/tests/rollback.test.js +692 -0
  223. package/tests/secrets.test.js +752 -0
  224. package/tests/sleep-wake.test.js +1016 -0
  225. package/tests/status.test.js +370 -0
  226. package/tests/system.test.js +70 -0
  227. package/tests/telemetry.test.js +520 -0
  228. package/tests/terraform.test.js +84 -0
  229. package/tests/visualizer.test.js +496 -0
  230. package/vitest.config.js +9 -0
  231. package/index.js +0 -2
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: apply
3
+ description: Provision or update your AWS infrastructure with Terraform.
4
+ ---
5
+
6
+ Run the Terraform plan/apply flow against the generated configuration.
7
+
8
+ ## What it does
9
+
10
+ - Verifies you are in a grada project (`terraform/main.tf` must exist), exiting otherwise, so `apply` never runs against the wrong directory.
11
+ - Renders an infrastructure preview from your Terraform config and framework detection: a `Fixed Baseline` monthly figure with per-service breakdown, one topology entry per provisioned [`add`](/grada/cli/add/) addon (collapsing to a single `Addons (N)` line when three or more are active), and a one-line `Usage-based (N addons)` summary of metered billing drivers (shown only when usage-billed addons are present). With `--dry-run` it stops there and provisions nothing.
12
+ - Otherwise runs `terraform init -upgrade` followed by `terraform apply -auto-approve` in `terraform/`, streaming progress, then prints the live URLs from the Terraform outputs (`cloudfront_url` and `alb_direct_url`, or `api_gateway_url` on `--target lambda`) plus the `git push` command that deploys your app and clears the initial 503.
13
+ - On `--target lambda` projects, ensures the ECR repository exists first and seeds a minimal placeholder image under `:latest` when nothing has been pushed yet (Lambda rejects empty repositories), so Day-0 provisioning succeeds before the first code push.
14
+ - Asks for confirmation after the preview; declining aborts without provisioning anything.
15
+ - If the S3 state bucket is missing (e.g. deleted manually), offers to recreate it and resume automatically instead of failing.
16
+ - If the environment is asleep (a `.grada/sleep-state.json` entry exists), warns you to run [`wake`](/grada/cli/sleep/) first — applying would start tasks against a stopped database.
17
+ - On the known GitHub OIDC provider conflict (`EntityAlreadyExists` for `token.actions.githubusercontent.com`), tells you to set `create_oidc_provider = false` in `terraform/oidc.tf` and re-run; other failures print the Terraform error and the manual `cd terraform && terraform apply` fallback.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ npx grada-run apply
23
+ npx grada-run apply --dry-run
24
+ ```
25
+
26
+ ## Flags
27
+
28
+ | Flag | Description |
29
+ | ---- | ----------- |
30
+ | `--dry-run` | Render a preview of the planned changes without applying them. |
31
+
32
+ `apply` shells out to the `terraform` binary in your generated `terraform/` directory and streams progress while it runs.
@@ -0,0 +1,200 @@
1
+ ---
2
+ title: db
3
+ description: Tunnel to, migrate, back up, and restore your managed RDS database.
4
+ ---
5
+
6
+ Run migrations, create safety checkpoints, and restore your managed database — all from the terminal, without ever exposing the database to the public internet.
7
+
8
+ ## Commands
9
+
10
+ ```bash
11
+ npx grada-run db connect # Open a secure local tunnel
12
+ npx grada-run db migrate --cmd "<command>" # Run migrations inside your VPC
13
+ npx grada-run db backup # Create a snapshot checkpoint
14
+ npx grada-run db restore <snapshot-id> # Restore from a snapshot
15
+ npx grada-run db enable-vector # Enable pgvector for AI embeddings
16
+ npx grada-run db import --file <dump.sql> # Import a SQL dump
17
+ ```
18
+
19
+ All commands work across engines: RDS PostgreSQL, RDS MySQL 8.0, and Aurora PostgreSQL Serverless v2 (see `--db-engine` in [init](/grada/cli/init/)). `db connect` prints `mysql://` URIs and tunnels to port `3306` for MySQL, and discovers Aurora clusters via `<project-name>-db-cluster` automatically.
20
+
21
+ ## db connect
22
+
23
+ Connect your local tools (psql, DBeaver, DataGrip) or a local `.env` file directly to your isolated RDS instance. The command tunnels through a running ECS container as a jump host.
24
+
25
+ - Finds your RDS database (`<project-name>-db`, `<project-name>-db-cluster` for Aurora, or the `<workspace>` variants for PR-preview environments) and reads its endpoint and managed credentials from Secrets Manager.
26
+ - Prints the local host, port, database name, username, and a copy-pasteable `postgresql://` connection string. The password stays masked as `********` unless you pass `--show-credentials`.
27
+ - Finds a running container for the current project automatically and opens the tunnel via the Session Manager port-forwarding session. Press Ctrl+C to close it.
28
+ - Resolves its inputs automatically: cluster, service, and region (same order as `exec`: explicit flag → environment variable → `terraform/main.tf` → default).
29
+ - When no database is provisioned, or no containers are running, explains what to do (`init`/`apply`/`status`) and exits 1 instead of failing cryptically.
30
+ - On expired AWS credentials, points you to `aws sso login` / `aws configure` and exits 1 instead of throwing.
31
+ - Emits a `db_connect_run` telemetry event recording success and outcome. Credentials are never included in telemetry.
32
+
33
+ ```bash
34
+ npx grada-run db connect
35
+ npx grada-run db connect --port 5544
36
+ npx grada-run db connect --show-credentials
37
+ npx grada-run db connect --workspace pr-123
38
+ ```
39
+
40
+ Paste the printed connection string into DBeaver, or export it locally:
41
+
42
+ ```bash
43
+ export DATABASE_URL="postgresql://dbadmin:<password>@localhost:5432/<dbname>"
44
+ ```
45
+
46
+ The printed connection string already percent-encodes special characters in the username and password (AWS-generated passwords often contain `@`, `[`, or `/`). The standalone `Password:` line is shown verbatim — encode it yourself if you build a URI by hand instead of copying ours.
47
+
48
+ | Flag | Description |
49
+ | ---- | ----------- |
50
+ | `--port <port>` | Local port for the tunnel (defaults to the remote database port: `5432` for PostgreSQL/Aurora, `3306` for MySQL). Must be a number between 1 and 65535. |
51
+ | `--show-credentials` | Reveal the decrypted password in the terminal output. Masked by default. |
52
+ | `--workspace <name>` | Target a PR-preview environment (e.g. `--workspace pr-123`). Falls back to the workspace in `.terraform/environment`. |
53
+ | `--cluster <name>` | Explicit cluster name override. |
54
+ | `--service <name>` | Explicit service name override. |
55
+ | `--region <region>` | Explicit AWS region override. |
56
+
57
+ ## db migrate
58
+
59
+ Run schema migrations or seed scripts (Prisma, Drizzle, Alembic, Django, Rails, or anything custom) inside your VPC as a short-lived ECS task — no tunnel, no local database access needed. Logs stream live to your terminal, and the command exits with your migration's own exit code.
60
+
61
+ When you omit `--cmd`, the project is inspected for a known migration setup (`db:migrate` / `migrate` npm scripts, Prisma, Drizzle, Alembic, Django, Rails) and the detected command is used (in CI) or offered for confirmation (interactively).
62
+
63
+ When your task definition carries discrete `DB_*` credentials, the command synthesizes the engine-matching `DATABASE_URL` at runtime — with `PGSSLMODE=require` for PostgreSQL, since RDS/Aurora enforces `rds.force_ssl = 1`.
64
+
65
+ ```bash
66
+ npx grada-run db migrate --cmd "npx prisma migrate deploy"
67
+ npx grada-run db migrate # auto-detect the command
68
+ npx grada-run db migrate --cmd "npm run db:seed" --timeout 1200
69
+ ```
70
+
71
+ | Flag | Description |
72
+ | ---- | ----------- |
73
+ | `--cmd <command>` | Migration command to run. Auto-detected when omitted. |
74
+ | `--task-def <task-def>` | Task definition (ARN or `family:revision`) to run. Defaults to the live service revision. |
75
+ | `--timeout <seconds>` | Give up after this long (default `600`). The task is stopped automatically. |
76
+ | `--setup-ci` | Install the pre-deploy migration gate into `.github/workflows/deploy.yml` instead of running. |
77
+ | `--project-name <name>` | Explicit project name override. |
78
+ | `--workspace <name>` | Target a PR-preview environment. |
79
+ | `--cluster <name>` | Explicit cluster name override. |
80
+ | `--service <name>` | Explicit service name override. |
81
+ | `--container <name>` | Explicit container name override. |
82
+ | `--region <region>` | Explicit AWS region override. |
83
+
84
+ ### Pre-deploy migration gate
85
+
86
+ `db migrate --setup-ci` adds a step to your deploy workflow that runs migrations against the newly built image **before** the ECS service updates — a failing migration halts the release automatically:
87
+
88
+ ```bash
89
+ npx grada-run db migrate --cmd "npx prisma migrate deploy" --setup-ci
90
+ ```
91
+
92
+ The step is re-installed cleanly on every run, so re-running the command updates the wired migration command in place.
93
+
94
+ ## db backup
95
+
96
+ Create a point-in-time safety checkpoint of your database (a cluster snapshot for Aurora) before risky operations like migrations or restores. The command waits until the snapshot is ready, then prints the restore command for it.
97
+
98
+ ```bash
99
+ npx grada-run db backup
100
+ npx grada-run db backup --id pre-migration-checkpoint
101
+ npx grada-run db backup --no-wait # return immediately
102
+ ```
103
+
104
+ | Flag | Description |
105
+ | ---- | ----------- |
106
+ | `--id <snapshot-id>` | Custom snapshot id. Defaults to `<db>-manual-YYYYMMDD-HHmmss`. |
107
+ | `--timeout <seconds>` | Give up waiting after this long (default `900`). Creation continues in the background. |
108
+ | `--no-wait` | Return immediately without waiting for the snapshot to become available. |
109
+ | `--project-name <name>` | Explicit project name override. |
110
+ | `--workspace <name>` | Target a PR-preview environment. |
111
+ | `--db-identifier <id>` | Explicit RDS identifier override (instance or Aurora cluster). |
112
+ | `--region <region>` | Explicit AWS region override. |
113
+
114
+ ## db restore
115
+
116
+ Restore your database from a manual or automated snapshot. Omit the snapshot id to pick from a list of available checkpoints, newest first.
117
+
118
+ Restoring works through Terraform: the command pins the snapshot in `terraform/database.tf` (`snapshot_identifier`, in the instance or `aws_rds_cluster` block), so the VPC wiring, security groups, and Secrets Manager integration stay intact and future applies stay clean. Run `npx grada-run apply` afterwards to perform the restore.
119
+
120
+ ```bash
121
+ npx grada-run db restore # pick a snapshot interactively
122
+ npx grada-run db restore my-snapshot-id
123
+ npx grada-run db restore my-snapshot-id --yes # skip confirmation (for CI)
124
+ ```
125
+
126
+ > **Restoring replaces your current data.** Everything written after the snapshot is permanently discarded. Create a safety checkpoint with `npx grada-run db backup` first if you might need the current data.
127
+
128
+ | Flag | Description |
129
+ | ---- | ----------- |
130
+ | `<snapshot-id>` | Snapshot to restore (positional). Omit to choose interactively. |
131
+ | `--yes` | Skip the confirmation prompt. Required in non-interactive environments. |
132
+ | `--project-name <name>` | Explicit project name override. |
133
+ | `--workspace <name>` | Target a PR-preview environment. |
134
+ | `--db-identifier <id>` | Explicit RDS identifier override (instance or Aurora cluster). |
135
+ | `--region <region>` | Explicit AWS region override. |
136
+
137
+ After `apply` completes, leave `snapshot_identifier` in `terraform/database.tf` — it keeps subsequent applies drift-free.
138
+
139
+ ## db enable-vector
140
+
141
+ Enable the `pgvector` extension on RDS PostgreSQL or Aurora PostgreSQL for AI/RAG embeddings — no OpenSearch cluster required. Runs a one-off ECS task inside your VPC that executes `CREATE EXTENSION IF NOT EXISTS vector` using whatever client your image already has (`psql`, `pg`/`@prisma/client`, or `psycopg`), negotiating TLS on every branch for `rds.force_ssl` databases, then verifies the installed version. Refuses to run on MySQL projects.
142
+
143
+ ```bash
144
+ npx grada-run db enable-vector
145
+ npx grada-run db enable-vector --task-def myapp-task:4 --timeout 300
146
+ ```
147
+
148
+ If your project has a Prisma schema without `postgresqlExtensions`, the command prints the snippet to add. When the container has no usable PostgreSQL client, it exits 3 with install guidance instead of failing cryptically.
149
+
150
+ | Flag | Description |
151
+ | ---- | ----------- |
152
+ | `--task-def <task-def>` | Task definition to run (defaults to the service's active revision). |
153
+ | `--timeout <seconds>` | Give up waiting after this long (default `600`). |
154
+ | `--project-name <name>` | Explicit project name override. |
155
+ | `--workspace <name>` | Target a PR-preview environment. |
156
+ | `--cluster <name>` | Explicit cluster name override. |
157
+ | `--service <name>` | Explicit service name override. |
158
+ | `--container <name>` | Explicit container name override. |
159
+ | `--region <region>` | Explicit AWS region override. |
160
+
161
+ ## db import
162
+
163
+ Stream a local SQL dump or a remote database (Heroku, Supabase, Render, Railway) directly into your isolated RDS instance through an automated background SSM tunnel — the database stays private throughout.
164
+
165
+ ```bash
166
+ npx grada-run db import --file ./prod.sql --yes
167
+ npx grada-run db import --file ./prod.sql.gz --yes # gzipped dumps stream through gunzip
168
+ npx grada-run db import --file ./prod.dump --yes # Postgres custom archives via pg_restore
169
+ npx grada-run db import --from "postgresql://user:pass@host:5432/db" --yes
170
+ ```
171
+
172
+ - Pass exactly one of `--file` / `--from` (or pick interactively when neither is given).
173
+ - `.dump` archives restore with `pg_restore --no-owner --no-acl`; `--from` pipes `pg_dump` (`mysqldump` for MySQL targets) straight into the target client, so multi-gigabyte databases never touch your disk.
174
+ - **Secrets never touch argv or disk.** Target credentials come from Secrets Manager and travel via `PGPASSWORD` / `MYSQL_PWD`; `--from` passwords are parsed out of the URL and passed the same way. Validation errors print the URL with the password masked as `****`.
175
+ - **TLS by default.** Postgres clients on both sides run with `PGSSLMODE=require` (unless you pinned `PGSSLMODE`), since RDS/Aurora enforces `rds.force_ssl = 1`.
176
+ - The tunnel binds an ephemeral loopback port (never `5432`/`3306`, which may already serve a local database) and is always torn down afterwards, even on failure or Ctrl+C.
177
+ - Requires the matching client tools locally: `psql` / `pg_restore` / `pg_dump` (`brew install libpq`, then add `$(brew --prefix libpq)/bin` to `PATH`) or `mysql` / `mysqldump` (`brew install mysql-client`).
178
+
179
+ | Flag | Description |
180
+ | ---- | ----------- |
181
+ | `--file <path>` | Local `.sql`, `.sql.gz`, or `.dump` file to import. |
182
+ | `--from <url>` | Source `postgresql://` or `mysql://` URL (must include a database name). |
183
+ | `--yes` | Skip the confirmation prompt. Required in non-interactive environments. |
184
+ | `--project-name <name>` | Explicit project name override. |
185
+ | `--workspace <name>` | Target a PR-preview environment. |
186
+ | `--db-identifier <id>` | Explicit RDS identifier override. |
187
+ | `--region <region>` | Explicit AWS region override. |
188
+
189
+ > **Importing writes to your live database.** Take a safety checkpoint with `npx grada-run db backup` before importing into a database you care about.
190
+
191
+ ## Prerequisites
192
+
193
+ - Run `npx grada-run apply` first with a managed database provisioned (answer "Yes" to the database prompt during `init`).
194
+ - `db connect` additionally needs the AWS CLI and the Session Manager plugin (`brew install session-manager-plugin` on Mac; the command prints the right instructions for your OS when it's missing). On expired credentials, refresh with `aws sso login` or `aws configure`. See the [AWS credentials guide](/grada/guides/aws-credentials/).
195
+
196
+ ## See also
197
+
198
+ - [Managed Database Connections](/grada/guides/database-connections/)
199
+ - [exec](/grada/cli/exec/)
200
+ - [status](/grada/cli/status/)
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: destroy
3
+ description: Tear down all AWS resources provisioned for this project.
4
+ ---
5
+
6
+ Permanently delete the AWS infrastructure created by `apply` when a project is retired or needs a clean rebuild, protecting you from ongoing AWS charges.
7
+
8
+ ## What it does
9
+
10
+ - Verifies you are in a grada project (`terraform/backend.tf` must exist) and that the `terraform` binary is installed, exiting otherwise.
11
+ - Asks for explicit confirmation before doing anything destructive; declining cancels with no changes.
12
+ - Before destroying, wakes a stopped or transitional-state database back to `available` (RDS refuses to delete databases that aren't available), so tearing down an asleep environment succeeds instead of failing mid-destroy; aborts with a retry message if the database never becomes ready.
13
+ - Runs `terraform destroy -auto-approve` in `terraform/`, streaming progress, so all compute resources (ECS or Lambda, ALB or API Gateway, database, and related resources) are removed.
14
+ - Parses the state bucket name and region out of `terraform/backend.tf` (region defaults to `us-east-2` when not found), then optionally asks whether to also empty and delete the S3 state bucket via `teardownStateBucket`. Answering "No" keeps the bucket so `apply` can restore the infrastructure later.
15
+ - Emits an `infrastructure_destroyed` telemetry event recording success and whether the state bucket was retained.
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ npx grada-run destroy
21
+ ```
22
+
23
+ ## Flags
24
+
25
+ This command accepts no CLI flags. Both confirmation prompts are interactive.
26
+
27
+ ## See also
28
+
29
+ - [apply](/grada/cli/apply/)
30
+ - [doctor](/grada/cli/doctor/)
31
+ - [sleep & wake](/grada/cli/sleep/) (pause billing temporarily instead of tearing down)
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: diagnose
3
+ description: Diagnose failing ECS deployments from logs and task state.
4
+ ---
5
+
6
+ Inspect recent ECS task failures and CloudWatch logs for the current project.
7
+
8
+ ## What it does
9
+
10
+ - Saves you from digging through the AWS console by finding the most recently stopped ECS task for this project and showing why it stopped plus the failing container's recent log events (up to 50 lines).
11
+ - Resolves its inputs automatically: the AWS region from `AWS_REGION`, falling back to `region` in `terraform/main.tf` (default `us-east-2`); the cluster (`<project-name>-cluster`, overridable via `ECS_CLUSTER`); and the log group (`/ecs/<project-name>`, overridable via `ECS_LOG_GROUP`). The project name itself comes from `app_name` in `terraform/main.tf`, falling back to the current directory name.
12
+ - Lists up to 100 recent stopped tasks, describes them in a single batch, and diagnoses the most recently stopped one (by container exit time, falling back to stop/start/creation time): stopped reason, failing container name, exit code, container reason, and how long ago it stopped.
13
+ - Reports recovery instead of a stale crash: when the crash belongs to a superseded task-definition revision, or a running task started after the stop, prints the previous crash as one-line context (no log dump) and exits healthy.
14
+ - Fetches logs from the crashed task's own CloudWatch stream first, falling back to the last hour of group-wide events; reports a missing log group distinctly instead of showing an empty result.
15
+ - Makes no changes to your infrastructure; it is read-only. Prints a healthy message and exits when no stopped tasks exist.
16
+ - On `--target lambda` projects, checks function state and configuration via the AWS CLI and tails the function's recent log events instead of inspecting ECS tasks.
17
+ - On expired AWS credentials, points you to `aws sso login` / `aws configure` and the [AWS credentials guide](/grada/guides/aws-credentials/), then exits with code 1 instead of throwing.
18
+ - Emits a `diagnose_run` telemetry event recording success and whether the service was healthy.
19
+
20
+ ## Usage
21
+
22
+ ```bash
23
+ npx grada-run diagnose
24
+ npx grada-run wtf
25
+ ```
26
+
27
+ `wtf` is an alias for `diagnose`.
28
+
29
+ ## Flags
30
+
31
+ This command accepts no CLI flags. Region, cluster, and log group are resolved as described above, not from flags.
32
+
33
+ ## See also
34
+
35
+ - [exec](/grada/cli/exec/)
36
+ - [status](/grada/cli/status/)
37
+ - [ADR-0004: IaC-Driven Diagnostic Context](/grada/adrs/0004-iac-driven-diagnostic-context/)
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: doctor
3
+ description: Check that required tools are installed before provisioning.
4
+ ---
5
+
6
+ Verify your machine is ready to provision and deploy, telling you exactly which dependency to install when something is missing.
7
+
8
+ ## What it does
9
+
10
+ - Checks for the four required binaries — `terraform`, `aws` (AWS CLI), `docker`, and `git` — and prints a pass/fail line for each with an install hint for anything missing (Homebrew on macOS, distro-appropriate guidance on Linux, `winget` on native Windows).
11
+ - Makes no changes to your project or cloud resources; it is a read-only check.
12
+ - Prints a success message when everything is present, or a reminder to install the missing dependencies first.
13
+ - Emits a `doctor_run` telemetry event recording whether all checks passed plus per-check outcomes (`passed_checks`, `failed_checks`, `total_failed` using stable check IDs — never paths or error text).
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ npx grada-run doctor
19
+ ```
20
+
21
+ ## Flags
22
+
23
+ This command accepts no CLI flags.
24
+
25
+ ## See also
26
+
27
+ - [npx grada-run](/grada/cli/init/)
28
+ - [apply](/grada/cli/apply/)
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: domain
3
+ description: Attach a custom domain to your CloudFront distribution with automated ACM TLS certificates and DNS verification.
4
+ ---
5
+
6
+ Serve your application from your own domain with automated edge TLS — no manual certificate requests, validation emails, or CloudFront console edits.
7
+
8
+ ## What it does
9
+
10
+ - `domain add <domain>` provisions an ACM TLS certificate in `us-east-1` (required by CloudFront) and wires it into your distribution's `aliases` and `viewer_certificate`.
11
+ - With `--zone-id <id>`, validation and routing are fully automated: grada creates the ACM validation records plus apex `A`/`AAAA` alias records in your Route 53 hosted zone, then binds the certificate to CloudFront in a single `apply`.
12
+ - Without `--zone-id`, you get a guided 2-step flow for external DNS providers (Cloudflare, Namecheap): `domain add` stages the certificate, `domain status` shows the exact CNAME records to paste, and `domain verify` activates the domain once DNS is in place.
13
+ - `domain status` shows the configured domain, its mode, whether CloudFront is wired, and a copy-paste DNS record table.
14
+ - `domain remove` deletes the domain configuration and restores the free `*.cloudfront.net` default certificate.
15
+ - PR preview workspaces are unaffected: domain resources are scoped to the production workspace, so previews keep serving over their own `*.cloudfront.net` URL and teardowns never touch your certificate, aliases, or DNS.
16
+ - Domain configuration lives in `terraform/domain.tf`, so `destroy` tears it down and `eject` keeps it automatically.
17
+ - Emits a `domain_run` telemetry event recording the subcommand and outcome.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ # Route 53, fully automated (one step)
23
+ npx grada-run domain add example.com --zone-id Z1234567890ABC
24
+ npx grada-run apply
25
+
26
+ # External DNS, guided (two steps)
27
+ npx grada-run domain add example.com
28
+ npx grada-run apply
29
+ # add the printed CNAMEs at your DNS provider, then:
30
+ npx grada-run domain verify
31
+ npx grada-run apply
32
+
33
+ # Inspect or remove
34
+ npx grada-run domain status
35
+ npx grada-run domain remove
36
+ ```
37
+
38
+ To replace a configured domain, run `domain add <new-domain>` again with `--force` — the old domain is swapped out of CloudFront cleanly.
39
+
40
+ ## Flags
41
+
42
+ | Flag | Description |
43
+ | ---- | ----------- |
44
+ | `--zone-id <id>` | Route 53 hosted zone ID for automated validation and routing. Accepts a bare ID (`Z123…`) or the console's `/hostedzone/Z123…` form. Only applies to `domain add`. |
45
+ | `--activate` | Activate immediately in external-DNS mode (skips the pending stage). Make sure your validation CNAMEs exist first — `apply` waits on DNS propagation. Only applies to `domain add`. |
46
+ | `--force` | Replace an already-configured domain. Without it, re-adding refuses to clobber your configuration. Only applies to `domain add`. |
47
+ | `--yes` | Skip the confirmation prompt. Required in headless/CI mode. Only applies to `domain remove`. |
48
+
49
+ Requires a project initialized with `grada` (`terraform/cloudfront.tf` must exist).
50
+
51
+ > **One domain per project:** each project manages a single custom domain. Need apex plus `www`? Configure the apex here and add a redirect rule for `www` at your DNS provider.
52
+
53
+ ## See also
54
+
55
+ - [add](/grada/cli/add/) (provision `email:ses` on the same domain)
56
+ - [apply](/grada/cli/apply/)
57
+ - [destroy](/grada/cli/destroy/)
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: drift
3
+ description: Detect out-of-band AWS changes with terraform plan, locally or on a daily GitHub Actions schedule.
4
+ ---
5
+
6
+ Catch console click-ops before they surprise you: compare live AWS state against Terraform, locally on demand or daily in CI with automatic GitHub Issues.
7
+
8
+ ## What it does
9
+
10
+ - `drift` runs `terraform init` + `terraform plan -detailed-exitcode` in `terraform/` and reports `✅ No infrastructure drift detected` (exit `0`), `⚠ Infrastructure drift detected!` with a resource summary (exit `2`), or a plan failure (exit `1`).
11
+ - `drift --setup` (alias: `drift init`) scaffolds `.github/workflows/drift.yml` into an existing project, reusing your deploy workflow's OIDC role — no extra secrets needed.
12
+ - `--setup-ci-drift` scaffolds the same workflow during `grada` scaffolding.
13
+ - The scheduled workflow runs daily at 06:00 UTC (plus a manual `workflow_dispatch` trigger): on drift it opens (or updates, without spamming) a GitHub Issue labeled `iac-drift` with the plan diff; when drift resolves it comments `✅ Drift resolved` and closes the issue.
14
+ - Set a `SLACK_WEBHOOK_URL` repository secret to also post drift alerts to Slack.
15
+ - Emits a `drift_run` telemetry event recording the action and outcome.
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ npx grada-run drift
21
+ npx grada-run drift --setup
22
+ npx grada-run drift --setup --force
23
+ npx grada-run --setup-ci-drift
24
+ ```
25
+
26
+ ## Flags
27
+
28
+ | Flag | Description |
29
+ | ---- | ----------- |
30
+ | `--setup` | Scaffold `.github/workflows/drift.yml` instead of running a local check. |
31
+ | `--force` | Overwrite an existing `drift.yml` on `--setup`. |
32
+ | `--region <region>` | Explicit AWS region override. |
33
+ | `--project-name <name>` | Explicit project name override (defaults to the name in `terraform/main.tf`, then the directory name). |
34
+
35
+ Requires a project initialized with `grada` (`terraform/main.tf` must exist) and the Terraform CLI installed for local checks.
36
+
37
+ ## See also
38
+
39
+ - [apply](/grada/cli/apply/) (reconcile drifted state)
40
+ - [init](/grada/cli/init/)
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: eject
3
+ description: Decouple your project from grada into vanilla Terraform.
4
+ ---
5
+
6
+ Take permanent, sole ownership of your infrastructure files when you no longer want the CLI managing them, while keeping everything running in AWS.
7
+
8
+ ## What it does
9
+
10
+ - Asks for explicit confirmation (defaulting to "No"); declining cancels with no changes.
11
+ - Strips grada metadata from your local files: removes the `# grada generated infrastructure` header and the `default_tags { tags = { ManagedBy = "grada" } }` block from `terraform/main.tf`, and removes the `# grada backups` block from `.gitignore`.
12
+ - Recursively deletes every `*.bak.*` backup file in the project (skipping `node_modules` and `.git`).
13
+ - Leaves your infrastructure fully operational as raw, standalone Terraform. As a final step, run `terraform apply` inside `terraform/` so AWS syncs state and removes the live `ManagedBy` tags.
14
+ - Emits a `project_ejected` telemetry event. This cannot be undone.
15
+
16
+ ## Usage
17
+
18
+ ```bash
19
+ npx grada-run eject
20
+ ```
21
+
22
+ ## Flags
23
+
24
+ This command accepts no CLI flags. The confirmation prompt is interactive.
25
+
26
+ ## See also
27
+
28
+ - [apply](/grada/cli/apply/)
29
+ - [destroy](/grada/cli/destroy/)
@@ -0,0 +1,49 @@
1
+ ---
2
+ title: exec
3
+ description: Open an interactive shell inside your running ECS container.
4
+ ---
5
+
6
+ Drop into a secure shell inside your live Fargate container to inspect files, check environment variables, or debug a running app — without opening the AWS console.
7
+
8
+ ## What it does
9
+
10
+ - Finds a running container for the current project automatically and opens an interactive shell (`/bin/sh` by default) via ECS Exec.
11
+ - Resolves its inputs automatically: cluster (`<project-name>-cluster`, overridable via `ECS_CLUSTER`), service (`<project-name>-service`, overridable via `ECS_SERVICE`), container (`<project-name>-container`, overridable via `ECS_CONTAINER`), and region (`--region` → `AWS_REGION` → `terraform/main.tf` → `us-east-2`).
12
+ - Checks that the AWS CLI is installed first; if missing, prints install links and exits 1 instead of failing cryptically.
13
+ - Checks that the Session Manager plugin is installed next; if missing, prints install instructions for your OS (`brew install session-manager-plugin` on Mac, download links on Windows/Linux) and exits 1.
14
+ - When no containers are running (e.g. scaled to zero or still booting), explains that a running container is required, points you to `status` and `apply`, and exits 1.
15
+ - On expired AWS credentials, points you to `aws sso login` / `aws configure` and exits 1 instead of throwing.
16
+ - ECS only: on `--target lambda` projects the command exits with an error (functions have no shell to attach to) and points you to `logs` instead.
17
+ - Emits an `exec_run` telemetry event recording success and outcome.
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ npx grada-run exec
23
+ npx grada-run exec --command /bin/bash
24
+ npx grada-run exec --service myapp-service --container myapp-container
25
+ ```
26
+
27
+ Type `exit` to leave the shell.
28
+
29
+ ## Flags
30
+
31
+ | Flag | Description |
32
+ | ---- | ----------- |
33
+ | `[service]` | Service to connect to. Defaults to the project service. |
34
+ | `--service <name>` | Explicit service name override. |
35
+ | `--cluster <name>` | Explicit cluster name override. |
36
+ | `--container <name>` | Explicit container name override. |
37
+ | `--command <cmd>` | Shell to open (default `/bin/sh`). |
38
+ | `--region <region>` | Explicit AWS region override. |
39
+
40
+ ## Prerequisites
41
+
42
+ - Run `npx grada-run apply` first: ECS Exec access (`enable_execute_command` plus the container's session permissions) is provisioned with your infrastructure. If the connection is refused on an older deployment, re-run `apply` to enable it.
43
+ - Install the AWS CLI and the Session Manager plugin (`brew install session-manager-plugin` on Mac; the command prints the right instructions for your OS when it's missing). On expired credentials, refresh with `aws sso login` or `aws configure`. See the [AWS credentials guide](/grada/guides/aws-credentials/).
44
+
45
+ ## See also
46
+
47
+ - [status](/grada/cli/status/)
48
+ - [logs](/grada/cli/logs/)
49
+ - [diagnose](/grada/cli/diagnose/)
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: gc
3
+ description: Discover and delete orphaned ECR images, CloudWatch log groups, and Elastic IPs.
4
+ ---
5
+
6
+ Dry-run discovery and interactive deletion of orphaned AWS resources left behind by failed deployments, deleted PR previews, or manual console changes — protecting your AWS bill without leaving the terminal.
7
+
8
+ ## What it does
9
+
10
+ - Scans ECR repositories matching `<project-name>-*` for untagged images and batch-deletes them.
11
+ - Scans CloudWatch log groups under `/ecs/<project-name>-*` (preview leftovers; the live `/ecs/<project-name>` group is never matched) and deletes them. On `--target lambda` projects it scans `/aws/lambda/<project-name>-*` instead, always excluding the live `/aws/lambda/<project-name>-fn` group.
12
+ - Scans Elastic IPs and releases any without an association (stops the hourly unused-EIP charge).
13
+ - Paginates all discovery APIs, so large accounts are fully scanned.
14
+ - Prints a categorized dry-run summary with per-target counts before asking anything.
15
+
16
+ ## Usage
17
+
18
+ ```bash
19
+ npx grada-run gc
20
+ npx grada-run gc --region eu-west-1
21
+ ```
22
+
23
+ ## Flags
24
+
25
+ | Flag | Description |
26
+ | ---- | ----------- |
27
+ | `--region <region>` | Explicit AWS region override. |
28
+ | `--project-name <name>` | Explicit project name override (defaults to `app_name` in `terraform/main.tf`, then the current directory name). |
29
+
30
+ ## Safety
31
+
32
+ Deletion requires explicit interactive confirmation (`Are you sure you want to permanently delete these orphaned resources? (y/N)`, defaulting to no). There is intentionally no `--yes` flag, so the command can never wipe resources from a CI pipeline by accident. Declining or cancelling deletes nothing; finding nothing skips the prompt entirely.
33
+
34
+ ## See also
35
+
36
+ - [status](/grada/cli/status/)
37
+ - [Ephemeral PR Previews](/grada/guides/ephemeral-pr-previews/)
@@ -0,0 +1,72 @@
1
+ ---
2
+ title: Initializing Project (npx grada-run)
3
+ description: Scaffold production-ready AWS infrastructure and CI/CD pipelines.
4
+ ---
5
+
6
+ Generate Terraform, Docker, and GitHub Actions files for your project.
7
+
8
+ ## What it does
9
+
10
+ - Turns your codebase into a deployable AWS project: auto-detects your framework, `Procfile`, `vercel.json`, and Compose files, warns about framework-specific migration issues (NestJS bind address, Next.js standalone output, SvelteKit/Astro adapters), then provisions the remote-state S3 bucket and synthesizes Terraform, Docker, and CI/CD files.
11
+ - Scans your manifests for infrastructure signals before prompting: database drivers and migration markers pre-select the managed PostgreSQL prompt, worker dependencies pre-fill the background-worker command, and detected capabilities (Redis, SQS, S3, DynamoDB, Bedrock, SES) come pre-checked in the addon picker — every suggestion shows the exact evidence that triggered it (`detected: ioredis, REDIS_URL`). Detection is read-only and skips secret values entirely.
12
+ - Scaffolds selected addons in the same run (same pipeline as [`add`](/grada/cli/add/), including container env injection and README cost refresh), offers to wire the pre-deploy database migration gate into the generated workflow, offers scheduled IaC drift detection (a daily `terraform plan` workflow that opens GitHub Issues), and prints a full stack topology preview when addons are included.
13
+ - Backs up any existing generated files before overwriting them, and writes AI assistant rule files for the assistants you choose (advanced mode) or the ones already present in your repo (quickstart mode). Your own `README.md` is never overwritten: deployment docs go to `README.md` only when it is absent or was previously generated, otherwise to `DEPLOYMENT.md` (or `GRADA.md` when both are yours), with an existing `secret_keys.json` left untouched.
14
+ - Finishes with the exact next steps: the `apply` command to provision, and the `git` commands to commit and push.
15
+ - Writes a fixed-baseline monthly cost estimate into the generated deployment doc, refreshed automatically whenever you later run [`add`](/grada/cli/add/).
16
+ - Emits `project_provisioned` (recording the database engine, detected/selected addons, migration-gate status, and drift-detection status) and `cli-error` telemetry events (disable with `--no-telemetry`).
17
+
18
+ ## Usage
19
+
20
+ ```bash
21
+ npx grada-run
22
+ npx grada-run --headless --framework=nextjs --region=us-east-2
23
+ npx grada-run --headless --framework=nestjs --needsDatabase \
24
+ --with db:redis,ai:bedrock,email:ses --domain example.com --setup-ci-migrate
25
+ npx grada-run --headless --framework=node --target=lambda
26
+ ```
27
+
28
+ Running with no subcommand starts the interactive setup wizard (`init` is the default command).
29
+
30
+ ## Compute targets
31
+
32
+ `--target` selects the AWS compute architecture (interactive runs prompt when the flag is absent):
33
+
34
+ - `ecs` (default, `fargate` accepted as a synonym) — always-on ECS Fargate tasks behind an ALB: zero cold starts, ~$31.28/mo compute+ALB baseline.
35
+ - `lambda` — scale-to-zero AWS Lambda container function (via the Lambda Web Adapter, zero app code changes) behind API Gateway HTTP API v2 and CloudFront: $0.00/mo fixed compute baseline, usage-based invocations.
36
+
37
+ Lambda targets skip ECS-only scaffolding (no worker service, no ALB listener rules, no pre-deploy migration gate — run migrations from CI against your database endpoint instead). Day-0 `apply` seeds a placeholder image into ECR automatically, so the first provision succeeds before any code push. Secrets pushed with `secrets push` stay in the shared vault for runtime reads (`APP_SECRETS_ARN`); database credentials flow as `DB_*` environment variables so VPC-attached functions need no Secrets Manager endpoint.
38
+
39
+ Not sure which to pick? Choose `ecs` for steady or latency-sensitive traffic, long responses, WebSockets, background workers, or persistent database connections — and `lambda` for sporadic or bursty traffic where $0 idle cost beats warm latency. The full side-by-side (cost crossover, request limits, connection safety, network egress) lives in [Fargate vs Lambda tradeoffs](/grada/guides/architecture/#fargate-vs-lambda-tradeoffs).
40
+
41
+ ## Headless flags
42
+
43
+ | Flag | Description |
44
+ | ---- | ----------- |
45
+ | `--headless` | Bypass all interactive prompts (for CI/CD and automation). |
46
+ | `--framework=<name>` | `node`, `nestjs`, `nextjs`, `nuxt`, `svelte`, `python`, `django`, `rails`, `go`, `static`. |
47
+ | `--region=<region>` | AWS region (e.g. `us-east-1`). |
48
+ | `--port=<port>` | Container port your app listens on. |
49
+ | `--size=<size>` | Fargate task size preset. |
50
+ | `--healthCheckPath=<path>` | ALB health-check path. |
51
+ | `--desiredCount=<n>` | Number of tasks to run. |
52
+ | `--branch=<name>` | Branch the CI workflow deploys. |
53
+ | `--needsDatabase` | Provision a managed database. |
54
+ | `--db-engine <engine>` | Database engine: `postgres` (default), `mysql` (MySQL 8.0), or `aurora-postgresql` (Serverless v2 scale-to-zero). Skip the interactive engine prompt. |
55
+ | `--target <target>` | Compute target: `ecs` (default, `fargate` synonym) or `lambda` (scale-to-zero serverless). Skips the interactive target prompt. |
56
+ | `--enablePrPreviews` | Enable ephemeral PR preview environments. |
57
+ | `--dir=<path>` | Target directory for generated files. |
58
+ | `--preconfigured` | Skip framework-specific warnings (for preconfigured setups). |
59
+ | `--with <capabilities>` | Comma-separated (or repeatable) addon capabilities to scaffold during init (`storage:s3`, `db:dynamodb`, `db:redis`, `queue:sqs`, `ai:bedrock`, `email:ses`, `cron`). Pre-checks the interactive picker, or scaffolds directly in headless mode. |
60
+ | `--model <id>` | Bedrock model override when `ai:bedrock` is included (defaults to the catalog's recommended model). |
61
+ | `--domain <domain>` | Domain for the SES identity when `email:ses` is included (required in headless mode). |
62
+ | `--zone-id <id>` | Route 53 hosted zone ID for automatic SES DNS records. |
63
+ | `--from-email <email>` | Default SES sender address (default `noreply@<domain>`). |
64
+ | `--setup-ci-migrate` | Wire the pre-deploy database migration gate into the generated workflow when a database and migration command are detected. |
65
+ | `--setup-ci-drift` | Scaffold `.github/workflows/drift.yml`: a daily 06:00 UTC `terraform plan` check that opens (or updates) a GitHub Issue labeled `iac-drift` on drift and closes it when resolved. |
66
+ | `--no-telemetry` | Disable telemetry for this run (or set `DO_NOT_TRACK=1` for all runs). |
67
+
68
+ New here? Start with the [Quickstart](/grada/guides/quickstart/).
69
+
70
+ See the [Supported Frameworks](/grada/guides/frameworks/) guide for detection rules and per-framework requirements, and the [Headless Mode guide](/grada/guides/headless/) for automation examples.
71
+
72
+ After scaffolding, continue with [CI/CD Pipeline & First Deploy](/grada/guides/cicd-pipeline/).