grada-run 0.49.3 → 0.49.5
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/add.js +1 -1
- package/src/commands/alerts.js +1 -1
- package/src/commands/apply.js +2 -2
- package/src/commands/db/backup.js +3 -3
- package/src/commands/db/connect.js +2 -2
- package/src/commands/db/enable-vector.js +1 -1
- package/src/commands/db/import.js +2 -2
- package/src/commands/db/migrate.js +7 -6
- package/src/commands/destroy.js +6 -6
- package/src/commands/diagnose.js +1 -1
- package/src/commands/domain.js +2 -2
- package/src/commands/exec.js +1 -1
- package/src/commands/gc.js +2 -2
- package/src/commands/init.js +7 -7
- package/src/commands/logs.js +3 -3
- package/src/commands/rollback.js +4 -4
- package/src/commands/secrets.js +18 -18
- package/src/commands/status.js +3 -3
- package/src/commands/wake.js +2 -2
- package/src/utils/addons.js +1 -1
- package/src/utils/backup.js +1 -1
- package/src/utils/ecs-runner.js +3 -3
- package/src/utils/generator.js +3 -3
- package/src/utils/prompts.js +1 -1
- package/src/utils/resolvers.js +8 -10
- package/src/utils/terraform.js +1 -1
- package/templates/github/deploy-lambda.yml +2 -2
- package/templates/github/deploy-static.yml +1 -1
- package/templates/github/deploy.yml +2 -2
- package/templates/github/drift.yml +1 -1
- package/templates/github/plan.yml +2 -2
- package/templates/github/preview-lambda.yml +4 -4
- package/templates/github/preview.yml +4 -4
- package/templates/github/teardown.yml +3 -3
- package/templates/terraform/addons/bedrock.tf +1 -1
- package/templates/terraform/backend.tf +1 -1
- package/templates/terraform/cloudfront-lambda.tf +2 -2
- package/templates/terraform/cloudfront.tf +3 -3
- package/templates/terraform/database-aurora-postgresql.tf +1 -1
- package/templates/terraform/main.tf +3 -3
- package/templates/terraform/oidc.tf +62 -40
- package/templates/terraform/secrets.tf +1 -1
package/src/utils/ecs-runner.js
CHANGED
|
@@ -311,7 +311,7 @@ export async function runEphemeralEcsTask({
|
|
|
311
311
|
// Sniffs the URL scheme from discrete credentials. Explicit values win;
|
|
312
312
|
// when DB_ENGINE/DB_PORT are secrets-sourced (valueFrom, values unknown
|
|
313
313
|
// to the CLI) the reference text is sniffed for engine/port hints
|
|
314
|
-
// instead
|
|
314
|
+
// instead. Indeterminate stays postgresql (back-compat).
|
|
315
315
|
function sniffRunnerScheme(entries, values) {
|
|
316
316
|
const engine = values.get('DB_ENGINE');
|
|
317
317
|
if (typeof engine === 'string' && engine !== '') {
|
|
@@ -326,7 +326,7 @@ function sniffRunnerScheme(entries, values) {
|
|
|
326
326
|
return 'postgresql';
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
// Runtime userinfo encoder for the synthesized URL
|
|
329
|
+
// Runtime userinfo encoder for the synthesized URL: node sees
|
|
330
330
|
// only shell references, never the values, so the encoding ladder ships
|
|
331
331
|
// inside the script — node (encodeURIComponent) → sed (the URL-breaking
|
|
332
332
|
// subset: %, ?, #, @, :, /) → warned raw. Quoting alone cannot save a
|
|
@@ -510,7 +510,7 @@ export async function reportRunnerOutcome({
|
|
|
510
510
|
if (exitCode === 0) {
|
|
511
511
|
// Owner pairs its own start/stop: the runner usually stops
|
|
512
512
|
// first (idempotent no-op then), but success must never
|
|
513
|
-
// depend on a callee for the spinner lifecycle
|
|
513
|
+
// depend on a callee for the spinner lifecycle.
|
|
514
514
|
try { s.stop(color.green(`${label} succeeded.`)); } catch { /* already stopped */ }
|
|
515
515
|
console.log(color.green(`\n✅ ${label} succeeded.`));
|
|
516
516
|
await trackSuccess(event, { ...telemetry });
|
package/src/utils/generator.js
CHANGED
|
@@ -17,7 +17,7 @@ const __dirname = path.dirname(__filename);
|
|
|
17
17
|
// name stays a writable candidate so pre-rebrand docs keep updating.
|
|
18
18
|
export const MANAGED_DOC_FALLBACK = 'GRADA.md';
|
|
19
19
|
export const LEGACY_MANAGED_DOC_FALLBACK = 'DEPLOY-STACK.md';
|
|
20
|
-
// Greppable, boot-failing Rails master-key seed
|
|
20
|
+
// Greppable, boot-failing Rails master-key seed: Rails cannot
|
|
21
21
|
// boot on it, so a tree that never pushes the real key fails closed.
|
|
22
22
|
export const RAILS_MASTER_KEY_PLACEHOLDER = 'REPLACE_ME_PUSH_REAL_RAILS_MASTER_KEY';
|
|
23
23
|
|
|
@@ -505,7 +505,7 @@ export async function generateTemplates(targetDir, config) {
|
|
|
505
505
|
// Build the initial HCL map for AWS Secrets Manager
|
|
506
506
|
let initialSecretMap = `{\n EXAMPLE_API_KEY = "replace_me_in_aws_console"`;
|
|
507
507
|
|
|
508
|
-
// 4.1. Seed a placeholder for the Rails master key
|
|
508
|
+
// 4.1. Seed a placeholder for the Rails master key: the
|
|
509
509
|
// live key must never render into committed .tf (or linger in
|
|
510
510
|
// state), and no constant dummy may boot prod. The placeholder is
|
|
511
511
|
// greppable and boot-failing; the loud instruction tells the
|
|
@@ -587,7 +587,7 @@ resource "aws_lb_listener_rule" "vercel_redirect_${index}" {
|
|
|
587
587
|
|
|
588
588
|
// Inject variables. Replacement FUNCTION (not string): `$&`/`$'`/
|
|
589
589
|
// `$$` in values (Procfile commands, compose env vars) must land
|
|
590
|
-
// byte-identical, not interpolate match text
|
|
590
|
+
// byte-identical, not interpolate match text.
|
|
591
591
|
for (const [key, value] of Object.entries(config)) {
|
|
592
592
|
const literal = String(value ?? '');
|
|
593
593
|
content = content.replace(new RegExp(`{{${key}}}`, 'g'), () => literal);
|
package/src/utils/prompts.js
CHANGED
|
@@ -90,7 +90,7 @@ export async function getProjectConfig(isHeadless, headlessOptions, targetDir, d
|
|
|
90
90
|
const skipsContainerSizing = hints && typeof hints === 'object'
|
|
91
91
|
&& (hints.target === 'lambda' || hints.target === 'static');
|
|
92
92
|
if (isHeadless) {
|
|
93
|
-
//
|
|
93
|
+
// An undetectable framework with a package.json present is
|
|
94
94
|
// a plain-Node project, not a static site — defaulting to 'static'
|
|
95
95
|
// renders an nginx Dockerfile that can neither build scriptless
|
|
96
96
|
// projects nor run node payloads. No package.json keeps 'static'.
|
package/src/utils/resolvers.js
CHANGED
|
@@ -46,17 +46,15 @@ export function readTerraformComputeTarget(cwd = process.cwd()) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Offline database-kind detection for `--setup-ci` (no AWS calls): the
|
|
49
|
-
// generator
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
49
|
+
// generator and `add` always render to database.tf regardless of engine,
|
|
50
|
+
// so the kind comes from the rendered content — an aurora tree declares
|
|
51
|
+
// an rds cluster. Unknown/absent means instance — the runtime backup
|
|
52
|
+
// resolves the live kind anyway; the id prefix only name-scopes the
|
|
53
|
+
// snapshot for guardrails + gc.
|
|
53
54
|
export function readTerraformDbKind(cwd = process.cwd()) {
|
|
54
55
|
const base = resolveCwd({}, cwd);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} catch {
|
|
58
|
-
// Fall through to the instance default
|
|
59
|
-
}
|
|
56
|
+
const databaseTf = readFileSafe(path.join(base, 'terraform', 'database.tf'));
|
|
57
|
+
if (typeof databaseTf === 'string' && databaseTf.includes('resource "aws_rds_cluster"')) return 'cluster';
|
|
60
58
|
return 'instance';
|
|
61
59
|
}
|
|
62
60
|
|
|
@@ -210,7 +208,7 @@ function scanBracketBlock(content, openIdx) {
|
|
|
210
208
|
// reference, so it never matches; the shape filter drops resource names
|
|
211
209
|
// (`${...}`, hyphens, paths). Sorted, deduplicated, [] when unreadable.
|
|
212
210
|
//
|
|
213
|
-
// Scoped to secret-receiving containers
|
|
211
|
+
// Scoped to secret-receiving containers: ECS collides secrets
|
|
214
212
|
// with environment per container definition, so sidecar `environment`
|
|
215
213
|
// arrays (whose containers get no secrets) must not contribute names —
|
|
216
214
|
// parsing them would falsely render same-named secrets undeployable.
|
package/src/utils/terraform.js
CHANGED
|
@@ -218,7 +218,7 @@ export function runTerraformCommand(args, cwd, spin, loadingPrefix, options = {}
|
|
|
218
218
|
if (timer && typeof timer.unref === 'function') timer.unref();
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
//
|
|
221
|
+
// Pipe chunks split lines at arbitrary byte offsets, so
|
|
222
222
|
// each chunk's trailing fragment is carried over and only
|
|
223
223
|
// newline-terminated lines are delivered. Splitting per chunk
|
|
224
224
|
// injects newlines into giant single-line JSON (show -json),
|
|
@@ -64,7 +64,7 @@ jobs:
|
|
|
64
64
|
aws-region: ${{ env.AWS_REGION }}
|
|
65
65
|
|
|
66
66
|
# Deploy never skips: a failed assume fails the run with the
|
|
67
|
-
# bootstrap pointer
|
|
67
|
+
# bootstrap pointer.
|
|
68
68
|
- name: Interpret credential failure
|
|
69
69
|
if: steps.aws-creds.outcome == 'failure'
|
|
70
70
|
run: |
|
|
@@ -179,7 +179,7 @@ jobs:
|
|
|
179
179
|
|
|
180
180
|
# A cancelled apply/destroy can strand the S3 state lockfile: point
|
|
181
181
|
# at recovery instead of leaving the next run to fail obscurely
|
|
182
|
-
|
|
182
|
+
#. Generic by necessity — the lock ID only exists in the
|
|
183
183
|
# follow-up run's own error.
|
|
184
184
|
- name: Cancellation recovery note
|
|
185
185
|
if: cancelled()
|
|
@@ -64,7 +64,7 @@ jobs:
|
|
|
64
64
|
aws-region: ${{ env.AWS_REGION }}
|
|
65
65
|
|
|
66
66
|
# Deploy never skips: a failed assume fails the run with the
|
|
67
|
-
# bootstrap pointer
|
|
67
|
+
# bootstrap pointer.
|
|
68
68
|
- name: Interpret credential failure
|
|
69
69
|
if: steps.aws-creds.outcome == 'failure'
|
|
70
70
|
run: |
|
|
@@ -68,7 +68,7 @@ jobs:
|
|
|
68
68
|
aws-region: ${{ env.AWS_REGION }}
|
|
69
69
|
|
|
70
70
|
# Deploy never skips: a failed assume fails the run with the
|
|
71
|
-
# bootstrap pointer
|
|
71
|
+
# bootstrap pointer.
|
|
72
72
|
- name: Interpret credential failure
|
|
73
73
|
if: steps.aws-creds.outcome == 'failure'
|
|
74
74
|
run: |
|
|
@@ -272,7 +272,7 @@ jobs:
|
|
|
272
272
|
|
|
273
273
|
# A cancelled apply/destroy can strand the S3 state lockfile: point
|
|
274
274
|
# at recovery instead of leaving the next run to fail obscurely
|
|
275
|
-
|
|
275
|
+
#. Generic by necessity — the lock ID only exists in the
|
|
276
276
|
# follow-up run's own error.
|
|
277
277
|
- name: Cancellation recovery note
|
|
278
278
|
if: cancelled()
|
|
@@ -34,7 +34,7 @@ jobs:
|
|
|
34
34
|
# STS denies a missing role and a trust mismatch with the same
|
|
35
35
|
# message, so the API won't support distinguishing them: every
|
|
36
36
|
# assume failure skips loud (green) with both cases + pointers
|
|
37
|
-
# named
|
|
37
|
+
# named.
|
|
38
38
|
- name: Interpret credential failure
|
|
39
39
|
if: steps.aws-creds.outcome == 'failure'
|
|
40
40
|
run: |
|
|
@@ -3,7 +3,7 @@ name: Terraform Plan on PR
|
|
|
3
3
|
on:
|
|
4
4
|
# pull_request_target (not pull_request): this file comes from the base
|
|
5
5
|
# branch, so a fork PR cannot delete the same-repo guard below to reach
|
|
6
|
-
# the privileged CI roles
|
|
6
|
+
# the privileged CI roles. The PR head is checked out explicitly by
|
|
7
7
|
# SHA in the guarded step instead.
|
|
8
8
|
pull_request_target:
|
|
9
9
|
types: [opened, synchronize, reopened]
|
|
@@ -53,7 +53,7 @@ jobs:
|
|
|
53
53
|
aws-region: ${{ env.AWS_REGION }}
|
|
54
54
|
|
|
55
55
|
# Plan-on-PR is a merge signal: a failed assume fails the run with
|
|
56
|
-
# the bootstrap pointer (deploy shape
|
|
56
|
+
# the bootstrap pointer (deploy shape) — never green-silent.
|
|
57
57
|
- name: Interpret credential failure
|
|
58
58
|
if: steps.aws-creds.outcome == 'failure'
|
|
59
59
|
run: |
|
|
@@ -3,7 +3,7 @@ name: Ephemeral PR Preview
|
|
|
3
3
|
on:
|
|
4
4
|
# pull_request_target (not pull_request): this file comes from the base
|
|
5
5
|
# branch, so a fork PR cannot delete the same-repo guard below to reach
|
|
6
|
-
# the privileged CI roles
|
|
6
|
+
# the privileged CI roles. The PR head is checked out explicitly by
|
|
7
7
|
# SHA in the guarded step instead.
|
|
8
8
|
pull_request_target:
|
|
9
9
|
types: [opened, synchronize, reopened]
|
|
@@ -58,7 +58,7 @@ jobs:
|
|
|
58
58
|
# STS denies a missing role and a trust mismatch with the same
|
|
59
59
|
# message, so the API won't support distinguishing them: every
|
|
60
60
|
# assume failure skips loud (green) with both cases + pointers
|
|
61
|
-
# named
|
|
61
|
+
# named.
|
|
62
62
|
- name: Interpret credential failure
|
|
63
63
|
if: steps.aws-creds.outcome == 'failure'
|
|
64
64
|
run: |
|
|
@@ -137,7 +137,7 @@ jobs:
|
|
|
137
137
|
|
|
138
138
|
# One sticky comment per PR (updated in place), never a new
|
|
139
139
|
# comment per push — and a failed run overwrites the green URL
|
|
140
|
-
# instead of leaving it standing as truth
|
|
140
|
+
# instead of leaving it standing as truth.
|
|
141
141
|
- name: Comment PR
|
|
142
142
|
if: steps.aws-creds.outcome == 'success'
|
|
143
143
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
|
@@ -199,7 +199,7 @@ jobs:
|
|
|
199
199
|
|
|
200
200
|
# A cancelled apply can strand the S3 state lockfile: point at
|
|
201
201
|
# recovery instead of leaving the next run to fail obscurely
|
|
202
|
-
|
|
202
|
+
#. Generic by necessity — the lock ID only exists in the
|
|
203
203
|
# follow-up run's own error.
|
|
204
204
|
- name: Cancellation recovery note
|
|
205
205
|
if: cancelled()
|
|
@@ -3,7 +3,7 @@ name: Ephemeral PR Preview
|
|
|
3
3
|
on:
|
|
4
4
|
# pull_request_target (not pull_request): this file comes from the base
|
|
5
5
|
# branch, so a fork PR cannot delete the same-repo guard below to reach
|
|
6
|
-
# the privileged CI roles
|
|
6
|
+
# the privileged CI roles. The PR head is checked out explicitly by
|
|
7
7
|
# SHA in the guarded step instead.
|
|
8
8
|
pull_request_target:
|
|
9
9
|
types: [opened, synchronize, reopened]
|
|
@@ -58,7 +58,7 @@ jobs:
|
|
|
58
58
|
# STS denies a missing role and a trust mismatch with the same
|
|
59
59
|
# message, so the API won't support distinguishing them: every
|
|
60
60
|
# assume failure skips loud (green) with both cases + pointers
|
|
61
|
-
# named
|
|
61
|
+
# named.
|
|
62
62
|
- name: Interpret credential failure
|
|
63
63
|
if: steps.aws-creds.outcome == 'failure'
|
|
64
64
|
run: |
|
|
@@ -119,7 +119,7 @@ jobs:
|
|
|
119
119
|
|
|
120
120
|
# One sticky comment per PR (updated in place), never a new
|
|
121
121
|
# comment per push — and a failed run overwrites the green URL
|
|
122
|
-
# instead of leaving it standing as truth
|
|
122
|
+
# instead of leaving it standing as truth.
|
|
123
123
|
- name: Comment PR
|
|
124
124
|
if: steps.aws-creds.outcome == 'success'
|
|
125
125
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
|
@@ -183,7 +183,7 @@ jobs:
|
|
|
183
183
|
|
|
184
184
|
# A cancelled apply can strand the S3 state lockfile: point at
|
|
185
185
|
# recovery instead of leaving the next run to fail obscurely
|
|
186
|
-
|
|
186
|
+
#. Generic by necessity — the lock ID only exists in the
|
|
187
187
|
# follow-up run's own error.
|
|
188
188
|
- name: Cancellation recovery note
|
|
189
189
|
if: cancelled()
|
|
@@ -3,7 +3,7 @@ name: Destroy PR Preview
|
|
|
3
3
|
on:
|
|
4
4
|
# pull_request_target (not pull_request): this file comes from the base
|
|
5
5
|
# branch, so a fork PR cannot smuggle privileged steps into its own
|
|
6
|
-
# teardown run
|
|
6
|
+
# teardown run. The PR head is checked out explicitly by SHA
|
|
7
7
|
# in the guarded step instead.
|
|
8
8
|
pull_request_target:
|
|
9
9
|
types: [closed]
|
|
@@ -52,7 +52,7 @@ jobs:
|
|
|
52
52
|
# STS denies a missing role and a trust mismatch with the same
|
|
53
53
|
# message, so the API won't support distinguishing them: every
|
|
54
54
|
# assume failure skips loud (green) with both cases + pointers
|
|
55
|
-
# named
|
|
55
|
+
# named.
|
|
56
56
|
- name: Interpret credential failure
|
|
57
57
|
if: steps.aws-creds.outcome == 'failure'
|
|
58
58
|
run: |
|
|
@@ -109,7 +109,7 @@ jobs:
|
|
|
109
109
|
|
|
110
110
|
# A cancelled destroy can strand the S3 state lockfile: point at
|
|
111
111
|
# recovery instead of leaving the next run to fail obscurely
|
|
112
|
-
|
|
112
|
+
#. Generic by necessity — the lock ID only exists in the
|
|
113
113
|
# follow-up run's own error.
|
|
114
114
|
- name: Cancellation recovery note
|
|
115
115
|
if: cancelled()
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# chosen model in the AWS Bedrock console first.
|
|
8
8
|
|
|
9
9
|
# --- Least-Privilege IAM Policy for the ECS Task Role ---
|
|
10
|
-
# Scoped to the chosen model in the deploy region
|
|
10
|
+
# Scoped to the chosen model in the deploy region: the
|
|
11
11
|
# foundation-model ARN names the model exactly, and the
|
|
12
12
|
# inference-profile line stays (profile-style model IDs invoke through
|
|
13
13
|
# profiles) but pinned to the region.
|
|
@@ -10,7 +10,7 @@ terraform {
|
|
|
10
10
|
source = "hashicorp/tls"
|
|
11
11
|
version = "~> 4.0"
|
|
12
12
|
}
|
|
13
|
-
# Declared unconditionally
|
|
13
|
+
# Declared unconditionally: the conditional injection left
|
|
14
14
|
# pre-existing trees without the pin when the DB arrived via
|
|
15
15
|
# `add database`. Unused on DB-less trees; init installs it anyway.
|
|
16
16
|
random = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# is wrong for an app server — one slot per path gets shared by HTML docs,
|
|
3
3
|
# API/RSC variants, redirects, and errors, so a cacheable variant poisons
|
|
4
4
|
# every other viewer of that path. Each traffic class below gets its own
|
|
5
|
-
# key instead
|
|
5
|
+
# key instead.
|
|
6
6
|
data "aws_cloudfront_cache_policy" "disabled" {
|
|
7
7
|
name = "Managed-CachingDisabled"
|
|
8
8
|
}
|
|
@@ -63,7 +63,7 @@ data "aws_cloudfront_origin_request_policy" "all_viewer" {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
# Managed security headers (HSTS, frame/clickjacking guards, content-type
|
|
66
|
-
# sniffing) on every behavior
|
|
66
|
+
# sniffing) on every behavior.
|
|
67
67
|
data "aws_cloudfront_response_headers_policy" "security" {
|
|
68
68
|
name = "Managed-SecurityHeadersPolicy"
|
|
69
69
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# is wrong for an app server — one slot per path gets shared by HTML docs,
|
|
3
3
|
# API/RSC variants, redirects, and errors, so a cacheable variant poisons
|
|
4
4
|
# every other viewer of that path. Each traffic class below gets its own
|
|
5
|
-
# key instead
|
|
5
|
+
# key instead.
|
|
6
6
|
data "aws_cloudfront_cache_policy" "disabled" {
|
|
7
7
|
name = "Managed-CachingDisabled"
|
|
8
8
|
}
|
|
@@ -63,7 +63,7 @@ data "aws_cloudfront_origin_request_policy" "all_viewer" {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
# Managed security headers (HSTS, frame/clickjacking guards, content-type
|
|
66
|
-
# sniffing) on every behavior
|
|
66
|
+
# sniffing) on every behavior.
|
|
67
67
|
data "aws_cloudfront_response_headers_policy" "security" {
|
|
68
68
|
name = "Managed-SecurityHeadersPolicy"
|
|
69
69
|
}
|
|
@@ -81,7 +81,7 @@ resource "aws_cloudfront_distribution" "cdn" {
|
|
|
81
81
|
domain_name = aws_lb.main.dns_name
|
|
82
82
|
origin_id = "ALBOrigin"
|
|
83
83
|
|
|
84
|
-
# Origin secret
|
|
84
|
+
# Origin secret: proves to the ALB that the request came
|
|
85
85
|
# through THIS distribution — any other tenant's distro, or a direct
|
|
86
86
|
# ALB hit, lacks the header and gets a 403 from the listener rule.
|
|
87
87
|
custom_header {
|
|
@@ -41,7 +41,7 @@ resource "aws_rds_cluster" "postgres" {
|
|
|
41
41
|
storage_encrypted = true
|
|
42
42
|
|
|
43
43
|
# Match the instance engines: 7-day retention with explicit off-peak
|
|
44
|
-
# UTC windows instead of AWS-assigned ones
|
|
44
|
+
# UTC windows instead of AWS-assigned ones.
|
|
45
45
|
backup_retention_period = 7
|
|
46
46
|
preferred_backup_window = "03:00-04:00"
|
|
47
47
|
preferred_maintenance_window = "sun:04:00-sun:05:00"
|
|
@@ -30,7 +30,7 @@ locals {
|
|
|
30
30
|
# Safely read the keys generated by the CLI, default to empty list if file doesn't exist.
|
|
31
31
|
# distinct() collapses hand-duplicated entries (duplicates render the
|
|
32
32
|
# same RegisterTaskDefinition 400 as a name collision) while preserving
|
|
33
|
-
# file order, so upgrading trees get no task-definition churn
|
|
33
|
+
# file order, so upgrading trees get no task-definition churn.
|
|
34
34
|
secret_keys = fileexists("${path.module}/secret_keys.json") ? distinct(jsondecode(file("${path.module}/secret_keys.json"))) : []
|
|
35
35
|
|
|
36
36
|
# Exact container env + static-secret names (union over app and worker
|
|
@@ -230,7 +230,7 @@ resource "aws_lb_target_group" "app" {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
# Origin secret
|
|
233
|
+
# Origin secret: only requests bearing the header CloudFront
|
|
234
234
|
# injects may reach the app. The CloudFront edge-IP security group alone
|
|
235
235
|
# cannot prove WHICH distribution sent a request — any tenant's distro
|
|
236
236
|
# could point at this ALB — so the listener forwards solely on a header
|
|
@@ -348,7 +348,7 @@ output "ecs_task_role_arn" {
|
|
|
348
348
|
# State-only alarm: visible in the console, notifies nobody. There is no
|
|
349
349
|
# notification destination at scaffold time; `grada alerts` provisions
|
|
350
350
|
# separate alarms wired to SNS, and this one stays as a console signal so
|
|
351
|
-
# quiet trees still show red
|
|
351
|
+
# quiet trees still show red.
|
|
352
352
|
resource "aws_cloudwatch_metric_alarm" "alb_5xx_errors" {
|
|
353
353
|
alarm_name = "${local.app_name}-high-5xx-errors"
|
|
354
354
|
comparison_operator = "GreaterThanThreshold"
|
|
@@ -43,17 +43,21 @@ locals {
|
|
|
43
43
|
preview_boundary_arn = terraform.workspace == "default" ? aws_iam_policy.preview_boundary[0].arn : data.aws_iam_policy.preview_boundary[0].arn
|
|
44
44
|
# Shared twin resource lists: every Deny*/BoundaryDeny* pair consumes
|
|
45
45
|
# one list, so a one-sided resource edit is impossible. New pairs add
|
|
46
|
-
# their list here and reference it from both sides.
|
|
46
|
+
# their list here and reference it from both sides. Wildcards below
|
|
47
|
+
# anchor on prod_prefix (never on the bare project): preview names
|
|
48
|
+
# carry -pr-<n>- where prod carries the hex suffix, so a
|
|
49
|
+
# ${prod_prefix}-* pattern matches prod only. Anchoring also keeps
|
|
50
|
+
# the boundary under the 6144-char managed-policy quota that broke
|
|
51
|
+
# tier1 E2E at a 24-char prefix — prefer one anchored wildcard over
|
|
52
|
+
# several exact ARNs when adding entries.
|
|
47
53
|
guardrail_compute_abuse_resources = ["*"]
|
|
48
54
|
guardrail_snapshot_sharing_resources = ["*"]
|
|
49
55
|
guardrail_state_destruction_resources = [
|
|
50
|
-
"arn:aws:s3:::{{STATE_BUCKET}}",
|
|
51
|
-
"arn:aws:s3:::{{STATE_BUCKET}}/*",
|
|
56
|
+
"arn:aws:s3:::{{STATE_BUCKET}}*",
|
|
52
57
|
]
|
|
53
58
|
guardrail_ecs_shutdown_resources = [
|
|
54
59
|
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster/${local.prod_prefix}-cluster",
|
|
55
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster
|
|
56
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster/${local.prod_prefix}-worker-service",
|
|
60
|
+
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster/*",
|
|
57
61
|
]
|
|
58
62
|
guardrail_image_deletion_resources = [
|
|
59
63
|
"arn:aws:ecr:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:repository/${local.prod_prefix}-repo",
|
|
@@ -62,12 +66,10 @@ locals {
|
|
|
62
66
|
"arn:aws:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:${local.prod_prefix}-fn",
|
|
63
67
|
]
|
|
64
68
|
guardrail_queue_destruction_resources = [
|
|
65
|
-
"arn:aws:sqs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:${local.prod_prefix}
|
|
66
|
-
"arn:aws:sqs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:${local.prod_prefix}-dlq",
|
|
69
|
+
"arn:aws:sqs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:${local.prod_prefix}-*",
|
|
67
70
|
]
|
|
68
71
|
guardrail_database_destruction_resources = [
|
|
69
|
-
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:db:${local.prod_prefix}-db",
|
|
70
|
-
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:db:${local.prod_prefix}-db-instance-1",
|
|
72
|
+
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:db:${local.prod_prefix}-db*",
|
|
71
73
|
]
|
|
72
74
|
guardrail_aurora_destruction_resources = [
|
|
73
75
|
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster:${local.prod_prefix}-db-cluster",
|
|
@@ -78,7 +80,7 @@ locals {
|
|
|
78
80
|
guardrail_snapshot_deletion_resources = [
|
|
79
81
|
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:snapshot:${local.prod_prefix}-db-*",
|
|
80
82
|
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster-snapshot:${local.prod_prefix}-db-cluster-*",
|
|
81
|
-
#
|
|
83
|
+
# Legacy bare pre-deploy-<sha> ids carry no db prefix, so
|
|
82
84
|
# they match no prod pattern above — deny them outright. gc never
|
|
83
85
|
# runs under preview credentials, so nothing legitimate needs them.
|
|
84
86
|
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:snapshot:pre-deploy-*",
|
|
@@ -92,24 +94,21 @@ locals {
|
|
|
92
94
|
]
|
|
93
95
|
guardrail_task_execution_resources = [
|
|
94
96
|
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster/${local.prod_prefix}-cluster",
|
|
95
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster
|
|
96
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster/${local.prod_prefix}-worker-service",
|
|
97
|
+
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster/*",
|
|
97
98
|
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task/${local.prod_prefix}-cluster/*",
|
|
98
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.prod_prefix}
|
|
99
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.prod_prefix}-worker-task:*",
|
|
99
|
+
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.prod_prefix}-*:*",
|
|
100
100
|
]
|
|
101
101
|
guardrail_task_definition_resources = [
|
|
102
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.prod_prefix}
|
|
103
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.prod_prefix}-worker-task:*",
|
|
102
|
+
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.prod_prefix}-*:*",
|
|
104
103
|
]
|
|
105
104
|
# String-built (not HCL refs): static trees define no IAM roles, so
|
|
106
105
|
# refs would dangle and fail validate. ECS and Lambda use identical
|
|
107
106
|
# physical role names, so one pattern covers both and matches
|
|
108
|
-
# nothing on static.
|
|
107
|
+
# nothing on static. The wildcard also covers the CI roles (same
|
|
108
|
+
# prefix, -github-actions-*-role): capped callers never legitimately
|
|
109
|
+
# pass or mutate those, so the overlap only tightens the boundary.
|
|
109
110
|
guardrail_app_role_resources = [
|
|
110
|
-
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}
|
|
111
|
-
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-execution-role",
|
|
112
|
-
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-cron-scheduler-role",
|
|
111
|
+
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-*-role",
|
|
113
112
|
]
|
|
114
113
|
}
|
|
115
114
|
|
|
@@ -231,8 +230,10 @@ resource "aws_iam_role_policy" "deploy_boundary" {
|
|
|
231
230
|
|
|
232
231
|
# Preview guardrails: PR-triggered runs (preview/teardown/plan) keep full
|
|
233
232
|
# build power but cannot destroy production data, mint compute, or open
|
|
234
|
-
# IAM backdoors. Every Resource below names
|
|
235
|
-
#
|
|
233
|
+
# IAM backdoors. Every Resource below names production only — exact ARNs
|
|
234
|
+
# or prod_prefix-anchored wildcards (preview names carry -pr-<n>- where
|
|
235
|
+
# prod carries the hex suffix, so anchored patterns never match preview
|
|
236
|
+
# resources and pr-suffixed workflows keep working).
|
|
236
237
|
resource "aws_iam_role_policy" "preview_guardrails" {
|
|
237
238
|
count = terraform.workspace == "default" ? 1 : 0
|
|
238
239
|
name = "${local.prod_prefix}-preview-guardrails"
|
|
@@ -254,7 +255,7 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
254
255
|
Resource = "*"
|
|
255
256
|
},
|
|
256
257
|
{
|
|
257
|
-
#
|
|
258
|
+
# The preview role carries IAMFullAccess, so without this
|
|
258
259
|
# statement it can delete its own guardrails, delete the deploy
|
|
259
260
|
# role, or widen trust in one call. Scoped to the CI role ARNs
|
|
260
261
|
# (not *): preview stacks legitimately manage their own
|
|
@@ -324,7 +325,7 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
324
325
|
Resource = local.guardrail_table_deletion_resources
|
|
325
326
|
},
|
|
326
327
|
{
|
|
327
|
-
#
|
|
328
|
+
# Manual snapshots (grada names them
|
|
328
329
|
# <db-identifier>-manual-<stamp> and
|
|
329
330
|
# <db-identifier>-pre-deploy-<sha>) are directly deletable;
|
|
330
331
|
# automated snapshots can only go away via retention changes or
|
|
@@ -352,7 +353,7 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
352
353
|
Resource = local.guardrail_log_deletion_resources
|
|
353
354
|
},
|
|
354
355
|
{
|
|
355
|
-
#
|
|
356
|
+
# Every role preview credentials create must carry the
|
|
356
357
|
# boundary — a missing key fails StringNotEquals, so unbounded
|
|
357
358
|
# creation is denied and born-capped roles cannot escalate.
|
|
358
359
|
Sid = "DenyRoleWithoutBoundary"
|
|
@@ -386,14 +387,23 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
386
387
|
]
|
|
387
388
|
},
|
|
388
389
|
{
|
|
389
|
-
#
|
|
390
|
-
#
|
|
390
|
+
# Close by target — deny the execution APIs on prod
|
|
391
|
+
# ARNs while pr-* stays allowed. No describes: plan.yml
|
|
391
392
|
# refreshes prod state with preview credentials, so describing
|
|
392
393
|
# prod is legitimate traffic.
|
|
393
394
|
Sid = "DenyProdTaskExecution"
|
|
394
395
|
Effect = "Deny"
|
|
395
396
|
Action = ["ecs:RunTask", "ecs:StopTask", "ecs:ExecuteCommand", "ecs:CreateService"]
|
|
396
397
|
Resource = local.guardrail_task_execution_resources
|
|
398
|
+
# The bounded scheduler role must RunTask its task
|
|
399
|
+
# definition at trigger time. A no-op on this side (the preview
|
|
400
|
+
# role is never the scheduler, assumable only by the scheduler
|
|
401
|
+
# service) but kept so the twins stay identical.
|
|
402
|
+
Condition = {
|
|
403
|
+
StringNotEquals = {
|
|
404
|
+
"aws:PrincipalArn" = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-cron-scheduler-role"
|
|
405
|
+
}
|
|
406
|
+
}
|
|
397
407
|
},
|
|
398
408
|
{
|
|
399
409
|
# RegisterTaskDefinition is likely resource-*-only (void half);
|
|
@@ -424,7 +434,7 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
424
434
|
})
|
|
425
435
|
}
|
|
426
436
|
|
|
427
|
-
#
|
|
437
|
+
# Permissions boundary capping every role preview credentials
|
|
428
438
|
# can create. The guardrail above denies CreateRole unless the request
|
|
429
439
|
# carries this boundary, so a backdoor role is born capped: its
|
|
430
440
|
# effective permissions are its own policies intersected with this one.
|
|
@@ -446,13 +456,19 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
446
456
|
Resource = "*"
|
|
447
457
|
},
|
|
448
458
|
{
|
|
449
|
-
#
|
|
459
|
+
# Capped roles must pass their task roles to ECS (the
|
|
450
460
|
# scheduler role passes at invocation time), so PassRole is
|
|
451
461
|
# carved out here and re-gated on service + target below.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
462
|
+
# Explicit Action list on purpose: a Deny with NotAction would
|
|
463
|
+
# veto every AWS service, not just IAM (tier2 E2E proved it on
|
|
464
|
+
# secretsmanager:GetSecretValue, SES, and Bedrock). IAM reads
|
|
465
|
+
# and cosmetic writes (UpdateRole, tagging) stay allowed: they
|
|
466
|
+
# cannot escalate a backdoor role, and a missing entry must
|
|
467
|
+
# weaken security instead of breaking prod tasks.
|
|
468
|
+
Sid = "BoundaryDenyIAM"
|
|
469
|
+
Effect = "Deny"
|
|
470
|
+
Action = ["iam:CreateRole", "iam:DeleteRole", "iam:UpdateAssumeRolePolicy", "iam:PutRolePolicy", "iam:DeleteRolePolicy", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:PutRolePermissionsBoundary", "iam:DeleteRolePermissionsBoundary", "iam:CreatePolicy", "iam:DeletePolicy", "iam:CreatePolicyVersion", "iam:DeletePolicyVersion", "iam:CreateUser", "iam:DeleteUser", "iam:CreateAccessKey", "iam:DeleteAccessKey"]
|
|
471
|
+
Resource = "*"
|
|
456
472
|
},
|
|
457
473
|
{
|
|
458
474
|
Sid = "BoundaryDenyAuditBilling"
|
|
@@ -543,6 +559,14 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
543
559
|
Effect = "Deny"
|
|
544
560
|
Action = ["ecs:RunTask", "ecs:StopTask", "ecs:ExecuteCommand", "ecs:CreateService"]
|
|
545
561
|
Resource = local.guardrail_task_execution_resources
|
|
562
|
+
# The bounded scheduler role must RunTask its task
|
|
563
|
+
# definition at trigger time; every other capped caller stays
|
|
564
|
+
# denied. Mirrors the twin's condition above.
|
|
565
|
+
Condition = {
|
|
566
|
+
StringNotEquals = {
|
|
567
|
+
"aws:PrincipalArn" = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-cron-scheduler-role"
|
|
568
|
+
}
|
|
569
|
+
}
|
|
546
570
|
},
|
|
547
571
|
{
|
|
548
572
|
Sid = "BoundaryDenyTaskDefinitionRegistration"
|
|
@@ -550,12 +574,10 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
550
574
|
Action = ["ecs:RegisterTaskDefinition", "ecs:DeregisterTaskDefinition"]
|
|
551
575
|
Resource = local.guardrail_task_definition_resources
|
|
552
576
|
},
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
Resource = local.guardrail_app_role_resources
|
|
558
|
-
},
|
|
577
|
+
# No flat BoundaryDenyPassRole twin: it denied the scheduler's
|
|
578
|
+
# own PassRole unconditionally, defeating the OffScheduler
|
|
579
|
+
# carve-out (any Deny wins). The OffService/OffTarget/
|
|
580
|
+
# OffScheduler trio below gates PassRole alone.
|
|
559
581
|
{
|
|
560
582
|
Sid = "BoundaryDenyAppRoleMutation"
|
|
561
583
|
Effect = "Deny"
|
|
@@ -563,7 +585,7 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
563
585
|
Resource = local.guardrail_app_role_resources
|
|
564
586
|
},
|
|
565
587
|
{
|
|
566
|
-
#
|
|
588
|
+
# Carved PassRole may only pass to the ECS tasks
|
|
567
589
|
# service (mirrors the scheduler policy's own condition).
|
|
568
590
|
Sid = "BoundaryDenyPassRoleOffService"
|
|
569
591
|
Effect = "Deny"
|
|
@@ -5,7 +5,7 @@ resource "aws_secretsmanager_secret" "app_secrets" {
|
|
|
5
5
|
count = terraform.workspace == "default" ? 1 : 0
|
|
6
6
|
name = "{{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-secrets"
|
|
7
7
|
description = "Environment variables for {{PROJECT_NAME}}"
|
|
8
|
-
# 30-day recovery
|
|
8
|
+
# 30-day recovery: an instant-delete vault turns any destroy
|
|
9
9
|
# bug into unrecoverable secret loss. Lower per-tree if you must.
|
|
10
10
|
recovery_window_in_days = 30
|
|
11
11
|
}
|