mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 21:43:14 +00:00
Adds an env config layer resolved from CDK context (`-c env=staging`, default prod) and threads it through all three stacks so a fully isolated staging environment can be deployed in the same AWS account. prod is byte-identical: the prod config reproduces the deployed values exactly and stackSuffix='' keeps every construct ID, stack name, and physical resource name unchanged. Verified via synth — prod foundation keeps proposal-system-db / -uploads / db-credentials / -auth / seahaven; staging suffixes all of them. - config.ts: EnvConfig (prod + staging, same account) + resolveConfig - app.ts: env-aware stack naming + config passthrough - foundation/compute/frontend: ~40 physical names suffixed with config.stackSuffix; CORS, Cognito domain/callbacks, alarms email from config; RETAIN / deletionProtection gated on config.retainData so staging can be torn down - cdk.json: register `env` context (default prod) - post-deploy.sh: STACK_SUFFIX for dynamic stack-name lookup (default prod) Note: automated staging CI deploy needs a one-line `cdk-context` input added to the org reusable cd-cdk.yaml (companion change). prod deploy is unaffected (default prod).
38 lines
1.3 KiB
Bash
Executable file
38 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Multi-env (PR2): STACK_SUFFIX is '' for prod (default) and '-staging' for staging,
|
|
# matching the CDK stack-name suffix. Prod runs with no suffix -> names unchanged.
|
|
SUFFIX="${STACK_SUFFIX:-}"
|
|
|
|
cd web
|
|
npm ci
|
|
npm run build
|
|
cd ..
|
|
|
|
BUCKET=$(aws cloudformation describe-stacks \
|
|
--stack-name "proposal-system-frontend${SUFFIX}" \
|
|
--query "Stacks[0].Outputs[?OutputKey=='SiteBucketName'].OutputValue" \
|
|
--output text)
|
|
aws s3 sync web/dist "s3://$BUCKET" --delete
|
|
|
|
DIST_ID=$(aws cloudformation describe-stacks \
|
|
--stack-name "proposal-system-frontend${SUFFIX}" \
|
|
--query "Stacks[0].Outputs[?OutputKey=='DistributionId'].OutputValue" \
|
|
--output text)
|
|
aws cloudfront create-invalidation --distribution-id "$DIST_ID" --paths "/*"
|
|
|
|
# Health check: verify API is reachable
|
|
API_URL=$(aws cloudformation describe-stacks \
|
|
--stack-name "proposal-system-compute${SUFFIX}" \
|
|
--query "Stacks[0].Outputs[?OutputKey=='ApiEndpoint'].OutputValue" \
|
|
--output text)
|
|
|
|
echo "Running post-deploy health check..."
|
|
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${API_URL}/api/health" --max-time 10 || true)
|
|
if [ "$HTTP_STATUS" -eq 200 ]; then
|
|
echo "Health check passed (HTTP $HTTP_STATUS)"
|
|
else
|
|
echo "WARNING: Health check returned HTTP $HTTP_STATUS" >&2
|
|
exit 1
|
|
fi
|