grada-run 0.43.0 → 0.43.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grada-run",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "description": "Provision production-ready AWS infrastructure and CI/CD pipelines in seconds.",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -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
- if (albUrl) finalMessage += `\n 🚦 Direct URL: ${color.gray(albUrl)} ${color.dim('(bypasses the CDN — for debugging)')}`;
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) {
@@ -532,12 +532,16 @@ async function runDbMigrateMain(input = {}) {
532
532
  return { ok: true, success: true, exitCode: 0, taskArn: outcome.taskArn };
533
533
  }
534
534
  const propagated = (typeof exitCode === 'number' && exitCode > 0) ? exitCode : 1;
535
+ // The ECS stopped reason is the only diagnosis PostHog gets for a
536
+ // failed task (exit codes alone can't distinguish image-pull from
537
+ // command-not-found from migration errors) — stamp it.
538
+ const failureDetail = `Migration failed with exit code ${exitCode ?? 'unknown'}: ${stoppedReason}`;
535
539
  return failCommand({
536
- message: `\nāœ– Migration failed with exit code ${exitCode ?? 'unknown'}: ${stoppedReason}.\n`,
540
+ message: `\nāœ– ${failureDetail}.\n`,
537
541
  event: 'db_migrate_run',
538
542
  telemetry: { projectName, cmd_source: cmdSource, ci_setup: false },
539
543
  errorCode: 'MIGRATION_TASK_FAILED',
540
- extra: { exit_code: exitCode ?? -1 },
544
+ extra: { exit_code: exitCode ?? -1, error_message: failureDetail },
541
545
  reason: 'migration-task-failed',
542
546
  resultExtra: { cluster, service, region, taskArn: outcome.taskArn },
543
547
  exitCode: propagated,
@@ -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' };
@@ -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
- } else if (spinnerStopped) {
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: `āŒ Failed to ${verb} secrets: ${error.message}`, exitCode: 1 });
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
- const envContent = await fs.readFile(envPath, 'utf-8');
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
- // BUG-161: the merge appends remote-only keys (reviving local
900
- // deletions) — name what came back instead of syncing silently.
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
- const unrepresentable = orderedKeys.filter((key) =>
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,12 @@ async function pullSecretsMain(envFilePath, projectName, options = {}) {
914
938
  abort.code = 'SECRETS_PULL_UNREPRESENTABLE_VALUE';
915
939
  throw abort;
916
940
  }
917
- await fs.writeFile(envPath, serializeEnv(orderedKeys, merged));
941
+ // Skip the write when the file is already byte-identical so
942
+ // in-sync pulls don't strip comments/formatting for no reason.
943
+ const nextEnvContent = serializeEnv(orderedKeys, merged);
944
+ if (!localExists || envContent !== nextEnvContent) {
945
+ await fs.writeFile(envPath, nextEnvContent);
946
+ }
918
947
 
919
948
  outro(`Successfully synced ${remoteKeys.length} secrets to ${resolvedFilePath}`);
920
949
 
@@ -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. INFRASTRUCTURE SYNC (The New Marketplace Action) ---
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
- # --- 3. BUILD ---
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
- # --- 4. DEPLOY ---
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
- # A missing role means the stack is absent (never provisioned or
35
- # destroyed): skip loud instead of bursting red assume noise. Any
36
- # other assume failure fails loud with both cases named (BUG-138).
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
- TOKEN="$(curl -fsSL -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=sts.amazonaws.com" | jq -r '.value')"
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
- # A missing role means the stack is absent (never provisioned or
59
- # destroyed): skip loud instead of bursting red assume noise. Any
60
- # other assume failure fails loud with both cases named (BUG-138).
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
- TOKEN="$(curl -fsSL -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=sts.amazonaws.com" | jq -r '.value')"
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
- # A missing role means the stack is absent (never provisioned or
59
- # destroyed): skip loud instead of bursting red assume noise. Any
60
- # other assume failure fails loud with both cases named (BUG-138).
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
- TOKEN="$(curl -fsSL -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=sts.amazonaws.com" | jq -r '.value')"
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
- # A missing role means the stack is absent (never provisioned or
53
- # destroyed): skip loud instead of bursting red assume noise. Any
54
- # other assume failure fails loud with both cases named (BUG-138).
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
- TOKEN="$(curl -fsSL -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=sts.amazonaws.com" | jq -r '.value')"
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 (no logging_config): it doubles
90
- # request costs into a second bucket. Restrict price_class to
91
- # PriceClass_100/200 as well if most traffic is US/EU — edge coverage
92
- # shrinks but so does the transfer bill.
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
@@ -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
- storage_encrypted = true
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
- storage_encrypted = true
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, "-", "_")