grada-run 0.49.11 → 0.50.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 +1 -1
- package/src/commands/alerts.js +283 -59
- package/src/commands/db/migrate.js +1 -1
- package/src/commands/diagnose.js +2 -2
- package/src/commands/gc.js +8 -2
- package/src/commands/rollback.js +2 -2
- package/src/commands/status.js +85 -7
- package/src/data/action-pins.js +1 -1
- package/src/utils/generator.js +19 -0
- package/src/utils/golden-signals.js +4 -4
- package/src/utils/prompts.js +6 -0
- package/src/utils/rds.js +7 -5
- package/src/utils/resolvers.js +18 -3
- package/templates/github/deploy-lambda.yml +1 -1
- package/templates/github/deploy-static.yml +1 -1
- package/templates/github/deploy.yml +1 -1
- package/templates/github/drift.yml +68 -0
- package/templates/github/preview.yml +131 -0
- package/templates/terraform/addons/bedrock.tf +3 -3
- package/templates/terraform/addons/cron-lambda.tf +23 -3
- package/templates/terraform/addons/cron.tf +23 -3
- package/templates/terraform/addons/s3.tf +6 -0
- package/templates/terraform/addons/ses.tf +44 -1
- package/templates/terraform/addons/sqs.tf +12 -3
- package/templates/terraform/database-aurora-postgresql.tf +46 -4
- package/templates/terraform/database-mysql.tf +32 -3
- package/templates/terraform/database.tf +32 -3
- package/templates/terraform/main-lambda.tf +13 -5
- package/templates/terraform/main.tf +16 -5
- package/templates/terraform/oidc.tf +132 -29
|
@@ -49,16 +49,16 @@ locals {
|
|
|
49
49
|
# ${prod_prefix}-* pattern matches prod only. Anchoring also keeps
|
|
50
50
|
# the boundary under the 6144-char managed-policy quota that broke
|
|
51
51
|
# tier1 E2E at a 24-char prefix — prefer one anchored wildcard over
|
|
52
|
-
# several exact ARNs when adding entries.
|
|
52
|
+
# several exact ARNs when adding entries. Headroom is 78 chars
|
|
53
|
+
# at 32-char prefixes (316 at 24): the shutdown-into-execution
|
|
54
|
+
# merger paid for the lifecycle/snapshot/table data verbs, so
|
|
55
|
+
# additions still fit — but the next one re-runs the quota probe
|
|
56
|
+
# before extending.
|
|
53
57
|
guardrail_compute_abuse_resources = ["*"]
|
|
54
58
|
guardrail_snapshot_sharing_resources = ["*"]
|
|
55
59
|
guardrail_state_destruction_resources = [
|
|
56
60
|
"arn:aws:s3:::{{STATE_BUCKET}}*",
|
|
57
61
|
]
|
|
58
|
-
guardrail_ecs_shutdown_resources = [
|
|
59
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster/${local.prod_prefix}-cluster",
|
|
60
|
-
"arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:service/${local.prod_prefix}-cluster/*",
|
|
61
|
-
]
|
|
62
62
|
guardrail_image_deletion_resources = [
|
|
63
63
|
"arn:aws:ecr:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:repository/${local.prod_prefix}-repo",
|
|
64
64
|
]
|
|
@@ -110,6 +110,37 @@ locals {
|
|
|
110
110
|
guardrail_app_role_resources = [
|
|
111
111
|
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-*-role",
|
|
112
112
|
]
|
|
113
|
+
# Data-plane confinement: prod data ARNs shared by the
|
|
114
|
+
# DenyProdAppData twins. One statement is exact here, not
|
|
115
|
+
# lazy — every denied action only ever matches its own service's
|
|
116
|
+
# ARNs in a real call, so the cross-product cannot over-match.
|
|
117
|
+
guardrail_app_data_resources = [
|
|
118
|
+
"arn:aws:secretsmanager:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:secret:${local.prod_prefix}-secrets-*",
|
|
119
|
+
"arn:aws:sqs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:${local.prod_prefix}-*",
|
|
120
|
+
]
|
|
121
|
+
# Lifecycle twin of the above, deliberately carve-free: no bounded
|
|
122
|
+
# role ever stops or reboots a database (sleep/wake and db commands
|
|
123
|
+
# run on user credentials), and one fewer condition keeps the pair
|
|
124
|
+
# under the 6144-char boundary quota.
|
|
125
|
+
guardrail_db_lifecycle_resources = [
|
|
126
|
+
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:db:${local.prod_prefix}-db*",
|
|
127
|
+
"arn:aws:rds:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:cluster:${local.prod_prefix}-db-cluster",
|
|
128
|
+
]
|
|
129
|
+
# Carve-out principal for the app-data twins: the exact prod task
|
|
130
|
+
# role ARN (workers send/receive prod queues). Singular on purpose:
|
|
131
|
+
# execution resolves taskdef secrets via GetSecretValue, which no
|
|
132
|
+
# statement here denies (plan refresh requires it — provider-proven),
|
|
133
|
+
# and nothing bounded writes secrets — so nothing else needs
|
|
134
|
+
# carving. Exact ARN, never a wildcard: a backdoor role could match
|
|
135
|
+
# a pattern by name since CreateRole sets its own trust inline.
|
|
136
|
+
# String-built, so static trees (no roles at all) stay valid. The
|
|
137
|
+
# scheduler is intentionally absent: RunTask plus PassRole only.
|
|
138
|
+
# Length-conditional like the role itself: over-cap trees hash the
|
|
139
|
+
# task name, and the carve-out must track the rendered name exactly
|
|
140
|
+
# (a stale plain ARN would silently uncarve workers).
|
|
141
|
+
guardrail_task_role_principals = [
|
|
142
|
+
length("${local.prod_prefix}-task-role") > 64 ? "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${substr(local.prod_prefix, 0, 64 - 1 - 5 - 10)}-${substr(md5(local.prod_prefix), 0, 5)}-task-role" : "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.prod_prefix}-task-role",
|
|
143
|
+
]
|
|
113
144
|
}
|
|
114
145
|
|
|
115
146
|
# Deploy role FIRST: readTerraformOidcTrust anchors on this block so re-init
|
|
@@ -273,7 +304,7 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
273
304
|
{
|
|
274
305
|
Sid = "DenySnapshotSharing"
|
|
275
306
|
Effect = "Deny"
|
|
276
|
-
Action = ["rds:
|
|
307
|
+
Action = ["rds:Modify*SnapshotAttribute"]
|
|
277
308
|
Resource = local.guardrail_snapshot_sharing_resources
|
|
278
309
|
},
|
|
279
310
|
{
|
|
@@ -282,12 +313,6 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
282
313
|
Action = ["s3:DeleteBucket", "s3:DeleteObjectVersion"]
|
|
283
314
|
Resource = local.guardrail_state_destruction_resources
|
|
284
315
|
},
|
|
285
|
-
{
|
|
286
|
-
Sid = "DenyProdECSShutdown"
|
|
287
|
-
Effect = "Deny"
|
|
288
|
-
Action = ["ecs:UpdateService", "ecs:DeleteService", "ecs:DeleteCluster"]
|
|
289
|
-
Resource = local.guardrail_ecs_shutdown_resources
|
|
290
|
-
},
|
|
291
316
|
{
|
|
292
317
|
Sid = "DenyProdImageDeletion"
|
|
293
318
|
Effect = "Deny"
|
|
@@ -319,9 +344,15 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
319
344
|
Resource = local.guardrail_aurora_destruction_resources
|
|
320
345
|
},
|
|
321
346
|
{
|
|
322
|
-
|
|
347
|
+
# Item data joins the table deny: preview apps use preview
|
|
348
|
+
# tables, so no bounded role ever reads prod items — and the
|
|
349
|
+
# wildcard set below leaves Describe*/List* (plan refresh) and
|
|
350
|
+
# control verbs alone. Streams stay out of reach of this
|
|
351
|
+
# pattern (stream ARNs carry a /stream suffix): accepted, the
|
|
352
|
+
# iterator dance is narrow and unactionable without table reads.
|
|
353
|
+
Sid = "DenyProdTableData"
|
|
323
354
|
Effect = "Deny"
|
|
324
|
-
Action = ["dynamodb:DeleteTable"]
|
|
355
|
+
Action = ["dynamodb:DeleteTable", "dynamodb:Batch*", "dynamodb:*Item", "dynamodb:Query", "dynamodb:Scan", "dynamodb:Execute*", "dynamodb:Transact*"]
|
|
325
356
|
Resource = local.guardrail_table_deletion_resources
|
|
326
357
|
},
|
|
327
358
|
{
|
|
@@ -330,9 +361,13 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
330
361
|
# <db-identifier>-pre-deploy-<sha>) are directly deletable;
|
|
331
362
|
# automated snapshots can only go away via retention changes or
|
|
332
363
|
# instance deletion, both already denied above.
|
|
333
|
-
|
|
364
|
+
# Copies, snapshot-based restores, and S3 exports authorize
|
|
365
|
+
# the source snapshot (service authorization reference), so
|
|
366
|
+
# denying them here closes the copy-then-read and
|
|
367
|
+
# export-to-attacker-bucket paths. Deletion keeps its verbs.
|
|
368
|
+
Sid = "DenyProdSnapshotData"
|
|
334
369
|
Effect = "Deny"
|
|
335
|
-
Action = ["rds:DeleteDBSnapshot", "rds:DeleteDBClusterSnapshot"]
|
|
370
|
+
Action = ["rds:DeleteDBSnapshot", "rds:DeleteDBClusterSnapshot", "rds:Copy*", "rds:Restore*", "rds:StartExportTask"]
|
|
336
371
|
Resource = local.guardrail_snapshot_deletion_resources
|
|
337
372
|
},
|
|
338
373
|
{
|
|
@@ -391,9 +426,15 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
391
426
|
# ARNs while pr-* stays allowed. No describes: plan.yml
|
|
392
427
|
# refreshes prod state with preview credentials, so describing
|
|
393
428
|
# prod is legitimate traffic.
|
|
429
|
+
# Service shutdown verbs live here (not in a separate
|
|
430
|
+
# statement): they share the cluster+service resources below,
|
|
431
|
+
# and a twin pair of their own would re-inline ~280 chars of
|
|
432
|
+
# ARNs against the boundary quota. The scheduler carve-out is
|
|
433
|
+
# a no-op for them — the scheduler role can never call
|
|
434
|
+
# Update/DeleteService or DeleteCluster.
|
|
394
435
|
Sid = "DenyProdTaskExecution"
|
|
395
436
|
Effect = "Deny"
|
|
396
|
-
Action = ["ecs:RunTask", "ecs:StopTask", "ecs:ExecuteCommand", "ecs:CreateService"]
|
|
437
|
+
Action = ["ecs:RunTask", "ecs:StopTask", "ecs:ExecuteCommand", "ecs:CreateService", "ecs:UpdateService", "ecs:DeleteService", "ecs:DeleteCluster"]
|
|
397
438
|
Resource = local.guardrail_task_execution_resources
|
|
398
439
|
# The bounded scheduler role must RunTask its task
|
|
399
440
|
# definition at trigger time. A no-op on this side (the preview
|
|
@@ -430,6 +471,49 @@ resource "aws_iam_role_policy" "preview_guardrails" {
|
|
|
430
471
|
Action = ["iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:PutRolePolicy", "iam:DeleteRolePolicy", "iam:UpdateAssumeRolePolicy", "iam:DeleteRole"]
|
|
431
472
|
Resource = local.guardrail_app_role_resources
|
|
432
473
|
},
|
|
474
|
+
{
|
|
475
|
+
# Preview CI must never write prod secrets or touch prod queue
|
|
476
|
+
# traffic. GetSecretValue stays allowed: plan refreshes the
|
|
477
|
+
# version resource with preview credentials, and the provider
|
|
478
|
+
# reads it via GetSecretValue (provider source verified) — a
|
|
479
|
+
# deny would break every PR plan. Reads stay an accepted
|
|
480
|
+
# residual (see below), as does DeleteMessage, which needs a
|
|
481
|
+
# Receive handle to call: with Receive denied it is unreachable.
|
|
482
|
+
# The carve-out is mirrored here as a no-op (the preview role
|
|
483
|
+
# is never a task role) so the twins stay identical.
|
|
484
|
+
# Accepted residual: GetSecretValue + prod state reads (plan
|
|
485
|
+
# refresh requires both; state additionally exposes adopted
|
|
486
|
+
# live values), Bedrock/SES spend verbs (denying would gut
|
|
487
|
+
# preview fidelity for AI/email apps — previews are full
|
|
488
|
+
# copies; same-repo guard + PR review are the controls), and
|
|
489
|
+
# DynamoDB stream reads (narrow iterator dance, unactionable
|
|
490
|
+
# without the table reads denied below). Snapshot copy/
|
|
491
|
+
# restore/export, point-in-time restore, DynamoDB item data,
|
|
492
|
+
# and RDS Start all landed as denies; DeleteMessage stays
|
|
493
|
+
# unreachable with Receive denied.
|
|
494
|
+
Sid = "DenyProdAppData"
|
|
495
|
+
Effect = "Deny"
|
|
496
|
+
Action = [
|
|
497
|
+
"secretsmanager:Put*", "secretsmanager:Update*",
|
|
498
|
+
"sqs:Send*", "sqs:Receive*",
|
|
499
|
+
]
|
|
500
|
+
Resource = local.guardrail_app_data_resources
|
|
501
|
+
Condition = {
|
|
502
|
+
StringNotEquals = {
|
|
503
|
+
"aws:PrincipalArn" = local.guardrail_task_role_principals
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
# ...nor stop, start, reboot, or point-in-time-restore prod
|
|
509
|
+
# databases. Deliberately carve-free: no bounded role ever
|
|
510
|
+
# calls these (sleep/wake and db commands run on user
|
|
511
|
+
# credentials).
|
|
512
|
+
Sid = "DenyProdDbLifecycle"
|
|
513
|
+
Effect = "Deny"
|
|
514
|
+
Action = ["rds:Stop*", "rds:Reboot*", "rds:Start*", "rds:Restore*"]
|
|
515
|
+
Resource = local.guardrail_db_lifecycle_resources
|
|
516
|
+
},
|
|
433
517
|
]
|
|
434
518
|
})
|
|
435
519
|
}
|
|
@@ -485,7 +569,7 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
485
569
|
{
|
|
486
570
|
Sid = "BoundaryDenySnapshotSharing"
|
|
487
571
|
Effect = "Deny"
|
|
488
|
-
Action = ["rds:
|
|
572
|
+
Action = ["rds:Modify*SnapshotAttribute"]
|
|
489
573
|
Resource = local.guardrail_snapshot_sharing_resources
|
|
490
574
|
},
|
|
491
575
|
{
|
|
@@ -494,12 +578,6 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
494
578
|
Action = ["s3:DeleteBucket", "s3:DeleteObjectVersion"]
|
|
495
579
|
Resource = local.guardrail_state_destruction_resources
|
|
496
580
|
},
|
|
497
|
-
{
|
|
498
|
-
Sid = "BoundaryDenyECSShutdown"
|
|
499
|
-
Effect = "Deny"
|
|
500
|
-
Action = ["ecs:UpdateService", "ecs:DeleteService", "ecs:DeleteCluster"]
|
|
501
|
-
Resource = local.guardrail_ecs_shutdown_resources
|
|
502
|
-
},
|
|
503
581
|
{
|
|
504
582
|
Sid = "BoundaryDenyImageDeletion"
|
|
505
583
|
Effect = "Deny"
|
|
@@ -531,15 +609,15 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
531
609
|
Resource = local.guardrail_aurora_destruction_resources
|
|
532
610
|
},
|
|
533
611
|
{
|
|
534
|
-
Sid = "
|
|
612
|
+
Sid = "BoundaryDenyTableData"
|
|
535
613
|
Effect = "Deny"
|
|
536
|
-
Action = ["dynamodb:DeleteTable"]
|
|
614
|
+
Action = ["dynamodb:DeleteTable", "dynamodb:Batch*", "dynamodb:*Item", "dynamodb:Query", "dynamodb:Scan", "dynamodb:Execute*", "dynamodb:Transact*"]
|
|
537
615
|
Resource = local.guardrail_table_deletion_resources
|
|
538
616
|
},
|
|
539
617
|
{
|
|
540
|
-
Sid = "
|
|
618
|
+
Sid = "BoundaryDenySnapshotData"
|
|
541
619
|
Effect = "Deny"
|
|
542
|
-
Action = ["rds:DeleteDBSnapshot", "rds:DeleteDBClusterSnapshot"]
|
|
620
|
+
Action = ["rds:DeleteDBSnapshot", "rds:DeleteDBClusterSnapshot", "rds:Copy*", "rds:Restore*", "rds:StartExportTask"]
|
|
543
621
|
Resource = local.guardrail_snapshot_deletion_resources
|
|
544
622
|
},
|
|
545
623
|
{
|
|
@@ -555,9 +633,11 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
555
633
|
Resource = local.guardrail_log_deletion_resources
|
|
556
634
|
},
|
|
557
635
|
{
|
|
636
|
+
# Shutdown verbs merged here; see the twin's comment (quota
|
|
637
|
+
# economy — a separate pair would re-inline the ARNs below).
|
|
558
638
|
Sid = "BoundaryDenyTaskExecution"
|
|
559
639
|
Effect = "Deny"
|
|
560
|
-
Action = ["ecs:RunTask", "ecs:StopTask", "ecs:ExecuteCommand", "ecs:CreateService"]
|
|
640
|
+
Action = ["ecs:RunTask", "ecs:StopTask", "ecs:ExecuteCommand", "ecs:CreateService", "ecs:UpdateService", "ecs:DeleteService", "ecs:DeleteCluster"]
|
|
561
641
|
Resource = local.guardrail_task_execution_resources
|
|
562
642
|
# The bounded scheduler role must RunTask its task
|
|
563
643
|
# definition at trigger time; every other capped caller stays
|
|
@@ -584,6 +664,29 @@ resource "aws_iam_policy" "preview_boundary" {
|
|
|
584
664
|
Action = ["iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:PutRolePolicy", "iam:DeleteRolePolicy", "iam:UpdateAssumeRolePolicy", "iam:DeleteRole"]
|
|
585
665
|
Resource = local.guardrail_app_role_resources
|
|
586
666
|
},
|
|
667
|
+
{
|
|
668
|
+
# Backdoor twin of DenyProdAppData: roles born under preview
|
|
669
|
+
# credentials get no prod vault writes or queue traffic either.
|
|
670
|
+
# The exact-ARN carve-out keeps workers sending/receiving.
|
|
671
|
+
Sid = "BoundaryDenyAppData"
|
|
672
|
+
Effect = "Deny"
|
|
673
|
+
Action = [
|
|
674
|
+
"secretsmanager:Put*", "secretsmanager:Update*",
|
|
675
|
+
"sqs:Send*", "sqs:Receive*",
|
|
676
|
+
]
|
|
677
|
+
Resource = local.guardrail_app_data_resources
|
|
678
|
+
Condition = {
|
|
679
|
+
StringNotEquals = {
|
|
680
|
+
"aws:PrincipalArn" = local.guardrail_task_role_principals
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
Sid = "BoundaryDenyDbLifecycle"
|
|
686
|
+
Effect = "Deny"
|
|
687
|
+
Action = ["rds:Stop*", "rds:Reboot*", "rds:Start*", "rds:Restore*"]
|
|
688
|
+
Resource = local.guardrail_db_lifecycle_resources
|
|
689
|
+
},
|
|
587
690
|
{
|
|
588
691
|
# Carved PassRole may only pass to the ECS tasks
|
|
589
692
|
# service (mirrors the scheduler policy's own condition).
|