deploy-stack 0.17.14 → 0.18.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.
@@ -0,0 +1,62 @@
1
+ name: IaC Validation
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ validate:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ framework: [nestjs, nextjs, nuxt, node, svelte, static, python, django, rails, go]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Setup Node.js
19
+ uses: actions/setup-node@v4
20
+ with:
21
+ node-version: '24.x'
22
+
23
+ - name: Install dependencies
24
+ run: npm install
25
+
26
+ - name: Setup Terraform
27
+ uses: hashicorp/setup-terraform@v3
28
+
29
+ - name: Setup TFLint
30
+ uses: terraform-linters/setup-tflint@v4
31
+ with:
32
+ github_token: ${{ secrets.GITHUB_TOKEN }}
33
+
34
+ - name: Scaffold app (${{ matrix.framework }})
35
+ run: |
36
+ TMPDIR=$(mktemp -d)
37
+ echo "GENERATED_DIR=$TMPDIR" >> "$GITHUB_ENV"
38
+ cd "$TMPDIR"
39
+ node "$GITHUB_WORKSPACE/bin/cli.js" --headless --preconfigured --framework=${{ matrix.framework }}
40
+
41
+ - name: Terraform Compile
42
+ working-directory: ${{ env.GENERATED_DIR }}/terraform
43
+ run: |
44
+ terraform init -backend=false
45
+ terraform validate
46
+
47
+ - name: Init TFLint
48
+ working-directory: ${{ env.GENERATED_DIR }}/terraform
49
+ run: tflint --init
50
+
51
+ - name: Terraform Lint
52
+ working-directory: ${{ env.GENERATED_DIR }}/terraform
53
+ run: tflint
54
+
55
+ - name: DevSecOps Scan
56
+ uses: aquasecurity/trivy-action@master
57
+ with:
58
+ scan-type: 'fs'
59
+ scan-ref: ${{ env.GENERATED_DIR }}
60
+ format: 'table'
61
+ severity: 'HIGH,CRITICAL'
62
+ exit-code: '1'
package/README.md CHANGED
@@ -35,6 +35,7 @@ You retain complete ownership of your infrastructure code without relying on bla
35
35
 
36
36
  **🛡️ DevSecOps & Security**
37
37
  * **Automated Trivy Scanning:** Integrated IaC and container vulnerability scanning on every GitHub Actions run.
38
+ * **Continuous IaC Validation:** Matrix pipeline scaffolds all 10 supported frameworks headlessly and gates every commit on `terraform validate`, `tflint`, and Trivy (HIGH/CRITICAL).
38
39
  * **Hardened Containers:** Explicitly drops root privileges using `nginx-unprivileged` and distroless bases for strict Fargate security compliance.
39
40
  * **Zero-Secret CI/CD:** Utilizes AWS IAM OpenID Connect (OIDC) for automated deployments—no long-lived AWS keys in GitHub.
40
41
  * **Built-in Secrets Manager:** Push local `.env` variables directly into encrypted AWS Secrets Manager vaults with a single CLI command.
@@ -90,7 +91,7 @@ The interactive wizard will analyze your codebase, detect your framework, estima
90
91
  Scans your local environment and generated files to ensure all required dependencies (Docker, Terraform, AWS CLI) are installed and configured correctly.
91
92
 
92
93
  * **`npx deploy-stack diagnose`** (alias: `wtf`)
93
- Troubleshoots a failing ECS deployment by reporting the most recent stopped task's `stoppedReason`, failing container (with exit code), and the last 50 CloudWatch log lines.
94
+ Troubleshoots a failing ECS deployment by reporting the most recent stopped task's `stoppedReason`, failing container (with exit code), and the last 50 CloudWatch log lines. Stateless: derives region/cluster context from `terraform/main.tf` (see ADR-0004), no local state file required.
94
95
 
95
96
  * **`npx deploy-stack destroy`**
96
97
  Safely tears down your ECS cluster, Load Balancers, and networking resources to stop AWS billing. Includes an interactive prompt to optionally retain or delete your S3 remote state bucket.
@@ -167,17 +168,12 @@ npx deploy-stack --no-telemetry
167
168
 
168
169
  ## 🗺️ Roadmap
169
170
 
170
- ### Current Focus (Phase 7: Team Workflows & Ecosystem Integrations)
171
- - [x] **Ephemeral PR Previews:** Generate GitHub Actions workflows that spin up temporary ECS Fargate tasks and post live preview URLs directly in pull request comments to streamline team code reviews.
172
- - [x] **AI Context Synchronization:** Implement `deploy-stack sync-ai` to automatically generate `.cursorrules` and AI context files, ensuring coding assistants generate accurate deployment commands tailored to the project.
173
- - [ ] **Native Ecosystem Integrations & Scaffolding:** Publish seamless, push-button plugins and templates across major framework package registries:
174
- - [x] `vite-plugin-deploy-stack` (Vite / React / Vue SPA ecosystem)
175
- - [x] `svelte-adapter-deploy-stack` (SvelteKit adapter integration)
176
- - [x] `cookiecutter-django-deploy-stack` (Listed on Django Packages)
177
- - [x] `cookiecutter-fastapi-deploy-stack` (Cookiecutter for modern async Python)
178
- - [x] `nest-deploy-stack` (Native `nest add` schematic for NestJS)
179
- - [x] `rails-template-deploy-stack` (Zero-click Ruby on Rails application template)
180
- - [x] **Automated Troubleshooting:** `deploy-stack diagnose` (alias: `wtf`) automatically analyzes common day-2 AWS operational issues (e.g., Fargate OOM kills, ALB 502s) directly from the terminal.
171
+ ### Current Focus: Phase 8: Platform Hardening & Developer Experience
172
+ **Goal:** Solidify the core engine's reliability, prove security compliance, and establish documentation hub before introducing Day-2 operational commands.
173
+ - [ ] **Documentation Hub:** Launch a dedicated Astro Starlight documentation site featuring interactive architecture diagrams, core concept deep-dives, and detailed CLI references.
174
+ - [ ] **Continuous Infrastructure Validation:** Implement a GitHub Actions matrix pipeline that automatically generates, compiles, and validates Terraform syntax (`terraform validate`, `tflint`) against all supported frameworks on every commit.
175
+ - [ ] **Automated Security & Compliance Proving:** Integrate DevSecOps infrastructure scanning (`trivy` or `tfsec`) directly into the CI pipeline to mathematically guarantee zero-CVE, secure-by-default AWS provisioning.
176
+ - [ ] **Integration Stability Suite:** Expand Vitest coverage to enforce strict contracts for headless execution flags (`--preconfigured`, `--headless`), ensuring seamless interoperability with third-party scaffolding tools.
181
177
 
182
178
  👉 **[See the full project history and future plans in ROADMAP.md](./ROADMAP.md)**
183
179
 
package/docs/ROADMAP.md CHANGED
@@ -22,15 +22,22 @@
22
22
  - [x] **Docker Compose to ECS Translator:** Automatically converting a familiar local `docker-compose.yml` into production ECS task definitions.
23
23
  - [x] **AI Agent Rulesets:** Publishing `.cursorrules` and Copilot instructions that teach AI assistants exactly how to utilize the CLI on the user's behalf.
24
24
 
25
- ### Phase 7: Team Workflows & Ecosystem Integrations (Current)
25
+ ### Phase 7: Team Workflows & Ecosystem Integrations (Completed)
26
26
  *Focus: Enhance collaborative development and expand native support across major framework ecosystems.*
27
27
  - [x] **Ephemeral PR Previews:** Generate GitHub Actions workflows that spin up temporary ECS Fargate tasks and post live preview URLs directly in pull request comments to streamline team code reviews.
28
28
  - [x] **AI Context Synchronization:** Implement `deploy-stack sync-ai` to automatically generate `.cursorrules` and AI context files, ensuring coding assistants generate accurate deployment commands tailored to the project.
29
- - [ ] **Native Ecosystem Integrations:** Publish seamless, push-button plugins across major frameworks.
29
+ - [x] **Native Ecosystem Integrations:** Publish seamless, push-button plugins across major frameworks.
30
30
  - [x] `vite-plugin-deploy-stack` (Live on NPM)
31
31
  - [x] `svelte-adapter-deploy-stack` (SvelteKit adapter integration)
32
32
  - [x] `cookiecutter-django-deploy-stack` (Listed on Django Packages)
33
33
  - [x] `cookiecutter-fastapi-deploy-stack` (Cookiecutter for modern async Python)
34
34
  - [x] `nest-deploy-stack` (Native `nest add` schematic for NestJS)
35
35
  - [x] `rails-template-deploy-stack` (Zero-click Ruby on Rails application template)
36
- - [x] **Automated Troubleshooting:** `deploy-stack diagnose` (alias: `wtf`) automatically analyzes common day-2 AWS operational issues (e.g., Fargate OOM kills, ALB 502s) directly from the terminal.
36
+ - [x] **Automated Troubleshooting:** `deploy-stack diagnose` (alias: `wtf`) automatically analyzes common day-2 AWS operational issues (e.g., Fargate OOM kills, ALB 502s) directly from the terminal.
37
+
38
+ ### Phase 8: Platform Hardening & Developer Experience (Current)
39
+ *Focus: Solidify the core engine's reliability, prove security compliance, and establish documentation hub before introducing Day-2 operational commands.*
40
+ - [ ] **Documentation Hub:** Launch a dedicated Astro Starlight documentation site featuring interactive architecture diagrams, core concept deep-dives, and detailed CLI references.
41
+ - [ ] **Continuous Infrastructure Validation:** Implement a GitHub Actions matrix pipeline that automatically generates, compiles, and validates Terraform syntax (`terraform validate`, `tflint`) against all supported frameworks on every commit.
42
+ - [ ] **Automated Security & Compliance Proving:** Integrate DevSecOps infrastructure scanning (`trivy` or `tfsec`) directly into the CI pipeline to mathematically guarantee zero-CVE, secure-by-default AWS provisioning.
43
+ - [ ] **Integration Stability Suite:** Expand Vitest coverage to enforce strict contracts for headless execution flags (`--preconfigured`, `--headless`), ensuring seamless interoperability with third-party scaffolding tools.
@@ -2,7 +2,6 @@
2
2
 
3
3
  * **Status:** Accepted
4
4
  * **Date:** 2026-08-15 (Retroactive)
5
- * **Deciders:** Core Engineering Team
6
5
 
7
6
  ## Context and Problem Statement
8
7
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  * **Status:** Accepted
4
4
  * **Date:** 2026-08-20 (Retroactive)
5
- * **Deciders:** Core Engineering Team
6
5
 
7
6
  ## Context and Problem Statement
8
7
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  * **Status:** Accepted
4
4
  * **Date:** 2026-09-02 (Retroactive)
5
- * **Deciders:** Core Engineering Team
6
5
 
7
6
  ## Context and Problem Statement
8
7
 
@@ -0,0 +1,34 @@
1
+ # 0004. IaC-Driven Diagnostic Context (Stateless CLI)
2
+
3
+ * **Status:** Accepted
4
+ * **Date:** 2026-09-19
5
+
6
+ ## Context and Problem Statement
7
+
8
+ To provide a seamless developer experience, the `deploy-stack diagnose` command needs to automatically fetch CloudWatch logs and ECS task failures without requiring the user to manually input their AWS Region, Cluster Name, or Log Group.
9
+
10
+ We needed a mechanism to persist or infer the deployment context locally so the CLI knows where to look for errors.
11
+
12
+ ## Decision Drivers
13
+
14
+ * **Statelessness:** The CLI should avoid managing internal database files or proprietary local state files that can fall out of sync with actual infrastructure.
15
+ * **Single Source of Truth:** Terraform is already the declarative source of truth for the project's infrastructure.
16
+ * **Ecosystem Compatibility:** Developers often delete node_modules or switch laptops; context retrieval must survive typical Git workflows.
17
+
18
+ ## Considered Options
19
+
20
+ 1. **Local State File:** Create a `.deploy-stack/context.json` file upon generation. (Rejected: creates state drift and pollutes version control).
21
+ 2. **AWS Tag Querying:** Use the AWS SDK to query all clusters for a specific tag. (Rejected: too slow, requires broad IAM `ListClusters` permissions, and fails if multiple environments exist).
22
+ 3. **IaC Parsing (Stateless):** Parse the generated `terraform/main.tf` to extract the AWS Region and infer the cluster name from the local directory structure.
23
+
24
+ ## Decision Outcome
25
+
26
+ **Chosen Option:** IaC Parsing (Stateless). The `diagnose` command reads the AWS Region directly via regex from `terraform/main.tf` and constructs standard AWS resource names based on the current working directory.
27
+
28
+ ### Positive Consequences
29
+ * The CLI remains entirely stateless. If the Terraform files exist, the diagnostics work.
30
+ * Enforces the architectural philosophy that the generated IaC is the ultimate source of truth.
31
+ * Zero additional files are added to the user's repository.
32
+
33
+ ### Negative Consequences
34
+ * If a user manually alters the `region` string inside `main.tf` using non-standard formatting, the regex parser may fail to detect it, falling back to a default region.
@@ -5,6 +5,10 @@ To ensure zero regressions in infrastructure generation and safe local execution
5
5
  ## 1. Unit & Argument Testing
6
6
  We use pure Node.js unit tests (via Vitest) to validate the CLI argument parser (`src/core/parser.js`). This ensures that flags (like `--headless` or `--no-telemetry`) are routed correctly and never hijack positional arguments like file paths.
7
7
 
8
+ ## 1.5. Ecosystem Integration Contracts
9
+ Because `deploy-stack` acts as the underlying engine for ecosystem wrappers (e.g., `nest-deploy-stack`, `cookiecutter-fastapi`), we strictly test execution flags that bypass interactive prompts:
10
+ * **Headless Validation:** Vitest specifically asserts that when `--headless` and `--preconfigured` are passed, the CLI never initializes the `inquirer` prompt module and never throws interactive warnings. This guarantees stability for automated ecosystem integrations.
11
+
8
12
  ## 2. Infrastructure Snapshot Harness (The Static Contract)
9
13
  Because `deploy-stack` generates highly dynamic Terraform (`.tf`), GitHub Actions (`.yml`), and `Dockerfile` configurations, we use **Vitest Snapshots** to lock in the expected text outputs.
10
14
  * **The Matrix:** The test suite generates dummy projects across 11 architectural topologies (including Django, Rails, Go, Nuxt, Next.js, SvelteKit, and Vercel/Heroku migrations).
@@ -17,7 +21,7 @@ To ensure tests run sub-second and deterministically without requiring real AWS
17
21
  * **Telemetry:** PostHog tracking is mocked to prevent test executions from polluting production analytics.
18
22
 
19
23
  ## 4. Continuous Integration & Execution Validation (CI)
20
- While Vitest proves the CLI generates the *correct* files, GitHub Actions proves those files *actually work*. All tests are strictly gated via `.github/workflows/test.yml`.
24
+ While Vitest proves the CLI generates the *correct* files, GitHub Actions proves those files *actually work*. Unit and snapshot tests are gated via `.github/workflows/test.yml`; live template compilation is gated via `.github/workflows/iac-validation.yml`.
21
25
  * **Phase 1 (Generation):** Vitest runs unit and snapshot tests to verify the CLI contract.
22
- * **Phase 2 (Static Application Security Testing - SAST):** The CI pipeline runs `trivy config` against the generated `Dockerfile` and Terraform snapshots to guarantee they remain compliant with strict security policies.
23
- * **Phase 3 (IaC Validation):** The CI pipeline runs `tflint` and `terraform validate` against the snapshots to ensure HashiCorp's compiler accepts the generated syntax before a release is cut.
26
+ * **Phase 2 (Static Application Security Testing - SAST):** CI runs `trivy config` against the generated `Dockerfile` and Terraform snapshots to guarantee they remain compliant with strict security policies.
27
+ * **Phase 3 (IaC Validation):** The `iac-validation` matrix workflow scaffolds all 10 supported frameworks headlessly (`--headless --preconfigured`), then runs `terraform init -backend=false` + `terraform validate`, `tflint`, and a Trivy filesystem scan (fails on HIGH/CRITICAL) fully offline with no AWS credentials.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deploy-stack",
3
- "version": "0.17.14",
3
+ "version": "0.18.0",
4
4
  "description": "Provision production-ready AWS infrastructure and CI/CD pipelines in seconds.",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -0,0 +1,17 @@
1
+ # Spec: Continuous Infrastructure Validation Pipeline
2
+
3
+ ## Objective
4
+ Create a GitHub Actions workflow that automatically generates, compiles, and security-scans our IaC templates across all supported frameworks to prevent regressions.
5
+
6
+ ## Requirements
7
+ 1. **Workflow Registration:** Create `.github/workflows/iac-validation.yml` triggered on push to `main` and all pull requests.
8
+ 2. **Matrix Strategy:** Run tests across all 10 supported framework permutations: `nestjs`, `nextjs`, `nuxt`, `node`, `svelte`, `static`, `python`, `django`, `rails`, and `go`.
9
+ 3. **Execution Steps:** For each framework in the matrix:
10
+ - Scaffold the app: Run `node bin/cli.js --headless --preconfigured --framework=<matrix-framework>` in a temporary directory.
11
+ - Terraform Compile: Run `terraform init -backend=false` followed by `terraform validate`.
12
+ - Terraform Lint: Run `tflint` to catch deprecated syntax.
13
+ - DevSecOps Scan: Run Trivy (via `aquasecurity/trivy-action`) to scan the generated `Dockerfile` and `terraform/` directory.
14
+
15
+ ## Constraints
16
+ - The pipeline must execute completely offline without AWS credentials (hence `-backend=false`).
17
+ - Trivy must be configured to fail the build if it detects HIGH or CRITICAL vulnerabilities.
@@ -0,0 +1,16 @@
1
+ # Spec: Starlight Documentation Hub
2
+
3
+ ## Objective
4
+ Initialize an Astro Starlight documentation site inside the monorepo to serve as the official, version-controlled developer portal for `deploy-stack`.
5
+
6
+ ## Requirements
7
+ 1. **Scaffolding:** Initialize a new Astro Starlight project inside the `apps/docs/` directory.
8
+ 2. **Information Architecture:** Configure `astro.config.mjs` to render a sidebar with three main sections:
9
+ - **Core Concepts:** (Link to ADRs and architectural decisions).
10
+ - **Guides:** (Link to deployment guides and PaaS migrations).
11
+ - **CLI Reference:** (Command reference for init, apply, diagnose).
12
+ 3. **Migration:** Move all existing Markdown files from the root `docs/adrs/` folder into `apps/docs/src/content/docs/adrs/` so they are immediately searchable.
13
+
14
+ ## Constraints
15
+ - Use the standard Astro Starlight dependency tree.
16
+ - Ensure a script (e.g., `"docs:dev": "npm run dev --workspace=apps/docs"`) is added to the root `package.json` to allow starting the docs from the top level.