grada-run 0.43.0 ā 0.43.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/package.json +1 -1
- package/src/commands/apply.js +4 -1
- package/src/commands/db/enable-vector.js +2 -0
- package/src/commands/db/migrate.js +10 -2
- package/src/commands/doctor.js +23 -0
- package/src/commands/secrets.js +44 -9
- package/templates/docker/django.Dockerfile +2 -2
- package/templates/docker/go.Dockerfile +2 -2
- package/templates/docker/python.Dockerfile +2 -2
- package/templates/docker/rails.Dockerfile +2 -2
- package/templates/docker/static.Dockerfile +1 -1
- package/templates/github/deploy-static.yml +20 -3
- package/templates/github/drift.yml +5 -11
- package/templates/github/preview-lambda.yml +5 -11
- package/templates/github/preview.yml +5 -11
- package/templates/github/teardown.yml +5 -11
- package/templates/terraform/addons/s3.tf +6 -4
- package/templates/terraform/database-aurora-postgresql.tf +6 -0
- package/templates/terraform/database-mysql.tf +5 -1
- package/templates/terraform/database.tf +5 -1
package/package.json
CHANGED
package/src/commands/apply.js
CHANGED
|
@@ -669,7 +669,10 @@ async function applyStackMain(input = {}) {
|
|
|
669
669
|
|
|
670
670
|
let finalMessage = color.green('ā
Infrastructure is live!');
|
|
671
671
|
if (cfUrl) finalMessage += `\n š App URL: ${color.cyan(cfUrl)} ${color.dim('(global CDN ā share this link)')}`;
|
|
672
|
-
|
|
672
|
+
// The origin only answers CloudFront (listener rule 403s direct
|
|
673
|
+
// hits without the origin-secret header) ā label the URL as
|
|
674
|
+
// unreachable instead of a working bypass (BUG-136).
|
|
675
|
+
if (albUrl) finalMessage += `\n š¦ Direct URL: ${color.gray(albUrl)} ${color.dim('(CloudFront-only origin ā direct hits 403)')}`;
|
|
673
676
|
// Lambda stacks have no CDN: without a CloudFront URL the API
|
|
674
677
|
// URL is the primary link, not a debug bypass.
|
|
675
678
|
if (apiUrl) {
|
|
@@ -323,6 +323,8 @@ async function runDbEnableVectorMain(input = {}) {
|
|
|
323
323
|
const exitCode = outcome.exitCode;
|
|
324
324
|
const stoppedReason = outcome.stoppedReason;
|
|
325
325
|
if (exitCode === 0) {
|
|
326
|
+
// Owner pairs its own start/stop (see migrate.js BUG-202).
|
|
327
|
+
try { s.stop(color.green('pgvector extension enabled.')); } catch { /* already stopped */ }
|
|
326
328
|
console.log(color.green('\nā
pgvector extension enabled.'));
|
|
327
329
|
try {
|
|
328
330
|
const prismaSchema = path.join(cwd, 'prisma', 'schema.prisma');
|
|
@@ -526,18 +526,26 @@ async function runDbMigrateMain(input = {}) {
|
|
|
526
526
|
const exitCode = outcome.exitCode;
|
|
527
527
|
const stoppedReason = outcome.stoppedReason;
|
|
528
528
|
if (exitCode === 0) {
|
|
529
|
+
// Owner pairs its own start/stop: the runner usually stops
|
|
530
|
+
// first (idempotent no-op then), but success must never
|
|
531
|
+
// depend on a callee for the spinner lifecycle (BUG-202).
|
|
532
|
+
try { s.stop(color.green('Migration succeeded.')); } catch { /* already stopped */ }
|
|
529
533
|
console.log(color.green('\nā
Migration succeeded.'));
|
|
530
534
|
await trackSuccess('db_migrate_run', { projectName, cmd_source: cmdSource, ci_setup: false });
|
|
531
535
|
outro(color.green('Done.'));
|
|
532
536
|
return { ok: true, success: true, exitCode: 0, taskArn: outcome.taskArn };
|
|
533
537
|
}
|
|
534
538
|
const propagated = (typeof exitCode === 'number' && exitCode > 0) ? exitCode : 1;
|
|
539
|
+
// The ECS stopped reason is the only diagnosis PostHog gets for a
|
|
540
|
+
// failed task (exit codes alone can't distinguish image-pull from
|
|
541
|
+
// command-not-found from migration errors) ā stamp it.
|
|
542
|
+
const failureDetail = `Migration failed with exit code ${exitCode ?? 'unknown'}: ${stoppedReason}`;
|
|
535
543
|
return failCommand({
|
|
536
|
-
message: `\nā
|
|
544
|
+
message: `\nā ${failureDetail}.\n`,
|
|
537
545
|
event: 'db_migrate_run',
|
|
538
546
|
telemetry: { projectName, cmd_source: cmdSource, ci_setup: false },
|
|
539
547
|
errorCode: 'MIGRATION_TASK_FAILED',
|
|
540
|
-
extra: { exit_code: exitCode ?? -1 },
|
|
548
|
+
extra: { exit_code: exitCode ?? -1, error_message: failureDetail },
|
|
541
549
|
reason: 'migration-task-failed',
|
|
542
550
|
resultExtra: { cluster, service, region, taskArn: outcome.taskArn },
|
|
543
551
|
exitCode: propagated,
|
package/src/commands/doctor.js
CHANGED
|
@@ -34,6 +34,7 @@ export const PROJECT_CHECKS = [
|
|
|
34
34
|
{ id: 'interrupted_run', label: 'Interrupted Terraform run', scope: 'project', severity: 'warn', run: checkInterruptedRun, hint: () => 'Review the last apply/destroy output before trusting applied state; the next run overwrites the marker.' },
|
|
35
35
|
{ id: 'oidc_trust_scope', label: 'OIDC trust scope', scope: 'project', severity: 'warn', run: checkOidcTrustScope, hint: () => 'Re-scope with: npx grada-run init --github-repo owner/name (or edit the sub claim in terraform/oidc.tf).' },
|
|
36
36
|
{ id: 'oidc_immutable_claims', label: 'OIDC trust formats', scope: 'project', severity: 'warn', run: checkOidcImmutableClaims, hint: () => 'Re-run npx grada-run init to upgrade the trust, or add a repo:<owner>@*/<name>@*:* entry to terraform/oidc.tf.' },
|
|
37
|
+
{ id: 'origin_restriction', label: 'ALB origin restriction', scope: 'project', severity: 'warn', run: checkOriginRestriction, hint: () => 'Re-run npx grada-run init to add the CloudFront origin-secret wiring, then apply.' },
|
|
37
38
|
];
|
|
38
39
|
|
|
39
40
|
const INSTALL_HINTS = {
|
|
@@ -207,6 +208,28 @@ function workspaceSuffix(lockKey) {
|
|
|
207
208
|
// by default): surfaces yellow without flipping the verdict red. List
|
|
208
209
|
// trusts flag when any entry is open; non-literal claims (var/ref)
|
|
209
210
|
// skip honestly as not parseable rather than as missing.
|
|
211
|
+
// Project check: the apply-time Direct URL only bypasses the CDN on
|
|
212
|
+
// trees predating the CloudFront origin-secret restriction (listener
|
|
213
|
+
// rule 403ing hits without the header). Warning-grade: the URL still
|
|
214
|
+
// prints, but on unwired trees it misleads. Non-ECS targets have no
|
|
215
|
+
// ALB ā skip.
|
|
216
|
+
function checkOriginRestriction({ cwd }) {
|
|
217
|
+
let mainTf;
|
|
218
|
+
try {
|
|
219
|
+
mainTf = fs.readFileSync(path.join(cwd, 'terraform', 'main.tf'), 'utf8');
|
|
220
|
+
} catch {
|
|
221
|
+
return { ok: true, skipped: 'no terraform/main.tf found' };
|
|
222
|
+
}
|
|
223
|
+
if (!mainTf.includes('aws_lb_listener')) {
|
|
224
|
+
return { ok: true, skipped: 'no ALB in this tree (non-ECS target)' };
|
|
225
|
+
}
|
|
226
|
+
if (mainTf.includes('X-Grada-Origin-Secret')) return { ok: true };
|
|
227
|
+
return {
|
|
228
|
+
ok: false,
|
|
229
|
+
detailLines: ['ALB accepts direct traffic (no CloudFront origin-secret restriction) ā the apply-time Direct URL bypasses the CDN on this tree.'],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
210
233
|
function checkOidcTrustScope({ cwd }) {
|
|
211
234
|
const trust = readTerraformOidcTrust(cwd);
|
|
212
235
|
if (trust === null) return { ok: true, skipped: 'no oidc.tf trust found' };
|
package/src/commands/secrets.js
CHANGED
|
@@ -348,6 +348,7 @@ async function handleSecretsCatch({
|
|
|
348
348
|
notFoundGuidance,
|
|
349
349
|
spinnerStopped = false,
|
|
350
350
|
stackTraceOnTypeError = false,
|
|
351
|
+
postVaultStep = null,
|
|
351
352
|
}) {
|
|
352
353
|
await trackFailure(event, {
|
|
353
354
|
projectName,
|
|
@@ -361,13 +362,25 @@ async function handleSecretsCatch({
|
|
|
361
362
|
for (const line of notFoundGuidance) console.log(line);
|
|
362
363
|
} else if (handleAuthErrorBranch(error, s, opts)) {
|
|
363
364
|
return;
|
|
364
|
-
}
|
|
365
|
+
}
|
|
366
|
+
// BUG-161: failures after the vault write (keys file, ECS restart)
|
|
367
|
+
// must report the vault as updated with the recovery step ā a bare
|
|
368
|
+
// "Failed to push" lies about what succeeded.
|
|
369
|
+
const postVaultHints = {
|
|
370
|
+
'secret_keys.json write': ' Re-run the push to regenerate terraform/secret_keys.json ā the vault already holds the new values.\n',
|
|
371
|
+
'ECS restart': ' Trigger the restart by hand (aws ecs update-service --force-new-deployment) or deploy ā the vault already holds the new values.\n',
|
|
372
|
+
};
|
|
373
|
+
const failureMessage = postVaultStep === null
|
|
374
|
+
? `ā Failed to ${verb} secrets: ${error.message}`
|
|
375
|
+
: `ā Vault updated, but the ${postVaultStep} failed: ${error.message}`;
|
|
376
|
+
const failureHint = postVaultStep === null ? null : (postVaultHints[postVaultStep] ?? null);
|
|
377
|
+
if (spinnerStopped) {
|
|
365
378
|
// The spinner already stopped, so its stop is a no-op ā
|
|
366
379
|
// route the message through the failure stamp instead.
|
|
367
|
-
return failCommand({ message:
|
|
368
|
-
} else {
|
|
369
|
-
s.stop(`ā Failed to ${verb} secrets: ${error.message}`);
|
|
380
|
+
return failCommand({ message: failureMessage, hint: failureHint, exitCode: 1 });
|
|
370
381
|
}
|
|
382
|
+
s.stop(failureMessage);
|
|
383
|
+
if (failureHint) console.log(color.dim(failureHint));
|
|
371
384
|
|
|
372
385
|
return failCommand({ exitCode: 1 });
|
|
373
386
|
}
|
|
@@ -450,6 +463,10 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
450
463
|
const s = spinner();
|
|
451
464
|
s.start(truncateSpinnerText(`Reading ${envFilePath} and pushing to AWS Secrets Manager...`));
|
|
452
465
|
|
|
466
|
+
// BUG-161: write progress for the catch below ā names the post-vault
|
|
467
|
+
// follow-up step when one fails, so the report says the vault is
|
|
468
|
+
// updated instead of misreporting a failed push.
|
|
469
|
+
let postVaultStep = null;
|
|
453
470
|
try {
|
|
454
471
|
// 1. Read and parse the local .env file
|
|
455
472
|
const envPath = path.resolve(process.cwd(), resolvedFilePath);
|
|
@@ -683,6 +700,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
683
700
|
keysUnchanged = false;
|
|
684
701
|
}
|
|
685
702
|
if (!keysUnchanged) {
|
|
703
|
+
postVaultStep = 'secret_keys.json write';
|
|
686
704
|
await atomicWriteFile(keysFilePath, nextKeysContent);
|
|
687
705
|
}
|
|
688
706
|
|
|
@@ -751,6 +769,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
751
769
|
const restartSpinner = spinner();
|
|
752
770
|
restartSpinner.start('Triggering rolling ECS restart...');
|
|
753
771
|
try {
|
|
772
|
+
postVaultStep = 'ECS restart';
|
|
754
773
|
await ecsClient.send(new UpdateServiceCommand({
|
|
755
774
|
cluster,
|
|
756
775
|
service,
|
|
@@ -797,6 +816,7 @@ async function pushSecretsInner(envFilePath, projectName, options = {}) {
|
|
|
797
816
|
s,
|
|
798
817
|
opts,
|
|
799
818
|
projectName: resolvedProjectName,
|
|
819
|
+
postVaultStep,
|
|
800
820
|
notFoundMessage: `ā Secrets Vault "${secretVaultId(resolvedProjectName)}" does not exist in AWS yet.`,
|
|
801
821
|
notFoundGuidance: [
|
|
802
822
|
`Run ${color.cyan('npx --yes grada-run apply')} first to provision the infrastructure and Secrets Manager vault.`,
|
|
@@ -849,8 +869,9 @@ async function pullSecretsMain(envFilePath, projectName, options = {}) {
|
|
|
849
869
|
const envPath = path.resolve(process.cwd(), resolvedFilePath);
|
|
850
870
|
let localSecrets = {};
|
|
851
871
|
let localExists = true;
|
|
872
|
+
let envContent = null;
|
|
852
873
|
try {
|
|
853
|
-
|
|
874
|
+
envContent = await fs.readFile(envPath, 'utf-8');
|
|
854
875
|
localSecrets = dotenv.parse(envContent);
|
|
855
876
|
} catch (fsError) {
|
|
856
877
|
if (fsError.code === 'ENOENT') {
|
|
@@ -896,13 +917,16 @@ async function pullSecretsMain(envFilePath, projectName, options = {}) {
|
|
|
896
917
|
...Object.keys(localSecrets),
|
|
897
918
|
...remoteKeys.filter((k) => !Object.hasOwn(localSecrets, k)),
|
|
898
919
|
];
|
|
899
|
-
//
|
|
900
|
-
//
|
|
920
|
+
// The merge appends remote-only keys (reviving local deletions)
|
|
921
|
+
// ā name what came back instead of syncing silently.
|
|
901
922
|
const appended = localExists ? remoteKeys.filter((k) => !Object.hasOwn(localSecrets, k)) : [];
|
|
902
923
|
if (appended.length > 0) {
|
|
903
924
|
console.log(color.yellow(`ā ļø Pulled ${appended.length} key${appended.length === 1 ? '' : 's'} not present locally (revived deletions?): ${appended.join(', ')}`));
|
|
904
925
|
}
|
|
905
|
-
|
|
926
|
+
// Only keys being added/overwritten can block the write: a
|
|
927
|
+
// local-only exotic value must not abort an unrelated sync.
|
|
928
|
+
const writtenKeys = remoteKeys.filter((key) => !Object.hasOwn(localSecrets, key) || overwrite);
|
|
929
|
+
const unrepresentable = writtenKeys.filter((key) =>
|
|
906
930
|
key === '__proto__' || quoteEnvValue(merged[key]) === null
|
|
907
931
|
);
|
|
908
932
|
if (unrepresentable.length > 0) {
|
|
@@ -914,7 +938,18 @@ async function pullSecretsMain(envFilePath, projectName, options = {}) {
|
|
|
914
938
|
abort.code = 'SECRETS_PULL_UNREPRESENTABLE_VALUE';
|
|
915
939
|
throw abort;
|
|
916
940
|
}
|
|
917
|
-
|
|
941
|
+
// Skip the write when the merge changes nothing semantically.
|
|
942
|
+
// Byte comparison always differs on commented files
|
|
943
|
+
// (serializeEnv emits canonical lines), so compare parsed
|
|
944
|
+
// content instead: same keys + same values means the file ā
|
|
945
|
+
// comments and all ā already holds exactly this state.
|
|
946
|
+
const localKeys = Object.keys(localSecrets);
|
|
947
|
+
const semanticallyEqual = localExists
|
|
948
|
+
&& localKeys.length === orderedKeys.length
|
|
949
|
+
&& orderedKeys.every((key) => Object.hasOwn(localSecrets, key) && String(localSecrets[key]) === String(merged[key]));
|
|
950
|
+
if (!semanticallyEqual) {
|
|
951
|
+
await fs.writeFile(envPath, serializeEnv(orderedKeys, merged));
|
|
952
|
+
}
|
|
918
953
|
|
|
919
954
|
outro(`Successfully synced ${remoteKeys.length} secrets to ${resolvedFilePath}`);
|
|
920
955
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# --- Stage 1: Build dependencies into an isolated venv ---
|
|
2
|
-
FROM python:3.12-alpine AS builder
|
|
2
|
+
FROM python:3.12-alpine@sha256:e6dae589c1c05976188fd3bd019afd091445fc533ed2ea29001beddc7368a9c8 AS builder
|
|
3
3
|
|
|
4
4
|
# Prevent Python from writing .pyc files and buffer stdout for cleaner logs
|
|
5
5
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
@@ -22,7 +22,7 @@ RUN python -m venv /opt/venv && \
|
|
|
22
22
|
rm -rf /root/.cache/pip
|
|
23
23
|
|
|
24
24
|
# --- Stage 2: Production runner (no build tools, no pip) ---
|
|
25
|
-
FROM python:3.12-alpine AS runner
|
|
25
|
+
FROM python:3.12-alpine@sha256:e6dae589c1c05976188fd3bd019afd091445fc533ed2ea29001beddc7368a9c8 AS runner
|
|
26
26
|
|
|
27
27
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
28
28
|
ENV PYTHONUNBUFFERED=1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Stage 1: Compile
|
|
2
|
-
FROM golang:1.26-alpine AS builder
|
|
2
|
+
FROM golang:1.26-alpine@sha256:a2012b4a1d1f9f7e9f44e0d39b805a901e856b1dd80b4e6ee4338db547050308 AS builder
|
|
3
3
|
WORKDIR /app
|
|
4
4
|
COPY go.mod go.sum* ./
|
|
5
5
|
RUN go mod download
|
|
@@ -7,7 +7,7 @@ COPY . .
|
|
|
7
7
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /main .
|
|
8
8
|
|
|
9
9
|
# Stage 2: Production runner
|
|
10
|
-
FROM alpine:3.20
|
|
10
|
+
FROM alpine:3.20@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc
|
|
11
11
|
WORKDIR /app
|
|
12
12
|
|
|
13
13
|
# Create unprivileged user
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# --- Stage 1: Build dependencies into an isolated venv ---
|
|
2
|
-
FROM python:3.12-alpine AS builder
|
|
2
|
+
FROM python:3.12-alpine@sha256:e6dae589c1c05976188fd3bd019afd091445fc533ed2ea29001beddc7368a9c8 AS builder
|
|
3
3
|
|
|
4
4
|
# Prevent Python from writing .pyc files and buffer stdout for cleaner logs
|
|
5
5
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
@@ -22,7 +22,7 @@ RUN python -m venv /opt/venv && \
|
|
|
22
22
|
rm -rf /root/.cache/pip
|
|
23
23
|
|
|
24
24
|
# --- Stage 2: Production runner (no build tools, no pip) ---
|
|
25
|
-
FROM python:3.12-alpine AS runner
|
|
25
|
+
FROM python:3.12-alpine@sha256:e6dae589c1c05976188fd3bd019afd091445fc533ed2ea29001beddc7368a9c8 AS runner
|
|
26
26
|
|
|
27
27
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
28
28
|
ENV PYTHONUNBUFFERED=1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Stage 1: Build the Rails application
|
|
2
|
-
FROM ruby:3.3.5-alpine AS builder
|
|
2
|
+
FROM ruby:3.3.5-alpine@sha256:b4c321a99b9f21b7bb24f22e558bf1477630fb55d692aba4e25b2fe5deb7eaf1 AS builder
|
|
3
3
|
WORKDIR /app
|
|
4
4
|
|
|
5
5
|
# Install native build tools required to compile C extensions (like pg or nokogiri)
|
|
@@ -21,7 +21,7 @@ COPY . .
|
|
|
21
21
|
RUN SECRET_KEY_BASE=dummy bundle exec rails assets:precompile || true
|
|
22
22
|
|
|
23
23
|
# Stage 2: Production runner
|
|
24
|
-
FROM ruby:3.3.5-alpine AS runner
|
|
24
|
+
FROM ruby:3.3.5-alpine@sha256:b4c321a99b9f21b7bb24f22e558bf1477630fb55d692aba4e25b2fe5deb7eaf1 AS runner
|
|
25
25
|
WORKDIR /app
|
|
26
26
|
|
|
27
27
|
ENV RAILS_ENV=production \
|
|
@@ -11,7 +11,7 @@ COPY . .
|
|
|
11
11
|
RUN npm run build
|
|
12
12
|
|
|
13
13
|
# STAGE 2: Serve with Hardened Nginx
|
|
14
|
-
FROM nginxinc/nginx-unprivileged:alpine
|
|
14
|
+
FROM nginxinc/nginx-unprivileged:alpine@sha256:b5047b9b76845eac124358373c6852377c52e4b05834a47647e955dd91cb8f1e
|
|
15
15
|
USER root
|
|
16
16
|
RUN apk upgrade --no-cache
|
|
17
17
|
USER nginx
|
|
@@ -54,7 +54,24 @@ jobs:
|
|
|
54
54
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
55
55
|
fi
|
|
56
56
|
|
|
57
|
-
# --- 2.
|
|
57
|
+
# --- 2. AWS AUTH (job-level credentials for every step below) ---
|
|
58
|
+
- name: Configure AWS credentials
|
|
59
|
+
id: aws-creds
|
|
60
|
+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4
|
|
61
|
+
continue-on-error: true
|
|
62
|
+
with:
|
|
63
|
+
role-to-assume: arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role
|
|
64
|
+
aws-region: ${{ env.AWS_REGION }}
|
|
65
|
+
|
|
66
|
+
# Deploy never skips: a failed assume fails the run with the
|
|
67
|
+
# bootstrap pointer (BUG-201).
|
|
68
|
+
- name: Interpret credential failure
|
|
69
|
+
if: steps.aws-creds.outcome == 'failure'
|
|
70
|
+
run: |
|
|
71
|
+
echo "::error::AWS credential assumption failed ā if the stack was never provisioned, bootstrap it first (npx grada-run apply); otherwise check terraform/oidc.tf trust."
|
|
72
|
+
exit 1
|
|
73
|
+
|
|
74
|
+
# --- 3. INFRASTRUCTURE SYNC (The New Marketplace Action) ---
|
|
58
75
|
- name: Apply Infrastructure Changes
|
|
59
76
|
uses: grada-run/grada-action@12227808ae4caafaec1041319645586a1132fc57 # v1
|
|
60
77
|
with:
|
|
@@ -62,7 +79,7 @@ jobs:
|
|
|
62
79
|
role-to-assume: arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role
|
|
63
80
|
terraform-dir: 'terraform'
|
|
64
81
|
|
|
65
|
-
# ---
|
|
82
|
+
# --- 4. BUILD ---
|
|
66
83
|
- name: Setup Node.js
|
|
67
84
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
|
68
85
|
with:
|
|
@@ -74,7 +91,7 @@ jobs:
|
|
|
74
91
|
npm ci
|
|
75
92
|
npm run build
|
|
76
93
|
|
|
77
|
-
# ---
|
|
94
|
+
# --- 5. DEPLOY ---
|
|
78
95
|
- name: Sync to S3
|
|
79
96
|
run: |
|
|
80
97
|
aws s3 sync "${{ env.BUILD_DIR }}/" "s3://${{ env.S3_BUCKET }}" --delete \
|
|
@@ -31,21 +31,15 @@ jobs:
|
|
|
31
31
|
role-to-assume: {{ROLE_ARN}}
|
|
32
32
|
aws-region: ${{ env.AWS_REGION }}
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
34
|
+
# STS denies a missing role and a trust mismatch with the same
|
|
35
|
+
# message, so the API won't support distinguishing them: every
|
|
36
|
+
# assume failure skips loud (green) with both cases + pointers
|
|
37
|
+
# named (BUG-199).
|
|
37
38
|
- name: Interpret credential failure
|
|
38
39
|
if: steps.aws-creds.outcome == 'failure'
|
|
39
40
|
run: |
|
|
40
41
|
ROLE_ARN="{{ROLE_ARN}}"
|
|
41
|
-
|
|
42
|
-
ERR="$(aws sts assume-role-with-web-identity --role-arn "$ROLE_ARN" --role-session-name grada-preflight --web-identity-token "$TOKEN" 2>&1)" || true
|
|
43
|
-
if echo "$ERR" | grep -qiE 'NoSuchEntity|does not exist|cannot be found'; then
|
|
44
|
-
echo "::notice::AWS role $ROLE_ARN does not exist ā the stack was likely never provisioned or was destroyed. Skipping this run (re-bootstrap with: npx grada-run apply)."
|
|
45
|
-
else
|
|
46
|
-
echo "::error::AWS credential assumption failed. Either the role is missing (stack absent ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf). Raw error: $ERR"
|
|
47
|
-
exit 1
|
|
48
|
-
fi
|
|
42
|
+
echo "::notice::AWS credential assumption failed for $ROLE_ARN ā skipping this run. Either the stack is absent (never provisioned or destroyed ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf)."
|
|
49
43
|
|
|
50
44
|
- name: Setup Terraform
|
|
51
45
|
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
|
|
@@ -55,21 +55,15 @@ jobs:
|
|
|
55
55
|
role-to-assume: arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role
|
|
56
56
|
aws-region: ${{ env.AWS_REGION }}
|
|
57
57
|
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
#
|
|
58
|
+
# STS denies a missing role and a trust mismatch with the same
|
|
59
|
+
# message, so the API won't support distinguishing them: every
|
|
60
|
+
# assume failure skips loud (green) with both cases + pointers
|
|
61
|
+
# named (BUG-199).
|
|
61
62
|
- name: Interpret credential failure
|
|
62
63
|
if: steps.aws-creds.outcome == 'failure'
|
|
63
64
|
run: |
|
|
64
65
|
ROLE_ARN="arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role"
|
|
65
|
-
|
|
66
|
-
ERR="$(aws sts assume-role-with-web-identity --role-arn "$ROLE_ARN" --role-session-name grada-preflight --web-identity-token "$TOKEN" 2>&1)" || true
|
|
67
|
-
if echo "$ERR" | grep -qiE 'NoSuchEntity|does not exist|cannot be found'; then
|
|
68
|
-
echo "::notice::AWS role $ROLE_ARN does not exist ā the stack was likely never provisioned or was destroyed. Skipping this run (re-bootstrap with: npx grada-run apply)."
|
|
69
|
-
else
|
|
70
|
-
echo "::error::AWS credential assumption failed. Either the role is missing (stack absent ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf). Raw error: $ERR"
|
|
71
|
-
exit 1
|
|
72
|
-
fi
|
|
66
|
+
echo "::notice::AWS credential assumption failed for $ROLE_ARN ā skipping this run. Either the stack is absent (never provisioned or destroyed ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf)."
|
|
73
67
|
|
|
74
68
|
- name: Login to Amazon ECR
|
|
75
69
|
if: steps.aws-creds.outcome == 'success'
|
|
@@ -55,21 +55,15 @@ jobs:
|
|
|
55
55
|
role-to-assume: arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role
|
|
56
56
|
aws-region: ${{ env.AWS_REGION }}
|
|
57
57
|
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
#
|
|
58
|
+
# STS denies a missing role and a trust mismatch with the same
|
|
59
|
+
# message, so the API won't support distinguishing them: every
|
|
60
|
+
# assume failure skips loud (green) with both cases + pointers
|
|
61
|
+
# named (BUG-199).
|
|
61
62
|
- name: Interpret credential failure
|
|
62
63
|
if: steps.aws-creds.outcome == 'failure'
|
|
63
64
|
run: |
|
|
64
65
|
ROLE_ARN="arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role"
|
|
65
|
-
|
|
66
|
-
ERR="$(aws sts assume-role-with-web-identity --role-arn "$ROLE_ARN" --role-session-name grada-preflight --web-identity-token "$TOKEN" 2>&1)" || true
|
|
67
|
-
if echo "$ERR" | grep -qiE 'NoSuchEntity|does not exist|cannot be found'; then
|
|
68
|
-
echo "::notice::AWS role $ROLE_ARN does not exist ā the stack was likely never provisioned or was destroyed. Skipping this run (re-bootstrap with: npx grada-run apply)."
|
|
69
|
-
else
|
|
70
|
-
echo "::error::AWS credential assumption failed. Either the role is missing (stack absent ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf). Raw error: $ERR"
|
|
71
|
-
exit 1
|
|
72
|
-
fi
|
|
66
|
+
echo "::notice::AWS credential assumption failed for $ROLE_ARN ā skipping this run. Either the stack is absent (never provisioned or destroyed ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf)."
|
|
73
67
|
|
|
74
68
|
- name: Login to Amazon ECR
|
|
75
69
|
if: steps.aws-creds.outcome == 'success'
|
|
@@ -49,21 +49,15 @@ jobs:
|
|
|
49
49
|
role-to-assume: arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role
|
|
50
50
|
aws-region: ${{ env.AWS_REGION }}
|
|
51
51
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
52
|
+
# STS denies a missing role and a trust mismatch with the same
|
|
53
|
+
# message, so the API won't support distinguishing them: every
|
|
54
|
+
# assume failure skips loud (green) with both cases + pointers
|
|
55
|
+
# named (BUG-199).
|
|
55
56
|
- name: Interpret credential failure
|
|
56
57
|
if: steps.aws-creds.outcome == 'failure'
|
|
57
58
|
run: |
|
|
58
59
|
ROLE_ARN="arn:aws:iam::{{AWS_ACCOUNT_ID}}:role/{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-github-actions-role"
|
|
59
|
-
|
|
60
|
-
ERR="$(aws sts assume-role-with-web-identity --role-arn "$ROLE_ARN" --role-session-name grada-preflight --web-identity-token "$TOKEN" 2>&1)" || true
|
|
61
|
-
if echo "$ERR" | grep -qiE 'NoSuchEntity|does not exist|cannot be found'; then
|
|
62
|
-
echo "::notice::AWS role $ROLE_ARN does not exist ā the stack was likely never provisioned or was destroyed. Skipping this run (re-bootstrap with: npx grada-run apply)."
|
|
63
|
-
else
|
|
64
|
-
echo "::error::AWS credential assumption failed. Either the role is missing (stack absent ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf). Raw error: $ERR"
|
|
65
|
-
exit 1
|
|
66
|
-
fi
|
|
60
|
+
echo "::notice::AWS credential assumption failed for $ROLE_ARN ā skipping this run. Either the stack is absent (never provisioned or destroyed ā re-bootstrap with: npx grada-run apply) or the OIDC trust does not cover this run (check terraform/oidc.tf)."
|
|
67
61
|
|
|
68
62
|
- name: Setup Terraform
|
|
69
63
|
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
|
|
@@ -86,10 +86,12 @@ resource "aws_cloudfront_origin_access_control" "storage_oac" {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
# trivy:ignore:AVD-AWS-0011 - WAF is omitted by default to prevent unexpected monthly costs for users
|
|
89
|
-
# Access logging is intentionally disabled
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
89
|
+
# Access logging is intentionally disabled: at starter scale these logs go
|
|
90
|
+
# unread (CloudWatch metrics cover ops), while a log bucket adds a delivery
|
|
91
|
+
# policy + lifecycle + review surface. Enable logging_config to a dedicated
|
|
92
|
+
# bucket if compliance needs it. Restrict price_class to PriceClass_100/200
|
|
93
|
+
# as well if most traffic is US/EU ā edge coverage shrinks but so does the
|
|
94
|
+
# transfer bill.
|
|
93
95
|
resource "aws_cloudfront_distribution" "storage_cdn" {
|
|
94
96
|
enabled = true
|
|
95
97
|
is_ipv6_enabled = true
|
|
@@ -40,6 +40,12 @@ resource "aws_rds_cluster" "postgres" {
|
|
|
40
40
|
skip_final_snapshot = true
|
|
41
41
|
storage_encrypted = true
|
|
42
42
|
|
|
43
|
+
# Match the instance engines: 7-day retention with explicit off-peak
|
|
44
|
+
# UTC windows instead of AWS-assigned ones (BUG-203).
|
|
45
|
+
backup_retention_period = 7
|
|
46
|
+
preferred_backup_window = "03:00-04:00"
|
|
47
|
+
preferred_maintenance_window = "sun:04:00-sun:05:00"
|
|
48
|
+
|
|
43
49
|
# grada destroy lifts this only via --allow-data-loss (or a per-run
|
|
44
50
|
# data-loss confirm); grada snapshots the database first unless the
|
|
45
51
|
# flag says the data may go. grada destroy also pre-wakes stopped
|
|
@@ -30,7 +30,11 @@ resource "aws_db_instance" "postgres" {
|
|
|
30
30
|
# grow the volume (and the bill) without bound.
|
|
31
31
|
max_allocated_storage = 200
|
|
32
32
|
backup_retention_period = 7
|
|
33
|
-
|
|
33
|
+
# Explicit off-peak UTC windows: without them AWS assigns windows
|
|
34
|
+
# that can land in peak hours (and drift between stacks).
|
|
35
|
+
backup_window = "03:00-04:00"
|
|
36
|
+
maintenance_window = "sun:04:00-sun:05:00"
|
|
37
|
+
storage_encrypted = true
|
|
34
38
|
|
|
35
39
|
# Strip dashes for the database name: RDS MySQL db_name must begin with a
|
|
36
40
|
# letter and contain only alphanumeric characters (e.g. my-project -> myproject)
|
|
@@ -30,7 +30,11 @@ resource "aws_db_instance" "postgres" {
|
|
|
30
30
|
# grow the volume (and the bill) without bound.
|
|
31
31
|
max_allocated_storage = 200
|
|
32
32
|
backup_retention_period = 7
|
|
33
|
-
|
|
33
|
+
# Explicit off-peak UTC windows: without them AWS assigns windows
|
|
34
|
+
# that can land in peak hours (and drift between stacks).
|
|
35
|
+
backup_window = "03:00-04:00"
|
|
36
|
+
maintenance_window = "sun:04:00-sun:05:00"
|
|
37
|
+
storage_encrypted = true
|
|
34
38
|
|
|
35
39
|
# Clean up dashes for the database name (e.g. my-project -> my_project)
|
|
36
40
|
db_name = replace(local.app_name, "-", "_")
|