CLI, not a PaaS

Deploy Next.js into your AWS account.

From a GitHub repo to a live site on one push. Actions assumes a short-lived OIDC role. Site bytes stay in that AWS account.

Pin @coresecure/deploy@0.7.0-rc.10. GitHub Packages only. Node 24 or newer, and pnpm.

Architecture

From repo to live site, in one push.

csd stands up the GitHub side and hands Actions an OIDC role. SST and OpenNext provision the AWS services the site runs on.

Next.js projectYour repo, your codecsdinit · oidcGitHub ActionsShort-lived OIDC tokenAssumeRoleno keysYOUR AWS ACCOUNTCloudFrontGlobal edge CDNLambdaSSR via OpenNextS3Static assetsRoute53 + ACMExisting Route53 zone and us-east-1 certsst deployLive sitewww.acme.com

Simplify. gh auth, aws sso login, csd init, csd oidc, then a push. The zone and the cert already exist.

Own it. Every AWS service in the diagram is provisioned inside your account under your name. Coresecure never holds a copy of your site.

No keys. GitHub Actions authenticates with a short-lived OIDC token, not a stored AWS access key.

Stages

Pick how many gates stand before the public site.

csd init --preset takes two, three, four, or three-test. The default is two. Each stage has its own branch, hostname, and GitHub environment. Production stays none unless stageOverrides.production.authMode is vip. This host gates staging and keeps production public. basicAuth and signedCookie are rejected. Other stages default to vip. The diagram shows the server-rendered default. --auth-mode sets every non-prod stage to none or vip.

  • --preset twoOne gate before the public site.
    vip

    staging

    staging-www.apex

    staging

    public

    production

    www.apex

    main

  • --preset threeA developer stage ahead of staging.
    vip

    dev

    dev-www.apex

    dev

    vip

    staging

    staging-www.apex

    staging

    public

    production

    www.apex

    main

  • --preset fourAdds test between dev and staging.
    vip

    dev

    dev-www.apex

    dev

    vip

    test

    test-www.apex

    test

    vip

    staging

    staging-www.apex

    staging

    public

    production

    www.apex

    main

vip
The VIP login gates the whole stage. Dev, test, and staging use this when you omit --auth-mode. A request with no CloudFront cookies is redirected to the login URL. /_csd/version stays public.
public
authMode none. That is the production default, and this host's production uses it. --auth-mode none sets the other stages the same way.

Auth gates the whole stage. authMode is the only switch. For each vip stage, the deploy installs the VIP key with the GitHub OIDC token of the job. CSD_VIP_URL picks the VIP. On this host staging is vip and sits behind the VIP login. Production stays none and is public.

Config is csd.config.json. schemaVersion is 1. On a site, apexDomain is required, certArn and zoneId are optional, and project is optional. framework is next or nuxt. A service requires project and does not take apexDomain, certArn, zoneId, waf, or framework. region defaults to us-east-1. On a site, stageOverrides accepts authMode and waf on every stage, and hostname and redirectHosts on production only. A branch override is rejected. The GitHub Environment is named after the stage. There is no domains key. redirects, staticBucketAdmins, and failover are static only.

csd statusmain
acme/www apex acme.com waf per-site
staging staging-www.acme.com live a1b2c3d head a1b2c3d
production www.acme.com live 9f8e7d6 head c4d5e6f behind staging by 2
next: gh pr create --base main --head staging
watch: gh run watch --repo acme/www

Redundancy

A static site can fail over. This host stays in one region.

@coresecure/deploy@0.7.0-rc.10 can switch a static site to a second S3 bucket on 5xx or timeout. www.coresecure.info is server-rendered Next.js. Its request path stays in us-east-1.

Static csd sites with failover

  1. Visitor

  2. Route 53

  3. CloudFront + ACM

  4. csd-shared-waf

  5. origin group

    • S3 primary

      us-east-1

      Healthy

    • S3 secondary

      failover region

      Healthy, standby

CloudFront switches to the secondary bucket on 5xx or timeout. Enabled with failover: { region }. Static sites only.

www.coresecure.info today

  1. Visitor

  2. Route 53

  3. CloudFront + ACM

    vip gate

  4. csd-shared-waf

  5. us-east-1

    • Lambda server

    • S3 assets

Single region by design because the site is server-rendered Next.js. csd failover does not apply.

Install

Pin it in the tenant lockfile.

Pin @coresecure/deploy@0.7.0-rc.10. The package is on GitHub Packages at npm.pkg.github.com. It is not on the public npm registry. Node 24 or newer, and pnpm. This host pins 0.7.0-rc.10 in the lockfile. Actions runs pnpm i --frozen-lockfile, then pnpm exec csd-deploy. Grant the repo Actions access on the package or CI returns 403.

.npmrc
@coresecure:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
onboard a tenant
gh auth login -s read:packages
aws sso login --profile <client>
gh repo clone <owner>/<repo> && cd <repo>
csd init --preset two --apex <apex>
csd oidc --profile <client>
NODE_AUTH_TOKEN=$(gh auth token) pnpm install
git add -A && git commit -m "Add the csd tenant"
git checkout -B staging && git push -u origin staging
csd status
csd doctor
  1. 1. gh auth login -s read:packages. Put the .npmrc lines where pnpm reads them. Then NODE_AUTH_TOKEN=$(gh auth token) pnpm --package=@coresecure/deploy@0.7.0-rc.10 dlx csd. After the tenant install, pnpm exec csd.
  2. 2. aws sso login --profile <client>. The Route53 zone and the issued us-east-1 ACM cert already exist. The cert covers every stage hostname.
  3. 3. gh repo clone. If the repo does not exist yet, gh repo create <owner>/<repo> --private --add-readme --clone && cd <repo>.
  4. 4. csd init --preset two --apex <apex> from the top of the clone. Then csd oidc --profile <client>.
  5. 5. NODE_AUTH_TOKEN=$(gh auth token) pnpm install. Commit. Push the staging branch. csd status. Open the gh pr create line when it prints one. csd doctor.

Commands

What you actually type.

csd uses gh or GH_TOKEN. csd oidc uses an AWS profile. csd secrets calls sst. csd refuses to run when CI=true. CI runs csd-deploy.

01 / csd init

Stand up a site

GitHub only. Run it from the top of a clone. A site requires an apex. --preset is two, three, four, or three-test, and the default is two. --auth-mode is none or vip, and it applies to non-prod stages. Production stays none unless stageOverrides.production.authMode is vip. basicAuth and signedCookie are rejected. Omit --auth-mode and dev, test, and staging use vip. Init copies the tenant template when sst.config.ts is absent. An existing Next app without that file is refused. Creating environments and secrets needs repository admin. Init does not call AWS and does not commit.

csd init
gh repo clone <owner>/<repo> && cd <repo>
csd init --preset two --apex acme.com

02 / csd init --kind service

Stand up a service

Same clone, with --kind service. kind defaults to site. A service does not take an apex, a zone, a certificate, or waf.

csd init --kind service
csd init --kind service
csd oidc --profile <client>

03 / csd oidc

Create the deploy role

AWS SSO, once per repo. It writes CSD_DEPLOY_ROLE_ARN and CSD_AWS_REGION. A site also gets CSD_ZONE_ID and CSD_CERT_ARN. The Route53 zone and the issued us-east-1 ACM cert already exist. The cert has to cover every stage hostname. csd does not create the zone or the cert. A service skips both. An existing stack is updated in place. Run it again to pick up a role change. It does not deploy the site.

csd oidc
aws sso login --profile <client>
csd oidc --profile <client>

04 / csd status

Read the chain, then open the printed PR

Push the stage branch. Actions runs csd-deploy for that stage. csd status prints a gh pr create line only when a later stage is behind and the previous stage is already live. Open that PR with gh or the GitHub UI. Merge deploys the next stage. There is no csd promote, ship, advance, or pr.

csd status
git push -u origin staging
csd status
csd status --all

05 / csd doctor

Audit the tenant

In this clone, doctor reads csd.config.json. --repo reads that file on GitHub. --ref reads a branch, tag, or commit. The waf line prints one mode when every stage agrees, and stage=mode when they differ. With AWS credentials it reads deploy role policy csd-deploy and fails with destroy_role when a static destroy action is missing. With no credentials it prints that the destroy role scan was skipped.

csd doctor
csd doctor
csd doctor --all

06 / csd init --refresh

Rewrite vendored YAML

Rewrites .github/workflows/deploy.yml and .github/actions/csd-deploy/action.yml. It does not rotate keys. It does not call AWS. It does not set branch protection. You commit and push.

csd init --refresh
csd init --refresh
git add .github/workflows/deploy.yml .github/actions/csd-deploy/action.yml
git commit -m "Refresh the csd workflow"
git push origin staging

07 / authMode vip

Gate a stage with VIP

csd vip was removed. The deploy gates each stage whose authMode is vip. It fetches the repo owner's VIP key from CSD_VIP_URL with the job's GitHub OIDC token, installs it in that owner's CloudFront key group, and attaches the group. CSD_VIP_URL defaults to https://vip.coresecure.com. You no longer set any CSD_GATE_* variable: the deploy derives them from authMode and hands them to SST. Run csd init --refresh so the workflow stops passing them, then delete them. Production stays none unless stageOverrides.production.authMode is vip. A service has no preview auth.

authMode vip
{
  "stageOverrides": {
    "staging": { "authMode": "vip" }
  }
}

08 / waf in csd.config.json

Choose shared or per-site

waf is shared or per-site, and the default is per-site. A stage stays per-site until csd.config.json sets waf to shared, or stageOverrides.<stage>.waf to shared. Services do not take waf. There is no csd waf command. Install the ACL once per account from a clone of the deploy repo, as stack csd-shared-waf in us-east-1. The stack writes the ARN to SSM /csd/shared-waf/arn and to the WebAclArn output. A shared deploy reads CSD_SHARED_WAF_ARN, then that parameter, then the output. The ARN alone does not attach the ACL. csd doctor fails when a shared stage cannot find it, and when a copied sst.config.ts does not read CSD_SHARED_WAF_ARN.

waf in csd.config.json
aws cloudformation deploy --region us-east-1 --stack-name csd-shared-waf --template-file infra/bootstrap/shared-waf.yaml

09 / csd secrets

Set app secrets

csd secrets list prints names. csd secrets set <name> reads the value from a pipe or a prompt. The value is not an argument. csd secrets check prints set, placeholder, or missing. Redeploy after set.

csd secrets
csd secrets set Name --stage staging < secret.txt
csd secrets check

10 / csd status --all

Read every tenant at once

GitHub is the project list. csd.projects.yaml is a local cache, and you do not commit it. The first csd status --all or csd doctor --all discovers the repos and writes the cache. There is no csd projects sync: no command refreshes a file that already exists. csd init writes the current repo into it.

csd status --all
csd status --all
csd doctor --all

11 / csd destroy

Tear down a stage

Usage is csd destroy <stage> [--confirm <value>]. Type the apex for a site, or owner/repo for a service. When there is no terminal, pass that text as --confirm. CI runs csd-deploy --action remove. If doctor reports destroy_role, run csd oidc before the retry.

csd destroy
csd destroy staging --confirm acme.com

12 / this host

www.coresecure.info is a tenant

Preset two. Apex coresecure.info. Region us-east-1. waf is shared. Staging is staging-www.coresecure.info and production is www.coresecure.info. Staging sets authMode vip and sits behind the VIP login. Production has no authMode override and is public. The pin is @coresecure/deploy 0.7.0-rc.10 from GitHub Packages. This repo is Next 16.3.8, React 19.2.8, and OpenNext 4.1.7. After install, run pnpm exec csd.

this host
pnpm exec csd status
pnpm exec csd doctor

Feature set

The boring parts are load-bearing.

01

Their account. No stored keys.

Actions assumes a short-lived OIDC role. csd oidc writes CSD_DEPLOY_ROLE_ARN. There is no AWS access key in the tenant.

02

Two binaries.

Humans run csd. It refuses to run when CI=true. CI runs csd-deploy --stage <id> --action deploy, redeploy, or remove. A service workflow offers the same three actions.

03

Promotion is a pull request.

csd status prints a gh pr create line only when a later stage is behind and the previous stage is already live. Open that PR and merge. There is no csd promote, ship, advance, or pr.

04

Auth gates the whole stage.

Production stays none unless stageOverrides.production.authMode is vip. basicAuth and signedCookie are rejected. Other stages default to vip.

05

Bring the zone and the cert.

csd never creates the hosted zone or the certificate. The cert is an issued us-east-1 ACM cert and covers every stage hostname.

06

WAF is opt-in shared.

The default is per-site. Set waf to shared, or set it on one stage. Install the ACL once per account from infra/bootstrap/shared-waf.yaml. Services do not take waf.

07

A service is not a site.

csd init --kind service takes no apex, zone, certificate, or waf.

08

Two supported app pairs.

Next 16.3.8 with React 19.2.8 and OpenNext 4.1.7, or Next 15.5.27. Nuxt is static only. Next stays server-rendered unless staticExport is true. Failover is static only, uses a different region, and is off by default.