Sources are Civet (
bin/,lib/,functions/,build.civet,validate-template.civet).build.civet(esbuild +@danielx/civet) compiles them todist/— the CDK app todist/pixie.cjsand eachfunctions/*.civetto a standalonedist/functions/*.js(CloudFrontJS_2_0-safe).cdk.jsonruns the build automatically on everycdkcommand, so there's no separate build step;dist/is gitignored.
Greenfield CDK stack for the static archive. Entirely separate from the legacy distribution
E3BKYYG8EH9O0K (which serves pixieengine.com today and is never touched by this stack).
Cutover = move the DNS alias to the new distribution.
- S3 bucket
pixieengine-static— private (CloudFront OAC only),RETAIN(content survivescdk destroy). - CloudFront Function
pixieengine-rewrite(compiled fromfunctions/rewrite.civet→dist/functions/rewrite.js; unit-tested vianpm test). - OAC + bucket policy (auto-managed by CDK since the bucket is stack-owned).
- CloudFront distribution: function on viewer-request,
index.htmlroot,403/404 → /410/index.htmlserved as 404 (CloudFront's custom-error responses don't allow a 410 code; both still de-index in Google). - (
withDomainonly) ACM cert (DNS-validated via the existing zone) +pixieengine.comalias + Route 53 A/AAAA records. pixie-deployIAM role (assumed by thepixie-opsuser) with read/write on the bucket,cloudfront:CreateInvalidationon the dist, and scoped backup-recovery access. No long-lived deploy key — content deploys assume the role for short-lived STS creds.
- Node 18+.
cdk synth/diffneed no creds. cdk deployruns locally as thepixie-opsprofile (scoped tosts:AssumeRoleon the CDK bootstrap roles):npx cdk deploy --profile pixie-ops. See "Credentials" below.- One-time per account/region:
npx cdk bootstrap aws://<account>/us-east-1— needs admin (run in CloudShell), sincepixie-opscan only assume the bootstrap roles, not create them. Already bootstrapped for this account, so normally skip it. npm installin this dir.
[pixie-ops] # the only static key — low-privilege (assume CDK + deploy roles)
aws_access_key_id = AKIA...
aws_secret_access_key = ...
[pixie-deploy] # keyless — assumes the role via pixie-ops; auto-refreshed STS creds
role_arn = arn:aws:iam::186123361267:role/pixie-deploy
source_profile = pixie-ops
region = us-east-1cdk deploy uses --profile pixie-ops; content syncs/invalidations use --profile pixie-deploy.
Nothing needs re-pasting across key rotations or stack updates — the role ARN is stable.
Deploys run locally as pixie-ops (below); only the one-time cdk bootstrap needs admin, since
pixie-ops can assume the bootstrap roles but not create them. This account is already
bootstrapped, so you normally skip this section. If you ever need to re-bootstrap:
CloudShell starts empty, so get this infra/ dir there. Either:
- git (if the repo is reachable): commit + push
infra/(it's self-contained — includesfunctions/*.civet;npm installpulls the build deps), then in CloudShellgit clone <repo> && cd pixieengine.com/infra, or - upload: CloudShell → Actions → Upload file → a zip of
infra/.
Then (CloudShell uses your console admin identity, no profile flag needed):
cd infra && npm install
npx cdk bootstrap aws://186123361267/us-east-1 # once per account/regioncd infra
npm install
npx cdk deploy --profile pixie-ops # creates bucket + dist + function (alias NOT attached yet)Note the DistributionDomain output (dXXXX.cloudfront.net).
Then populate the new bucket (content is NOT managed by CDK — it's a deploy step), syncing the generated tree with the deploy profile:
aws s3 sync ../static-site/public s3://pixieengine-static --profile pixie-deploy
aws cloudfront create-invalidation --distribution-id <DistributionId> --paths "/*" --profile pixie-deployTest everything on https://dXXXX.cloudfront.net/ — gallery, slug URLs, ?tagged= 301, missing→404, replay, tune.
A CloudFront alias can only exist on one distribution. So:
- Remove the
pixieengine.comalias (CNAME) from the legacy distE3BKYYG8EH9O0K(console). - Add it to the new dist + create cert + DNS:
(The ACM DNS validation auto-creates a CNAME in the zone; first deploy waits for it.)
npx cdk deploy -c withDomain=true --profile pixie-ops # ACM cert, alias, Route 53 A/AAAA -> new dist - Verify
https://pixieengine.com/.
Re-point the pixieengine.com Route 53 alias back to the legacy dist (or re-add the alias there).
Nothing in the legacy distribution was modified, so rollback is just DNS.
aws s3 sync ../static-site/public s3://pixieengine-static --delete --profile pixie-deploy
then a CloudFront invalidation.