deploy-stack 0.18.0 → 0.18.2
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.
- package/.github/workflows/deploy-docs.yml +37 -0
- package/.github/workflows/iac-validation.yml +67 -6
- package/.github/workflows/publish.yml +5 -0
- package/.muserules +6 -1
- package/README.md +6 -6
- package/apps/docs/.astro/collections/docs.schema.json +644 -0
- package/apps/docs/.astro/content-assets.mjs +4 -0
- package/apps/docs/.astro/content-modules.mjs +4 -0
- package/apps/docs/.astro/content.d.ts +179 -0
- package/apps/docs/.astro/data-store.json +1 -0
- package/apps/docs/.astro/dev.json +14 -0
- package/apps/docs/.astro/settings.json +5 -0
- package/apps/docs/.astro/types.d.ts +2 -0
- package/apps/docs/astro.config.mjs +68 -0
- package/apps/docs/package.json +17 -0
- package/{docs/adr → apps/docs/src/content/docs/adrs}/0001-s3-native-state-locking.md +4 -1
- package/{docs/adr → apps/docs/src/content/docs/adrs}/0002-eject-mechanism-pure-iac.md +4 -1
- package/{docs/adr → apps/docs/src/content/docs/adrs}/0003-sync-ai-context-strategy.md +4 -1
- package/{docs/adr → apps/docs/src/content/docs/adrs}/0004-iac-driven-diagnostic-context.md +4 -1
- package/apps/docs/src/content/docs/cli/apply.md +29 -0
- package/apps/docs/src/content/docs/cli/destroy.md +29 -0
- package/apps/docs/src/content/docs/cli/diagnose.md +28 -0
- package/apps/docs/src/content/docs/cli/doctor.md +28 -0
- package/apps/docs/src/content/docs/cli/eject.md +29 -0
- package/apps/docs/src/content/docs/cli/init.md +42 -0
- package/apps/docs/src/content/docs/cli/secrets.md +36 -0
- package/apps/docs/src/content/docs/cli/sync-ai.md +27 -0
- package/apps/docs/src/content/docs/guides/aws-credentials.md +68 -0
- package/apps/docs/src/content/docs/guides/cicd-pipeline.md +46 -0
- package/{docs → apps/docs/src/content/docs}/guides/database-connections.md +4 -1
- package/apps/docs/src/content/docs/guides/docker-compose.md +37 -0
- package/apps/docs/src/content/docs/guides/dockerfiles.md +46 -0
- package/{docs → apps/docs/src/content/docs}/guides/ephemeral-pr-previews.md +4 -1
- package/{docs → apps/docs/src/content/docs/guides}/examples.md +15 -8
- package/apps/docs/src/content/docs/guides/frameworks.md +88 -0
- package/{docs → apps/docs/src/content/docs}/guides/headless.md +4 -1
- package/apps/docs/src/content/docs/guides/rerun-init.md +43 -0
- package/{docs → apps/docs/src/content/docs}/guides/secrets-management.md +4 -1
- package/apps/docs/src/content/docs/index.mdx +36 -0
- package/{docs/migration → apps/docs/src/content/docs/migrations}/astro-vercel-to-aws.md +4 -1
- package/{docs/migration → apps/docs/src/content/docs/migrations}/heroku-procfile-to-aws.md +4 -1
- package/{docs/migration → apps/docs/src/content/docs/migrations}/nextjs-vercel-to-aws.md +4 -1
- package/{docs/migration → apps/docs/src/content/docs/migrations}/sveltekit-vercel-to-aws.md +4 -1
- package/{docs/ROADMAP.md → apps/docs/src/content/docs/roadmap.md} +5 -2
- package/{docs → apps/docs/src/content/docs}/testing-strategy.md +13 -9
- package/apps/docs/src/content.config.ts +7 -0
- package/apps/docs/src/custom.css +14 -0
- package/apps/docs/tsconfig.json +6 -0
- package/bin/cli.js +1 -1
- package/package.json +7 -2
- package/src/commands/diagnose.js +21 -7
- package/src/commands/init.js +5 -5
- package/src/commands/secrets.js +23 -8
- package/src/core/telemetry.js +8 -5
- package/src/utils/aws.js +16 -0
- package/src/utils/generator.js +6 -5
- package/src/utils/prompts.js +1 -1
- package/templates/docker/nestjs.Dockerfile +15 -3
- package/templates/docker/svelte.Dockerfile +4 -2
- package/templates/terraform/backend.tf +14 -1
- package/templates/terraform/secrets.tf +0 -6
- package/tests/__snapshots__/generator.test.js.snap +4 -2
- package/tests/diagnose.test.js +2 -2
- package/tests/secrets.test.js +29 -0
- package/docs/frameworks.md +0 -34
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineConfig } from 'astro/config';
|
|
2
|
+
import starlight from '@astrojs/starlight';
|
|
3
|
+
|
|
4
|
+
// https://starlight.astro.build/reference/configuration/
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
site: 'https://anton-codes-iac.github.io',
|
|
7
|
+
base: '/deploy-stack',
|
|
8
|
+
integrations: [
|
|
9
|
+
starlight({
|
|
10
|
+
title: 'deploy-stack',
|
|
11
|
+
description: 'Provision production-ready AWS infrastructure and CI/CD pipelines in seconds.',
|
|
12
|
+
customCss: ['./src/custom.css'],
|
|
13
|
+
sidebar: [
|
|
14
|
+
{
|
|
15
|
+
label: 'CLI Commands',
|
|
16
|
+
items: [
|
|
17
|
+
{ label: 'npx deploy-stack (init)', link: '/cli/init/' },
|
|
18
|
+
{ label: 'apply', link: '/cli/apply/' },
|
|
19
|
+
{ label: 'destroy', link: '/cli/destroy/' },
|
|
20
|
+
{ label: 'secrets push', link: '/cli/secrets/' },
|
|
21
|
+
{ label: 'diagnose', link: '/cli/diagnose/' },
|
|
22
|
+
{ label: 'doctor', link: '/cli/doctor/' },
|
|
23
|
+
{ label: 'eject', link: '/cli/eject/' },
|
|
24
|
+
{ label: 'sync-ai', link: '/cli/sync-ai/' },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'Deployment Guides',
|
|
29
|
+
items: [
|
|
30
|
+
{ label: 'CI/CD Pipeline & First Deploy', link: '/guides/cicd-pipeline/' },
|
|
31
|
+
{ label: 'Supported Frameworks', link: '/guides/frameworks/' },
|
|
32
|
+
{ label: 'Examples', link: '/guides/examples/' },
|
|
33
|
+
{ label: 'AWS Credentials & Auth', link: '/guides/aws-credentials/' },
|
|
34
|
+
{ label: 'Database Connections', link: '/guides/database-connections/' },
|
|
35
|
+
{ label: 'Secrets Management', link: '/guides/secrets-management/' },
|
|
36
|
+
{ label: 'Dockerfiles & Containers', link: '/guides/dockerfiles/' },
|
|
37
|
+
{ label: 'Docker Compose', link: '/guides/docker-compose/' },
|
|
38
|
+
{ label: 'Ephemeral PR Previews', link: '/guides/ephemeral-pr-previews/' },
|
|
39
|
+
{ label: 'Headless Mode & Automation', link: '/guides/headless/' },
|
|
40
|
+
{ label: 'Re-running Init', link: '/guides/rerun-init/' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: 'Platform Migrations',
|
|
45
|
+
items: [
|
|
46
|
+
{ label: 'Vercel (Next.js)', link: '/migrations/nextjs-vercel-to-aws/' },
|
|
47
|
+
{ label: 'Heroku (Procfile)', link: '/migrations/heroku-procfile-to-aws/' },
|
|
48
|
+
{ label: 'Vercel (Astro)', link: '/migrations/astro-vercel-to-aws/' },
|
|
49
|
+
{ label: 'Vercel (SvelteKit)', link: '/migrations/sveltekit-vercel-to-aws/' },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: 'Project Details',
|
|
54
|
+
items: [
|
|
55
|
+
{ label: 'Roadmap', link: '/roadmap/' },
|
|
56
|
+
{ label: 'Testing Strategy', link: '/testing-strategy/' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: 'Architecture (ADRs)',
|
|
61
|
+
items: [
|
|
62
|
+
{ autogenerate: { directory: 'adrs' } }
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "astro dev",
|
|
8
|
+
"build": "astro build",
|
|
9
|
+
"preview": "astro preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@astrojs/starlight": "^0.42.2",
|
|
13
|
+
"astro": "^7.3.3",
|
|
14
|
+
"js-yaml": "^4.3.2",
|
|
15
|
+
"sharp": "^0.34.2"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "S3 Native State Locking"
|
|
3
|
+
description: "When deploying infrastructure via Terraform across local developer workstations and automated CI/CD pipelines, remote state management is required to prevent ra"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
6
|
* **Status:** Accepted
|
|
4
7
|
* **Date:** 2026-08-15 (Retroactive)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Eject Mechanism for Pure IaC"
|
|
3
|
+
description: "deploy-stack abstracts away the complexity of writing raw Terraform for ECS Fargate, ALBs, CloudFront, OIDC, and Secrets Manager. However, a primary reason seni"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
6
|
* **Status:** Accepted
|
|
4
7
|
* **Date:** 2026-08-20 (Retroactive)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "AI Context Synchronization Strategy"
|
|
3
|
+
description: "Modern engineering teams heavily utilize AI coding assistants (Cursor, GitHub Copilot, Windsurf, Claude Code, etc.) in their local IDEs. However, when dealing w"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
6
|
* **Status:** Accepted
|
|
4
7
|
* **Date:** 2026-09-02 (Retroactive)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "IaC-Driven Diagnostic Context (Stateless CLI)"
|
|
3
|
+
description: "To provide a seamless developer experience, the deploy-stack diagnose command needs to automatically fetch CloudWatch logs and ECS task failures without requiri"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
6
|
* **Status:** Accepted
|
|
4
7
|
* **Date:** 2026-09-19
|
|
@@ -0,0 +1,29 @@
|
|
|
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 deploy-stack 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. 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`) plus the `git push` command that deploys your app and clears the initial 503.
|
|
13
|
+
- 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.
|
|
14
|
+
- Emits an `infrastructure_applied` telemetry event recording success or the error code.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx deploy-stack apply
|
|
20
|
+
npx deploy-stack apply --dry-run
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Flags
|
|
24
|
+
|
|
25
|
+
| Flag | Description |
|
|
26
|
+
| ---- | ----------- |
|
|
27
|
+
| `--dry-run` | Render a preview of the planned changes without applying them. |
|
|
28
|
+
|
|
29
|
+
`apply` shells out to the `terraform` binary in your generated `terraform/` directory and streams progress while it runs.
|
|
@@ -0,0 +1,29 @@
|
|
|
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 deploy-stack 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
|
+
- Runs `terraform destroy -auto-approve` in `terraform/`, streaming progress, so all compute resources (ECS, ALB, database, and related resources) are removed.
|
|
13
|
+
- 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.
|
|
14
|
+
- Emits an `infrastructure_destroyed` telemetry event recording success and whether the state bucket was retained.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx deploy-stack destroy
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Flags
|
|
23
|
+
|
|
24
|
+
This command accepts no CLI flags. Both confirmation prompts are interactive.
|
|
25
|
+
|
|
26
|
+
## See also
|
|
27
|
+
|
|
28
|
+
- [apply](/cli/apply/)
|
|
29
|
+
- [doctor](/cli/doctor/)
|
|
@@ -0,0 +1,28 @@
|
|
|
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 `region` in `terraform/main.tf` (default `us-east-1`), overridable via `AWS_REGION`; the cluster (`<project-name>-cluster`, overridable via `ECS_CLUSTER`); and the log group (`/ecs/<project-name>`, overridable via `ECS_LOG_GROUP`).
|
|
12
|
+
- Lists up to 10 recent stopped tasks, describes up to 5 of them, and diagnoses the most recently stopped one: stopped reason, failing container name, exit code, and container reason.
|
|
13
|
+
- Makes no changes to your infrastructure; it is read-only. Prints a healthy message and exits when no stopped tasks exist.
|
|
14
|
+
- On expired AWS credentials, points you to `aws sso login` / `aws configure` and the [AWS credentials guide](/guides/aws-credentials/).
|
|
15
|
+
- Emits a `diagnose_run` telemetry event recording success and whether the service was healthy.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx deploy-stack diagnose
|
|
21
|
+
npx deploy-stack wtf
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`wtf` is an alias for `diagnose`.
|
|
25
|
+
|
|
26
|
+
## Flags
|
|
27
|
+
|
|
28
|
+
This command accepts no CLI flags. Region, cluster, and log group are resolved as described above, not from flags.
|
|
@@ -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 a Homebrew install hint for anything missing.
|
|
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.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx deploy-stack doctor
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Flags
|
|
22
|
+
|
|
23
|
+
This command accepts no CLI flags.
|
|
24
|
+
|
|
25
|
+
## See also
|
|
26
|
+
|
|
27
|
+
- [npx deploy-stack (init)](/cli/init/)
|
|
28
|
+
- [apply](/cli/apply/)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: eject
|
|
3
|
+
description: Decouple your project from deploy-stack 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 deploy-stack metadata from your local files: removes the `# deploy-stack generated infrastructure` header and the `default_tags { tags = { ManagedBy = "deploy-stack" } }` block from `terraform/main.tf`, and removes the `# deploy-stack 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 deploy-stack 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](/cli/apply/)
|
|
29
|
+
- [destroy](/cli/destroy/)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Initializing Project (npx deploy-stack)
|
|
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 `docker-compose.yml`, 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
|
+
- 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).
|
|
12
|
+
- Finishes with the exact next steps: the `apply` command to provision, and the `git` commands to commit and push.
|
|
13
|
+
- Emits `project_provisioned` and `cli-error` telemetry events (disable with `--no-telemetry`).
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx deploy-stack
|
|
19
|
+
npx deploy-stack --headless --framework=nextjs --region=us-east-2
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Running with no subcommand starts the interactive setup wizard (`init` is the default command).
|
|
23
|
+
|
|
24
|
+
## Headless flags
|
|
25
|
+
|
|
26
|
+
| Flag | Description |
|
|
27
|
+
| ---- | ----------- |
|
|
28
|
+
| `--headless` | Bypass all interactive prompts (for CI/CD and automation). |
|
|
29
|
+
| `--framework=<name>` | `node`, `nextjs`, `nuxt`, `python`, `django`, `rails`, `go`, `static`. |
|
|
30
|
+
| `--region=<region>` | AWS region (e.g. `us-east-1`). |
|
|
31
|
+
| `--port=<port>` | Container port your app listens on. |
|
|
32
|
+
| `--size=<size>` | Fargate task size preset. |
|
|
33
|
+
| `--healthCheckPath=<path>` | ALB health-check path. |
|
|
34
|
+
| `--desiredCount=<n>` | Number of tasks to run. |
|
|
35
|
+
| `--branch=<name>` | Branch the CI workflow deploys. |
|
|
36
|
+
| `--needsDatabase` | Provision a managed database. |
|
|
37
|
+
| `--enablePrPreviews` | Enable ephemeral PR preview environments. |
|
|
38
|
+
| `--dir=<path>` | Target directory for generated files. |
|
|
39
|
+
| `--preconfigured` | Skip framework-specific warnings (for preconfigured setups). |
|
|
40
|
+
| `--no-telemetry` | Disable telemetry for this run. |
|
|
41
|
+
|
|
42
|
+
See the [Headless Mode guide](/guides/headless/) for automation examples.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: secrets push
|
|
3
|
+
description: Push local environment variables to AWS Secrets Manager.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Upload your `.env` file to the Secrets Manager vault provisioned for this project, so your deployed app can read the values at runtime.
|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
|
|
10
|
+
- Reads and parses a local env file (defaults to `.env`) and pushes every key as a single JSON secret string to the `<project-name>-secrets` vault via `UpdateSecretCommand`. This is the value of the command: no manual AWS console edits, and your app picks up the values on the next deployment.
|
|
11
|
+
- Resolves the AWS region from the `region` setting in `terraform/main.tf`, falling back to `AWS_REGION` or your AWS profile default.
|
|
12
|
+
- Writes the pushed key names to `terraform/secret_keys.json` so the Terraform configuration and CI redeploy know which variables exist. Commit this file and push to trigger a deployment with the new variables.
|
|
13
|
+
- Emits a `secrets_pushed` telemetry event. Exits non-zero on failure.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx deploy-stack secrets push
|
|
19
|
+
npx deploy-stack secrets push .env.production
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The optional positional argument is the path of the env file to push (resolved relative to the project root). It defaults to `.env` when omitted or blank.
|
|
23
|
+
|
|
24
|
+
## Flags
|
|
25
|
+
|
|
26
|
+
This command accepts no CLI flags.
|
|
27
|
+
|
|
28
|
+
## Prerequisites
|
|
29
|
+
|
|
30
|
+
- Run `npx deploy-stack apply` first: the `<project-name>-secrets` vault is created during provisioning. If it does not exist yet, the command points you back to `apply`.
|
|
31
|
+
- Valid AWS credentials. On expired credentials, refresh with `aws sso login` or `aws configure`. See the [AWS credentials guide](/guides/aws-credentials/).
|
|
32
|
+
|
|
33
|
+
## See also
|
|
34
|
+
|
|
35
|
+
- [Secrets management guide](/guides/secrets-management/)
|
|
36
|
+
- [apply](/cli/apply/)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: sync-ai
|
|
3
|
+
description: Regenerate AI assistant rules for an existing project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Give your AI coding assistants up-to-date deploy-stack context after project settings change, so they generate correct Terraform and deployment instructions instead of hallucinating them.
|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
|
|
10
|
+
- Prompts you to choose which AI assistants to configure, then writes the matching rule files with your project's region (from `region` in `terraform/main.tf`) and container port (from `containerPort` in `terraform/main.tf`).
|
|
11
|
+
- Writes a full rule file for Cursor (`.cursor/rules/deploy-stack.mdc`), Roo (`.roo/rules/deploy-stack.md`), Trae (`.trae/rules/project_rules.md`), and Continue (`.prompts/deploy-stack.prompt`); injects a managed block into the existing config for Windsurf (`.windsurfrules`), Copilot (`.github/copilot-instructions.md`), Claude (`CLAUDE.md`), Goose (`.goosehints`), and Aider (`.aider.conf.yml`).
|
|
12
|
+
- Exits without writing anything when no assistants are selected.
|
|
13
|
+
- Emits a `sync_ai_executed` telemetry event listing the selected assistants.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx deploy-stack sync-ai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Flags
|
|
22
|
+
|
|
23
|
+
This command accepts no CLI flags. Assistant selection is interactive.
|
|
24
|
+
|
|
25
|
+
## See also
|
|
26
|
+
|
|
27
|
+
- [npx deploy-stack (init)](/cli/init/)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Troubleshooting AWS Credentials & Authentication
|
|
3
|
+
description: Troubleshooting AWS authentication, expired tokens, and SSO logins.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`deploy-stack` interacts directly with AWS APIs (Secrets Manager, ECS, CloudWatch, S3) using the official AWS SDK v3 default credential provider chain.
|
|
7
|
+
|
|
8
|
+
When you encounter an `UnrecognizedClientException` or `ExpiredTokenException`, your local AWS authentication state has lapsed.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Quick Refresh by Setup Type
|
|
13
|
+
|
|
14
|
+
### A. AWS IAM Identity Center (AWS SSO)
|
|
15
|
+
If your organization or personal account uses IAM Identity Center / SSO:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Log in to refresh your active session token
|
|
19
|
+
aws sso login
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If you use named profiles:
|
|
23
|
+
```bash
|
|
24
|
+
aws sso login --profile your-profile-name
|
|
25
|
+
export AWS_PROFILE=your-profile-name
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### B. Standard Long-Lived Access Keys (`~/.aws/credentials`)
|
|
31
|
+
If you use long-lived `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` pairs:
|
|
32
|
+
|
|
33
|
+
1. Verify credentials configured:
|
|
34
|
+
```bash
|
|
35
|
+
aws sts get-caller-identity
|
|
36
|
+
```
|
|
37
|
+
2. If invalid or missing:
|
|
38
|
+
```bash
|
|
39
|
+
aws configure
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### C. Temporary Session Tokens (`AWS_SESSION_TOKEN`)
|
|
45
|
+
If you assumed an IAM role or exported manual session tokens in your terminal:
|
|
46
|
+
|
|
47
|
+
Check if stale environment variables are overriding your global credentials:
|
|
48
|
+
```bash
|
|
49
|
+
echo $AWS_SESSION_TOKEN
|
|
50
|
+
```
|
|
51
|
+
If expired, clear them:
|
|
52
|
+
```bash
|
|
53
|
+
unset AWS_ACCESS_KEY_ID
|
|
54
|
+
unset AWS_SECRET_ACCESS_KEY
|
|
55
|
+
unset AWS_SESSION_TOKEN
|
|
56
|
+
```
|
|
57
|
+
Then re-authenticate via `aws configure` or `aws sso login`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 2. Common Error References
|
|
62
|
+
|
|
63
|
+
| Error Name | Root Cause | Solution |
|
|
64
|
+
| :--- | :--- | :--- |
|
|
65
|
+
| `UnrecognizedClientException` | The security token is unrecognized, mistyped, or expired. | Run `aws sso login` or re-run `aws configure`. |
|
|
66
|
+
| `ExpiredTokenException` | Temporary STS credentials passed their validity window (typically 1–12 hrs). | Refresh STS credentials or log into SSO again. |
|
|
67
|
+
| `AccessDeniedException` | User or role lacks IAM permissions for ECS, Secrets Manager, or S3. | Ensure your IAM user has adequate deployment permissions. |
|
|
68
|
+
| `ResourceNotFoundException` | Target cluster, secret, or log group does not exist in target region. | Verify `AWS_REGION` and ensure infrastructure was provisioned via `deploy-stack apply`. |
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: CI/CD Pipeline & First Deploy
|
|
3
|
+
description: How the generated GitHub Actions workflow builds, scans, and deploys your app with zero stored AWS keys.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Every `npx deploy-stack` run generates `.github/workflows/deploy.yml`. This page explains what that pipeline does, when it runs, and why your site returns `503` until the first push completes.
|
|
9
|
+
|
|
10
|
+
## When it runs
|
|
11
|
+
|
|
12
|
+
The workflow triggers on two events (`templates/github/deploy.yml`):
|
|
13
|
+
|
|
14
|
+
- A `push` to your deploy branch (`{{DEPLOY_BRANCH}}`, chosen during setup).
|
|
15
|
+
- A weekly Sunday cron (`0 0 * * 0`) that re-applies the Terraform configuration, so drift and base-image updates converge automatically.
|
|
16
|
+
|
|
17
|
+
The region, ECR repository, ECS cluster, and ECS service names are baked in at generation time as `<project>-repo`, `<project>-cluster`, and `<project>-service`.
|
|
18
|
+
|
|
19
|
+
## No stored AWS keys
|
|
20
|
+
|
|
21
|
+
Authentication uses GitHub OIDC, not long-lived credentials. The workflow declares:
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
permissions:
|
|
25
|
+
id-token: write
|
|
26
|
+
contents: read
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
and assumes the `{{PROJECT_NAME}}-github-actions-role` IAM role created by `terraform/oidc.tf`. There is nothing to rotate and no secret to leak. (If your AWS account already has a GitHub OIDC provider, set `create_oidc_provider = false` in `terraform/oidc.tf` — see [apply](/cli/apply/).)
|
|
30
|
+
|
|
31
|
+
## The five stages
|
|
32
|
+
|
|
33
|
+
1. **IaC security scan.** Trivy scans `terraform/` for vulnerabilities, secrets, and misconfigurations (`CRITICAL,HIGH`). It is informational only (`exit-code: '0'`), so it never blocks the build; results land in the GitHub step summary.
|
|
34
|
+
2. **Infrastructure sync.** The `anton-codes-iac/deploy-stack-action@v1` step runs Terraform against `terraform/`, so infrastructure changes committed alongside code are applied before the new image rolls out.
|
|
35
|
+
3. **Build & push.** The workflow logs in to Amazon ECR, runs `docker build` on your generated `Dockerfile`, and tags the result `latest`.
|
|
36
|
+
4. **Container scan.** Trivy scans the built image (`os,library`, `ignore-unfixed: true`), again informational only with results in the step summary.
|
|
37
|
+
5. **Deploy.** The image is pushed to ECR and the workflow forces a new ECS deployment (`aws ecs update-service --force-new-deployment`), which rolls the new image across your tasks behind the ALB.
|
|
38
|
+
|
|
39
|
+
## Why you see a 503 first
|
|
40
|
+
|
|
41
|
+
`npx deploy-stack apply` provisions the ALB, cluster, and service, but no container image exists until this workflow runs once. Pushing to your deploy branch (`git add . && git commit -m "ci: infra" && git push`) builds and deploys the first image, clearing the `503`. If the service stays unhealthy after that, run `npx deploy-stack diagnose` — usually the container failed its ALB health check (see [Dockerfiles](/guides/dockerfiles/)).
|
|
42
|
+
|
|
43
|
+
## Related workflows
|
|
44
|
+
|
|
45
|
+
- `preview.yml` / `teardown.yml` exist only when ephemeral PR previews are enabled. See [Ephemeral PR Previews](/guides/ephemeral-pr-previews/).
|
|
46
|
+
- Secrets are injected at deploy time from AWS Secrets Manager, never from the repo. See [Secrets Management](/guides/secrets-management/).
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Managed Database Connections"
|
|
3
|
+
description: "When you run npx deploy-stack for a backend framework (Node, Django, Rails, Go, etc.), the CLI prompts you to automatically provision a managed AWS RDS PostgreS"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
6
|
When you run `npx deploy-stack` for a backend framework (Node, Django, Rails, Go, etc.), the CLI prompts you to automatically provision a managed AWS RDS PostgreSQL database.
|
|
4
7
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Docker Compose Support
|
|
3
|
+
description: How deploy-stack maps docker-compose.yml services to ECS — web-service selection, ports, env vars, and sidecars.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 4
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
If your repo contains a `docker-compose.yml` (or `docker-compose.yaml`), setup parses it (`src/utils/dockerCompose.js`) and translates its services into the ECS task definition. Your Compose file keeps working locally, and these are the exact mapping rules that decide what runs in AWS.
|
|
9
|
+
|
|
10
|
+
## File discovery
|
|
11
|
+
|
|
12
|
+
Only the repo root is checked, trying `docker-compose.yml` first and then `docker-compose.yaml`. A file with no `services` key — or one that fails YAML parsing — is treated as absent (a warning is printed, setup continues), so a stray or malformed file never blocks generation.
|
|
13
|
+
|
|
14
|
+
## Which service is "web"
|
|
15
|
+
|
|
16
|
+
The service used as the ECS web service is the **first service with an exposed port**; if none exposes a port, the first service listed wins. Every other service becomes an ECS **sidecar** in the same task definition. Structure your file accordingly: the publicly reachable app must be the port-exposing service.
|
|
17
|
+
|
|
18
|
+
## Port mapping
|
|
19
|
+
|
|
20
|
+
The container port is taken from the **last segment of the first port entry** — `"8080:80"` and `"127.0.0.1:8001:8001"` both resolve to the right-hand value (`80` and `8001`). Only the first entry is read, and any non-numeric characters are stripped. This port overrides the configured container port during setup, and the ALB health check targets it.
|
|
21
|
+
|
|
22
|
+
## Environment and command injection
|
|
23
|
+
|
|
24
|
+
- **Environment** supports both Compose styles: `environment:` as a mapping is used as-is; as a list (`- KEY=value`) each entry is split on the first `=`.
|
|
25
|
+
- The web service's variables are injected directly into the ECS task definition, and its `command` overrides the container start command — but only when no `Procfile` `web:` process already set one (`Procfile` wins; see [Dockerfiles](/guides/dockerfiles/)).
|
|
26
|
+
- Sidecars get the same treatment: their environment is injected, their `command` is preserved, a missing `image` defaults to `alpine:latest`, and each sidecar logs to the shared CloudWatch log group under an `ecs-<service>` stream prefix.
|
|
27
|
+
|
|
28
|
+
## What this means in practice
|
|
29
|
+
|
|
30
|
+
- Sidecars (Redis, Memcached, background helpers) run **in the same task** as the web container and share its lifecycle — this is co-location, not separate services.
|
|
31
|
+
- Compose `build:` contexts are not used in AWS; the image is built from the generated `Dockerfile` by the [CI/CD pipeline](/guides/cicd-pipeline/).
|
|
32
|
+
- Runtime secrets still belong in AWS Secrets Manager, not in Compose `environment:`. See [Secrets Management](/guides/secrets-management/).
|
|
33
|
+
|
|
34
|
+
## See also
|
|
35
|
+
|
|
36
|
+
- [Supported Frameworks](/guides/frameworks/) for detection and defaults.
|
|
37
|
+
- [Dockerfiles & the container contract](/guides/dockerfiles/) for runtime requirements.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Dockerfiles & the Container Contract
|
|
3
|
+
description: What your app must do at runtime (port, bind address, health check) and the per-framework prerequisites.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 3
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Setup generates a framework-specific Alpine multi-stage `Dockerfile` engineered for zero Critical/High CVEs. Your app only needs to honor a small runtime contract — plus a few per-framework prerequisites printed as warnings (`src/utils/warnings.js`) at the end of setup.
|
|
9
|
+
|
|
10
|
+
## The container contract
|
|
11
|
+
|
|
12
|
+
Every generated image assumes three things. Violating any of them is the most common cause of failing ALB health checks after an otherwise successful `apply`:
|
|
13
|
+
|
|
14
|
+
1. **Listen on `$PORT`.** The container must serve traffic on the port baked in as `{{PORT}}` (default per framework — see [Supported Frameworks](/guides/frameworks/)).
|
|
15
|
+
2. **Bind `0.0.0.0`, not `localhost`.** Localhost-bound apps are unreachable inside ECS networking and Docker.
|
|
16
|
+
3. **Answer the health check with `200 OK`.** The ALB polls your health-check path (default `/`); anything else marks the task unhealthy and the pipeline's new deployment never stabilizes.
|
|
17
|
+
|
|
18
|
+
## Per-framework prerequisites
|
|
19
|
+
|
|
20
|
+
| Framework | What setup warns you about |
|
|
21
|
+
| --------- | -------------------------- |
|
|
22
|
+
| NestJS | Bind `0.0.0.0` in `src/main.ts`: `await app.listen(process.env.PORT ?? 3000, '0.0.0.0')` |
|
|
23
|
+
| Next.js | Set `output: 'standalone'` in your Next config and create a health-check route (copy-paste code is in the generated README's "Critical Application Prerequisites") |
|
|
24
|
+
| Node.js / Express | A `start` script in `package.json` (e.g. `"start": "node index.js"`) and `0.0.0.0` binding |
|
|
25
|
+
| Python (FastAPI) | Web framework in `requirements.txt`, `0.0.0.0` binding, and a health-check route returning `200 OK` |
|
|
26
|
+
| Rails | Your default `Dockerfile` is backed up to `Dockerfile.bak` and replaced with the Alpine build; if you use SQLite locally but provisioned RDS, add the `pg` gem |
|
|
27
|
+
| Static sites | Output folder defaults to `/app/dist` — if your framework emits `build/` or `out/`, update the `COPY` command; ensure a `build` script exists (e.g. `vite build`) |
|
|
28
|
+
|
|
29
|
+
Warnings are skipped with `--preconfigured` and for `static` projects whose build directory was auto-detected.
|
|
30
|
+
|
|
31
|
+
## What command runs your app
|
|
32
|
+
|
|
33
|
+
The container's start command is resolved in this order:
|
|
34
|
+
|
|
35
|
+
1. `Procfile` `web:` command, if a `Procfile` exists (a `worker:` process additionally generates `worker.tf`, i.e. a second ECS service that doubles Fargate cost).
|
|
36
|
+
2. Otherwise the `command` of the `docker-compose.yml` web service, if one exists.
|
|
37
|
+
3. Otherwise the default `CMD` in the generated `Dockerfile`.
|
|
38
|
+
|
|
39
|
+
## Keeping images lean
|
|
40
|
+
|
|
41
|
+
Setup writes a `.dockerignore` excluding `.git/`, `terraform/`, state files, and `.env`, and appends Terraform entries to an existing `.gitignore`. Never commit `.env` — runtime secrets come from AWS Secrets Manager (see [Secrets Management](/guides/secrets-management/)).
|
|
42
|
+
|
|
43
|
+
## See also
|
|
44
|
+
|
|
45
|
+
- [CI/CD Pipeline & First Deploy](/guides/cicd-pipeline/) for how the image is built and rolled out.
|
|
46
|
+
- [diagnose](/cli/diagnose/) for reading ECS failure output when the contract is broken.
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Ephemeral PR Previews"
|
|
3
|
+
description: "When enabled, deploy-stack automatically configures your GitHub Actions pipeline to spin up isolated, temporary AWS environments every time a developer opens a "
|
|
4
|
+
---
|
|
2
5
|
|
|
3
6
|
When enabled, `deploy-stack` automatically configures your GitHub Actions pipeline to spin up isolated, temporary AWS environments every time a developer opens a Pull Request.
|
|
4
7
|
|