@pipeline-builder/pipeline-manager 6.5.5 → 6.5.7

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.
Files changed (65) hide show
  1. package/README.md +11 -3
  2. package/dist/agent/post-steps.d.ts +1 -1
  3. package/dist/agent/post-steps.d.ts.map +1 -1
  4. package/dist/agent/post-steps.js +27 -31
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +8 -9
  7. package/dist/commands/audit-stacks.d.ts +2 -1
  8. package/dist/commands/audit-stacks.d.ts.map +1 -1
  9. package/dist/commands/audit-stacks.js +12 -2
  10. package/dist/commands/provision-steps.d.ts +1 -1
  11. package/dist/commands/provision-steps.js +2 -2
  12. package/dist/commands/provision.js +2 -2
  13. package/dist/commands/redrive-events.d.ts +4 -3
  14. package/dist/commands/redrive-events.d.ts.map +1 -1
  15. package/dist/commands/redrive-events.js +51 -18
  16. package/dist/commands/runner-signing-key.js +2 -2
  17. package/dist/commands/{setup-runner.d.ts → setup-account.d.ts} +133 -71
  18. package/dist/commands/setup-account.d.ts.map +1 -0
  19. package/dist/commands/setup-account.js +1366 -0
  20. package/dist/commands/store-token.d.ts +6 -28
  21. package/dist/commands/store-token.d.ts.map +1 -1
  22. package/dist/commands/store-token.js +12 -139
  23. package/dist/config/cli.constants.d.ts +0 -8
  24. package/dist/config/cli.constants.d.ts.map +1 -1
  25. package/dist/config/cli.constants.js +1 -9
  26. package/dist/lambda/events-handler.js +1558 -0
  27. package/dist/lambda/runner-handler.d.ts +27 -1
  28. package/dist/lambda/runner-handler.d.ts.map +1 -1
  29. package/dist/lambda/runner-handler.js +428 -71
  30. package/dist/lambda/runner-inspect-connection.d.ts +45 -0
  31. package/dist/lambda/runner-inspect-connection.d.ts.map +1 -0
  32. package/dist/lambda/runner-inspect-connection.js +157 -0
  33. package/dist/lambda/runner-jws.d.ts.map +1 -1
  34. package/dist/lambda/runner-jws.js +64 -6
  35. package/dist/lambda/runner-sources.d.ts +12 -0
  36. package/dist/lambda/runner-sources.d.ts.map +1 -1
  37. package/dist/lambda/runner-sources.js +25 -16
  38. package/dist/lambda/token-renew-handler.d.ts +3 -2
  39. package/dist/lambda/token-renew-handler.d.ts.map +1 -1
  40. package/dist/lambda/token-renew-handler.js +17 -5
  41. package/dist/templates/account-stack.json +2060 -0
  42. package/dist/templates/forwarder-stack.json +133 -0
  43. package/dist/utils/{runner-template.d.ts → account-template.d.ts} +83 -18
  44. package/dist/utils/account-template.d.ts.map +1 -0
  45. package/dist/utils/account-template.js +340 -0
  46. package/dist/utils/inspect-buildspec.d.ts +9 -0
  47. package/dist/utils/inspect-buildspec.d.ts.map +1 -0
  48. package/dist/utils/inspect-buildspec.js +209 -0
  49. package/dist/utils/service-account.d.ts +10 -2
  50. package/dist/utils/service-account.d.ts.map +1 -1
  51. package/dist/utils/service-account.js +10 -4
  52. package/package.json +5 -4
  53. package/dist/commands/setup-events.d.ts +0 -15
  54. package/dist/commands/setup-events.d.ts.map +0 -1
  55. package/dist/commands/setup-events.js +0 -182
  56. package/dist/commands/setup-runner.d.ts.map +0 -1
  57. package/dist/commands/setup-runner.js +0 -1132
  58. package/dist/templates/events-stack.json +0 -192
  59. package/dist/templates/runner-stack.json +0 -960
  60. package/dist/templates/token-renew-stack.json +0 -115
  61. package/dist/utils/cron.d.ts +0 -28
  62. package/dist/utils/cron.d.ts.map +0 -1
  63. package/dist/utils/cron.js +0 -119
  64. package/dist/utils/runner-template.d.ts.map +0 -1
  65. package/dist/utils/runner-template.js +0 -238
@@ -0,0 +1,2060 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Pipeline Builder ACCOUNT CONNECTOR — one stack per (AWS account, organization), deployed by pipeline-manager infra setup-account. RUNNER (EnableRunner): a Lambda that starts/stops this account's pipelines on platform-signed requests to its Function URL (or an IP-allowlisted, WAF rate-limited API Gateway), with an optional deploy CodeBuild project (EnableDeploy) and the inspect CodeBuild project + results bucket. REPORTING (EnableReporting): an EventBridge rule — filtered to the allowlisted pipeline-name prefixes — feeding an encrypted SQS queue (+ dead-letter queue) and the events Lambda that forwards CodePipeline state changes to the platform, stamping the SSM last-event parameter the runner's health ping reports. KEY RENEWAL (RenewSecretNames): a scheduled Lambda rotating this org's platform credentials in Secrets Manager. Every role takes the optional PermissionsBoundaryArn. setup-account renders the prefix-scoped grants and event pattern (utils/account-template.ts), uploads the template to the CDK bootstrap bucket and the Lambda code separately.",
4
+ "Parameters": {
5
+ "RunnerId": {
6
+ "Type": "String",
7
+ "Description": "The connector id (the platform's runner id: every signed request's aud). '' with EnableRunner=false.",
8
+ "Default": ""
9
+ },
10
+ "PlatformBaseUrl": {
11
+ "Type": "String",
12
+ "Description": "The platform's base URL (https). Signatures are verified against this runner's own key set, <PlatformBaseUrl>/api/pipelines/runner/runners/<RunnerId>/jwks.json (its owning organization's keys only)."
13
+ },
14
+ "EntryPoint": {
15
+ "Type": "String",
16
+ "Default": "function-url",
17
+ "AllowedValues": [
18
+ "function-url",
19
+ "api-gateway"
20
+ ],
21
+ "Description": "A Lambda Function URL, or a REST API whose resource policy admits only AllowedIps."
22
+ },
23
+ "AllowedIps": {
24
+ "Type": "CommaDelimitedList",
25
+ "Default": "255.255.255.255/32",
26
+ "Description": "api-gateway entry point only: source CIDRs (the platform's egress IPs) the API admits."
27
+ },
28
+ "EnableWaf": {
29
+ "Type": "String",
30
+ "Default": "true",
31
+ "AllowedValues": [
32
+ "true",
33
+ "false"
34
+ ],
35
+ "Description": "api-gateway entry point only: attach a WAFv2 web ACL with a per-IP rate-based rule to the API stage ('false' = setup-runner --no-waf). Ignored for the Function URL entry point."
36
+ },
37
+ "WafRateLimit": {
38
+ "Type": "Number",
39
+ "Default": 1000,
40
+ "MinValue": 10,
41
+ "MaxValue": 2000000000,
42
+ "Description": "api-gateway entry point with EnableWaf: requests one source IP may send in any 5-minute window before WAF blocks it (WAFv2 rate-based rule; setup-runner --waf-rate-limit)."
43
+ },
44
+ "AllowedRegions": {
45
+ "Type": "String",
46
+ "Description": "Regions the runner may act in and reporting covers (comma-separated); the first is this stack's home region."
47
+ },
48
+ "AllowedPipelinePrefixes": {
49
+ "Type": "String",
50
+ "Description": "Comma-separated CodePipeline name prefixes the runner may act on ('*' = every pipeline)."
51
+ },
52
+ "PipelinePrefix": {
53
+ "Type": "String",
54
+ "Default": "pipeline-builder-",
55
+ "Description": "Single-prefix fallback used only when this template is deployed as-is; setup-runner replaces the PipelineActions resources with every region x prefix."
56
+ },
57
+ "NameSuffix": {
58
+ "Type": "String",
59
+ "Default": "",
60
+ "Description": "Suffix on the role/function/API names: setup-runner passes '-<RunnerId>', so runners of different organizations never collide in one account (an organization has at most one runner per account)."
61
+ },
62
+ "PipelineManagerVersion": {
63
+ "Type": "String",
64
+ "Default": "0.0.0",
65
+ "Description": "The @pipeline-builder/pipeline-manager version whose runner bundle this stack runs (semver; reported as runnerVersion in every response). setup-account always passes its own package version."
66
+ },
67
+ "EnableDeploy": {
68
+ "Type": "String",
69
+ "Default": "false",
70
+ "AllowedValues": [
71
+ "true",
72
+ "false"
73
+ ],
74
+ "Description": "Deploys through this runner (setup-runner --enable-deploy): the deploy CodeBuild project, its role, log group and grant key. The runner answers DEPLOY_NOT_ENABLED to a deploy request without it and reports the deploy:1 capability only with it."
75
+ },
76
+ "RegistryPullHost": {
77
+ "Type": "String",
78
+ "Default": "",
79
+ "AllowedPattern": "^$|^[A-Za-z0-9.-]+(:[0-9]{1,5})?$",
80
+ "Description": "EnableDeploy only: the platform registry host (and :port) the deploy build pulls the pipeline's system/cdk-synth image from, pinned by digest. Never taken from a request."
81
+ },
82
+ "RegistryCredentialSecretName": {
83
+ "Type": "String",
84
+ "Default": "",
85
+ "Description": "EnableDeploy only: the Secrets Manager secret (in the stack region) holding the registry:push key CodeBuild pulls the image with — pipeline-builder/<orgId>/registry-push (pipeline-manager infra store-token --scope registry:push)."
86
+ },
87
+ "CdkQualifier": {
88
+ "Type": "String",
89
+ "Default": "hnb659fds",
90
+ "AllowedPattern": "^[A-Za-z0-9]{1,10}$",
91
+ "Description": "EnableDeploy only: the CDK bootstrap qualifier of the regions deployed into (cdk-<qualifier>-*-role-<account>-<region> are the only roles the deploy job may assume)."
92
+ },
93
+ "DeployTimeoutMinutes": {
94
+ "Type": "Number",
95
+ "Default": 60,
96
+ "MinValue": 10,
97
+ "MaxValue": 120,
98
+ "Description": "EnableDeploy only: the deploy build's timeout (CodeBuild TimeoutInMinutes). At most 120: the platform's deploy deadline (RUNNER_DEPLOY_DEADLINE_MINUTES, default 120) cancels a longer deploy first, failing DEPLOY_TIMED_OUT."
99
+ },
100
+ "DeployConcurrency": {
101
+ "Type": "Number",
102
+ "Default": 2,
103
+ "MinValue": 1,
104
+ "MaxValue": 20,
105
+ "Description": "EnableDeploy only: deploy builds that may run at once (CodeBuild ConcurrentBuildLimit; the platform's MAX_ACTIVE_DEPLOYS_PER_RUNNER is the first limit)."
106
+ },
107
+ "EnableRunner": {
108
+ "Type": "String",
109
+ "Default": "true",
110
+ "AllowedValues": [
111
+ "true",
112
+ "false"
113
+ ],
114
+ "Description": "The runner Lambda and its endpoint (setup-account --no-runner: false)."
115
+ },
116
+ "EnableReporting": {
117
+ "Type": "String",
118
+ "Default": "true",
119
+ "AllowedValues": [
120
+ "true",
121
+ "false"
122
+ ],
123
+ "Description": "EventBridge reporting of CodePipeline state changes (setup-account --no-reporting: false)."
124
+ },
125
+ "OrgId": {
126
+ "Type": "String",
127
+ "AllowedPattern": "^[A-Za-z0-9_-]{1,64}$",
128
+ "Description": "The organization's id: scopes every Secrets Manager grant to pipeline-builder/<OrgId>/*."
129
+ },
130
+ "ReportingSecretName": {
131
+ "Type": "String",
132
+ "Default": "",
133
+ "Description": "EnableReporting: the reporting:ingest credential secret (pipeline-builder/<orgId>/reporting-ingest)."
134
+ },
135
+ "DoraEnabled": {
136
+ "Type": "String",
137
+ "Default": "false",
138
+ "AllowedValues": [
139
+ "false",
140
+ "true"
141
+ ],
142
+ "Description": "EnableReporting: resolve commit timestamps in-account for DORA lead time (advanced_reporting add-on)."
143
+ },
144
+ "RenewSecretNames": {
145
+ "Type": "String",
146
+ "Default": "",
147
+ "Description": "Credential secrets the key renewal rotates (comma-separated, each pipeline-builder/<OrgId>/…); '' = no renewal."
148
+ },
149
+ "KeyLifetimeDays": {
150
+ "Type": "Number",
151
+ "Default": 30,
152
+ "MinValue": 1,
153
+ "MaxValue": 365,
154
+ "Description": "Lifetime in days of each rotated key."
155
+ },
156
+ "RenewSchedule": {
157
+ "Type": "String",
158
+ "Default": "cron(0 0 * * ? *)",
159
+ "Description": "EventBridge schedule of the key renewal (default daily 00:00 UTC)."
160
+ },
161
+ "PermissionsBoundaryArn": {
162
+ "Type": "String",
163
+ "Default": "",
164
+ "Description": "An IAM permissions boundary every role in the stack takes ('' = none)."
165
+ }
166
+ },
167
+ "Conditions": {
168
+ "UseFunctionUrl": {
169
+ "Fn::And": [
170
+ {
171
+ "Condition": "RunnerOn"
172
+ },
173
+ {
174
+ "Fn::Equals": [
175
+ {
176
+ "Ref": "EntryPoint"
177
+ },
178
+ "function-url"
179
+ ]
180
+ }
181
+ ]
182
+ },
183
+ "UseApiGateway": {
184
+ "Fn::And": [
185
+ {
186
+ "Condition": "RunnerOn"
187
+ },
188
+ {
189
+ "Fn::Equals": [
190
+ {
191
+ "Ref": "EntryPoint"
192
+ },
193
+ "api-gateway"
194
+ ]
195
+ }
196
+ ]
197
+ },
198
+ "UseWaf": {
199
+ "Fn::And": [
200
+ {
201
+ "Condition": "UseApiGateway"
202
+ },
203
+ {
204
+ "Fn::Equals": [
205
+ {
206
+ "Ref": "EnableWaf"
207
+ },
208
+ "true"
209
+ ]
210
+ }
211
+ ]
212
+ },
213
+ "UseDeploy": {
214
+ "Fn::And": [
215
+ {
216
+ "Condition": "RunnerOn"
217
+ },
218
+ {
219
+ "Fn::Equals": [
220
+ {
221
+ "Ref": "EnableDeploy"
222
+ },
223
+ "true"
224
+ ]
225
+ }
226
+ ]
227
+ },
228
+ "RunnerOn": {
229
+ "Fn::Equals": [
230
+ {
231
+ "Ref": "EnableRunner"
232
+ },
233
+ "true"
234
+ ]
235
+ },
236
+ "ReportingOn": {
237
+ "Fn::Equals": [
238
+ {
239
+ "Ref": "EnableReporting"
240
+ },
241
+ "true"
242
+ ]
243
+ },
244
+ "RunnerReporting": {
245
+ "Fn::And": [
246
+ {
247
+ "Condition": "RunnerOn"
248
+ },
249
+ {
250
+ "Condition": "ReportingOn"
251
+ }
252
+ ]
253
+ },
254
+ "RenewOn": {
255
+ "Fn::Not": [
256
+ {
257
+ "Fn::Equals": [
258
+ {
259
+ "Ref": "RenewSecretNames"
260
+ },
261
+ ""
262
+ ]
263
+ }
264
+ ]
265
+ },
266
+ "DoraOn": {
267
+ "Fn::And": [
268
+ {
269
+ "Condition": "ReportingOn"
270
+ },
271
+ {
272
+ "Fn::Equals": [
273
+ {
274
+ "Ref": "DoraEnabled"
275
+ },
276
+ "true"
277
+ ]
278
+ }
279
+ ]
280
+ },
281
+ "HasPermissionsBoundary": {
282
+ "Fn::Not": [
283
+ {
284
+ "Fn::Equals": [
285
+ {
286
+ "Ref": "PermissionsBoundaryArn"
287
+ },
288
+ ""
289
+ ]
290
+ }
291
+ ]
292
+ }
293
+ },
294
+ "Resources": {
295
+ "RunnerRole": {
296
+ "Type": "AWS::IAM::Role",
297
+ "Properties": {
298
+ "RoleName": {
299
+ "Fn::Sub": "pipeline-builder-runner${NameSuffix}"
300
+ },
301
+ "AssumeRolePolicyDocument": {
302
+ "Version": "2012-10-17",
303
+ "Statement": [
304
+ {
305
+ "Effect": "Allow",
306
+ "Principal": {
307
+ "Service": "lambda.amazonaws.com"
308
+ },
309
+ "Action": "sts:AssumeRole"
310
+ }
311
+ ]
312
+ },
313
+ "ManagedPolicyArns": [
314
+ {
315
+ "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
316
+ }
317
+ ],
318
+ "Policies": [
319
+ {
320
+ "PolicyName": "pipeline-runner",
321
+ "PolicyDocument": {
322
+ "Version": "2012-10-17",
323
+ "Statement": [
324
+ {
325
+ "Sid": "FindPipelineByTag",
326
+ "Effect": "Allow",
327
+ "Action": [
328
+ "tag:GetResources"
329
+ ],
330
+ "Resource": "*"
331
+ },
332
+ {
333
+ "Sid": "PipelineActions",
334
+ "Effect": "Allow",
335
+ "Action": [
336
+ "codepipeline:StartPipelineExecution",
337
+ "codepipeline:StopPipelineExecution",
338
+ "codepipeline:GetPipelineExecution",
339
+ "codepipeline:ListTagsForResource"
340
+ ],
341
+ "Resource": [
342
+ {
343
+ "Fn::Sub": "arn:${AWS::Partition}:codepipeline:${AWS::Region}:${AWS::AccountId}:${PipelinePrefix}*"
344
+ }
345
+ ]
346
+ },
347
+ {
348
+ "Sid": "ListSourceConnections",
349
+ "Effect": "Allow",
350
+ "Action": [
351
+ "codeconnections:ListConnections",
352
+ "codeconnections:ListHosts",
353
+ "codestar-connections:ListConnections",
354
+ "codestar-connections:ListHosts"
355
+ ],
356
+ "Resource": "*"
357
+ },
358
+ {
359
+ "Sid": "ReadSourceConnections",
360
+ "Effect": "Allow",
361
+ "Action": [
362
+ "codeconnections:GetConnection",
363
+ "codeconnections:GetHost",
364
+ "codestar-connections:GetConnection",
365
+ "codestar-connections:GetHost"
366
+ ],
367
+ "Resource": [
368
+ {
369
+ "Fn::Sub": "arn:${AWS::Partition}:codeconnections:${AWS::Region}:${AWS::AccountId}:connection/*"
370
+ },
371
+ {
372
+ "Fn::Sub": "arn:${AWS::Partition}:codeconnections:${AWS::Region}:${AWS::AccountId}:host/*"
373
+ },
374
+ {
375
+ "Fn::Sub": "arn:${AWS::Partition}:codestar-connections:${AWS::Region}:${AWS::AccountId}:connection/*"
376
+ },
377
+ {
378
+ "Fn::Sub": "arn:${AWS::Partition}:codestar-connections:${AWS::Region}:${AWS::AccountId}:host/*"
379
+ }
380
+ ]
381
+ },
382
+ {
383
+ "Sid": "DescribeGitHubTokenSecrets",
384
+ "Effect": "Allow",
385
+ "Action": [
386
+ "secretsmanager:DescribeSecret"
387
+ ],
388
+ "Resource": [
389
+ {
390
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*/github-token"
391
+ },
392
+ {
393
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*/github-token-??????"
394
+ },
395
+ {
396
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*/github-token/*"
397
+ }
398
+ ]
399
+ },
400
+ {
401
+ "Sid": "ReadGitHubTokenSecrets",
402
+ "Effect": "Allow",
403
+ "Action": [
404
+ "secretsmanager:GetSecretValue"
405
+ ],
406
+ "Resource": [
407
+ {
408
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*/github-token"
409
+ },
410
+ {
411
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*/github-token-??????"
412
+ },
413
+ {
414
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*/github-token/*"
415
+ }
416
+ ]
417
+ },
418
+ {
419
+ "Sid": "InspectBuild",
420
+ "Effect": "Allow",
421
+ "Action": [
422
+ "codebuild:StartBuild",
423
+ "codebuild:BatchGetBuilds",
424
+ "codebuild:StopBuild"
425
+ ],
426
+ "Resource": {
427
+ "Fn::Sub": "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:project/pipeline-builder-inspect-${RunnerId}"
428
+ }
429
+ },
430
+ {
431
+ "Sid": "PassCodeConnectionToInspectBuild",
432
+ "Effect": "Allow",
433
+ "Action": [
434
+ "codeconnections:PassConnection"
435
+ ],
436
+ "Resource": {
437
+ "Fn::Sub": "arn:${AWS::Partition}:codeconnections:${AWS::Region}:${AWS::AccountId}:connection/*"
438
+ },
439
+ "Condition": {
440
+ "StringEquals": {
441
+ "codeconnections:PassedToService": "codebuild.amazonaws.com"
442
+ }
443
+ }
444
+ },
445
+ {
446
+ "Sid": "PassCodeStarConnectionToInspectBuild",
447
+ "Effect": "Allow",
448
+ "Action": [
449
+ "codestar-connections:PassConnection"
450
+ ],
451
+ "Resource": {
452
+ "Fn::Sub": "arn:${AWS::Partition}:codestar-connections:${AWS::Region}:${AWS::AccountId}:connection/*"
453
+ },
454
+ "Condition": {
455
+ "StringEquals": {
456
+ "codestar-connections:PassedToService": "codebuild.amazonaws.com"
457
+ }
458
+ }
459
+ },
460
+ {
461
+ "Sid": "ReadInspectResults",
462
+ "Effect": "Allow",
463
+ "Action": "s3:GetObject",
464
+ "Resource": {
465
+ "Fn::Sub": "${InspectResultsBucket.Arn}/*"
466
+ }
467
+ },
468
+ {
469
+ "Fn::If": [
470
+ "UseDeploy",
471
+ {
472
+ "Sid": "DeployBuild",
473
+ "Effect": "Allow",
474
+ "Action": [
475
+ "codebuild:StartBuild",
476
+ "codebuild:BatchGetBuilds",
477
+ "codebuild:StopBuild",
478
+ "codebuild:ListBuildsForProject"
479
+ ],
480
+ "Resource": [
481
+ {
482
+ "Fn::Sub": "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:project/pipeline-builder-runner-deploy-${RunnerId}"
483
+ }
484
+ ]
485
+ },
486
+ {
487
+ "Ref": "AWS::NoValue"
488
+ }
489
+ ]
490
+ },
491
+ {
492
+ "Fn::If": [
493
+ "RunnerReporting",
494
+ {
495
+ "Sid": "ReportingHealth",
496
+ "Effect": "Allow",
497
+ "Action": [
498
+ "sqs:GetQueueAttributes",
499
+ "ssm:GetParameter"
500
+ ],
501
+ "Resource": [
502
+ {
503
+ "Fn::GetAtt": [
504
+ "EventDeadLetterQueue",
505
+ "Arn"
506
+ ]
507
+ },
508
+ {
509
+ "Fn::Sub": "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/pipeline-builder/events${NameSuffix}/last-event"
510
+ }
511
+ ]
512
+ },
513
+ {
514
+ "Ref": "AWS::NoValue"
515
+ }
516
+ ]
517
+ }
518
+ ]
519
+ }
520
+ }
521
+ ],
522
+ "PermissionsBoundary": {
523
+ "Fn::If": [
524
+ "HasPermissionsBoundary",
525
+ {
526
+ "Ref": "PermissionsBoundaryArn"
527
+ },
528
+ {
529
+ "Ref": "AWS::NoValue"
530
+ }
531
+ ]
532
+ }
533
+ },
534
+ "Condition": "RunnerOn"
535
+ },
536
+ "RunnerFunction": {
537
+ "Type": "AWS::Lambda::Function",
538
+ "Properties": {
539
+ "FunctionName": {
540
+ "Fn::Sub": "pipeline-builder-runner${NameSuffix}"
541
+ },
542
+ "Runtime": "nodejs26.x",
543
+ "Architectures": [
544
+ "arm64"
545
+ ],
546
+ "Handler": "index.handler",
547
+ "Code": {
548
+ "ZipFile": "exports.handler=async()=>({statusCode:500,body:JSON.stringify({errorCode:'RUNNER_ERROR'})})"
549
+ },
550
+ "Role": {
551
+ "Fn::GetAtt": [
552
+ "RunnerRole",
553
+ "Arn"
554
+ ]
555
+ },
556
+ "Timeout": 30,
557
+ "MemorySize": 256,
558
+ "ReservedConcurrentExecutions": 2,
559
+ "Environment": {
560
+ "Variables": {
561
+ "RUNNER_ID": {
562
+ "Ref": "RunnerId"
563
+ },
564
+ "PLATFORM_BASE_URL": {
565
+ "Ref": "PlatformBaseUrl"
566
+ },
567
+ "ALLOWED_REGIONS": {
568
+ "Ref": "AllowedRegions"
569
+ },
570
+ "ALLOWED_PIPELINE_PREFIXES": {
571
+ "Ref": "AllowedPipelinePrefixes"
572
+ },
573
+ "RUNNER_VERSION": {
574
+ "Ref": "PipelineManagerVersion"
575
+ },
576
+ "DEPLOY_ENABLED": {
577
+ "Ref": "EnableDeploy"
578
+ },
579
+ "DEPLOY_PROJECT_NAME": {
580
+ "Fn::If": [
581
+ "UseDeploy",
582
+ {
583
+ "Fn::Sub": "pipeline-builder-runner-deploy-${RunnerId}"
584
+ },
585
+ ""
586
+ ]
587
+ },
588
+ "REGISTRY_PULL_HOST": {
589
+ "Ref": "RegistryPullHost"
590
+ },
591
+ "REGISTRY_CREDENTIAL_SECRET": {
592
+ "Ref": "RegistryCredentialSecretName"
593
+ },
594
+ "DEPLOY_GRANT_KEY_ARN": {
595
+ "Fn::If": [
596
+ "UseDeploy",
597
+ {
598
+ "Fn::GetAtt": [
599
+ "DeployGrantKey",
600
+ "Arn"
601
+ ]
602
+ },
603
+ ""
604
+ ]
605
+ },
606
+ "NODE_ENV": "production",
607
+ "INSPECT_PROJECT_NAME": {
608
+ "Fn::Sub": "pipeline-builder-inspect-${RunnerId}"
609
+ },
610
+ "INSPECT_RESULTS_BUCKET": {
611
+ "Ref": "InspectResultsBucket"
612
+ },
613
+ "REPORTING_DLQ_URL": {
614
+ "Fn::If": [
615
+ "RunnerReporting",
616
+ {
617
+ "Ref": "EventDeadLetterQueue"
618
+ },
619
+ {
620
+ "Ref": "AWS::NoValue"
621
+ }
622
+ ]
623
+ },
624
+ "REPORTING_LAST_EVENT_PARAMETER": {
625
+ "Fn::If": [
626
+ "RunnerReporting",
627
+ {
628
+ "Ref": "LastEventParameter"
629
+ },
630
+ {
631
+ "Ref": "AWS::NoValue"
632
+ }
633
+ ]
634
+ }
635
+ }
636
+ }
637
+ },
638
+ "Condition": "RunnerOn"
639
+ },
640
+ "RunnerLogGroup": {
641
+ "Type": "AWS::Logs::LogGroup",
642
+ "Properties": {
643
+ "LogGroupName": {
644
+ "Fn::Sub": "/aws/lambda/pipeline-builder-runner${NameSuffix}"
645
+ },
646
+ "RetentionInDays": 90
647
+ },
648
+ "Condition": "RunnerOn"
649
+ },
650
+ "DeployLogGroup": {
651
+ "Type": "AWS::Logs::LogGroup",
652
+ "Condition": "UseDeploy",
653
+ "Properties": {
654
+ "LogGroupName": {
655
+ "Fn::Sub": "/aws/codebuild/pipeline-builder-runner-deploy-${RunnerId}"
656
+ },
657
+ "RetentionInDays": 90
658
+ }
659
+ },
660
+ "DeployRole": {
661
+ "Type": "AWS::IAM::Role",
662
+ "Condition": "UseDeploy",
663
+ "Properties": {
664
+ "RoleName": {
665
+ "Fn::Sub": "pb-runner-deploy${NameSuffix}"
666
+ },
667
+ "Description": "Pipeline Builder runner deploy job: assumes only this account's CDK bootstrap roles in the allowlisted regions (cdk deploy), never IAM or CloudFormation directly.",
668
+ "AssumeRolePolicyDocument": {
669
+ "Version": "2012-10-17",
670
+ "Statement": [
671
+ {
672
+ "Effect": "Allow",
673
+ "Principal": {
674
+ "Service": "codebuild.amazonaws.com"
675
+ },
676
+ "Action": "sts:AssumeRole",
677
+ "Condition": {
678
+ "StringEquals": {
679
+ "aws:SourceAccount": {
680
+ "Ref": "AWS::AccountId"
681
+ }
682
+ },
683
+ "ArnLike": {
684
+ "aws:SourceArn": {
685
+ "Fn::Sub": "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:project/pipeline-builder-runner-deploy-${RunnerId}"
686
+ }
687
+ }
688
+ }
689
+ }
690
+ ]
691
+ },
692
+ "PermissionsBoundary": {
693
+ "Fn::If": [
694
+ "HasPermissionsBoundary",
695
+ {
696
+ "Ref": "PermissionsBoundaryArn"
697
+ },
698
+ {
699
+ "Ref": "AWS::NoValue"
700
+ }
701
+ ]
702
+ },
703
+ "Policies": [
704
+ {
705
+ "PolicyName": "pipeline-runner-deploy",
706
+ "PolicyDocument": {
707
+ "Version": "2012-10-17",
708
+ "Statement": [
709
+ {
710
+ "Sid": "AssumeCdkBootstrapRoles",
711
+ "Effect": "Allow",
712
+ "Action": [
713
+ "sts:AssumeRole"
714
+ ],
715
+ "Resource": [
716
+ {
717
+ "Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${CdkQualifier}-deploy-role-${AWS::AccountId}-${AWS::Region}"
718
+ },
719
+ {
720
+ "Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${CdkQualifier}-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
721
+ },
722
+ {
723
+ "Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${CdkQualifier}-image-publishing-role-${AWS::AccountId}-${AWS::Region}"
724
+ },
725
+ {
726
+ "Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${CdkQualifier}-lookup-role-${AWS::AccountId}-${AWS::Region}"
727
+ }
728
+ ]
729
+ },
730
+ {
731
+ "Sid": "ReadCdkBootstrapVersion",
732
+ "Effect": "Allow",
733
+ "Action": [
734
+ "ssm:GetParameter"
735
+ ],
736
+ "Resource": [
737
+ {
738
+ "Fn::Sub": "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/cdk-bootstrap/${CdkQualifier}/version"
739
+ }
740
+ ]
741
+ },
742
+ {
743
+ "Sid": "DescribeAccountSecrets",
744
+ "Effect": "Allow",
745
+ "Action": [
746
+ "secretsmanager:DescribeSecret"
747
+ ],
748
+ "Resource": [
749
+ {
750
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/*"
751
+ }
752
+ ]
753
+ },
754
+ {
755
+ "Sid": "ReadRegistryPullCredential",
756
+ "Effect": "Allow",
757
+ "Action": [
758
+ "secretsmanager:GetSecretValue"
759
+ ],
760
+ "Resource": [
761
+ {
762
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${RegistryCredentialSecretName}-??????"
763
+ }
764
+ ]
765
+ },
766
+ {
767
+ "Sid": "WriteDeployLogs",
768
+ "Effect": "Allow",
769
+ "Action": [
770
+ "logs:CreateLogStream",
771
+ "logs:PutLogEvents"
772
+ ],
773
+ "Resource": [
774
+ {
775
+ "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/pipeline-builder-runner-deploy-${RunnerId}:*"
776
+ }
777
+ ]
778
+ }
779
+ ]
780
+ }
781
+ }
782
+ ]
783
+ }
784
+ },
785
+ "DeployGrantKey": {
786
+ "Type": "AWS::KMS::Key",
787
+ "Condition": "UseDeploy",
788
+ "Properties": {
789
+ "Description": {
790
+ "Fn::Sub": "Pipeline Builder runner ${RunnerId}: wraps each deploy job's single-use platform grant under {runnerId, purpose, requestId} (the runner role encrypts, the deploy role decrypts; a ciphertext decrypts for its own request only)."
791
+ },
792
+ "EnableKeyRotation": true,
793
+ "PendingWindowInDays": 7,
794
+ "KeyPolicy": {
795
+ "Version": "2012-10-17",
796
+ "Statement": [
797
+ {
798
+ "Sid": "KeyAdministration",
799
+ "Effect": "Allow",
800
+ "Principal": {
801
+ "AWS": {
802
+ "Fn::Sub": "arn:${AWS::Partition}:iam::${AWS::AccountId}:root"
803
+ }
804
+ },
805
+ "Action": [
806
+ "kms:DescribeKey",
807
+ "kms:GetKeyPolicy",
808
+ "kms:GetKeyRotationStatus",
809
+ "kms:ListResourceTags",
810
+ "kms:PutKeyPolicy",
811
+ "kms:EnableKeyRotation",
812
+ "kms:DisableKeyRotation",
813
+ "kms:EnableKey",
814
+ "kms:DisableKey",
815
+ "kms:TagResource",
816
+ "kms:UntagResource",
817
+ "kms:UpdateKeyDescription",
818
+ "kms:ScheduleKeyDeletion",
819
+ "kms:CancelKeyDeletion"
820
+ ],
821
+ "Resource": "*"
822
+ },
823
+ {
824
+ "Sid": "RunnerEncryptsGrants",
825
+ "Effect": "Allow",
826
+ "Principal": {
827
+ "AWS": {
828
+ "Fn::GetAtt": [
829
+ "RunnerRole",
830
+ "Arn"
831
+ ]
832
+ }
833
+ },
834
+ "Action": "kms:Encrypt",
835
+ "Resource": "*",
836
+ "Condition": {
837
+ "StringEquals": {
838
+ "kms:EncryptionContext:runnerId": {
839
+ "Ref": "RunnerId"
840
+ },
841
+ "kms:EncryptionContext:purpose": "deploy-grant"
842
+ },
843
+ "Null": {
844
+ "kms:EncryptionContext:requestId": "false"
845
+ },
846
+ "ForAllValues:StringEquals": {
847
+ "kms:EncryptionContextKeys": [
848
+ "runnerId",
849
+ "purpose",
850
+ "requestId"
851
+ ]
852
+ }
853
+ }
854
+ },
855
+ {
856
+ "Sid": "DeployJobDecryptsGrants",
857
+ "Effect": "Allow",
858
+ "Principal": {
859
+ "AWS": {
860
+ "Fn::GetAtt": [
861
+ "DeployRole",
862
+ "Arn"
863
+ ]
864
+ }
865
+ },
866
+ "Action": "kms:Decrypt",
867
+ "Resource": "*",
868
+ "Condition": {
869
+ "StringEquals": {
870
+ "kms:EncryptionContext:runnerId": {
871
+ "Ref": "RunnerId"
872
+ },
873
+ "kms:EncryptionContext:purpose": "deploy-grant"
874
+ },
875
+ "Null": {
876
+ "kms:EncryptionContext:requestId": "false"
877
+ },
878
+ "ForAllValues:StringEquals": {
879
+ "kms:EncryptionContextKeys": [
880
+ "runnerId",
881
+ "purpose",
882
+ "requestId"
883
+ ]
884
+ }
885
+ }
886
+ }
887
+ ]
888
+ }
889
+ }
890
+ },
891
+ "DeployProject": {
892
+ "Type": "AWS::CodeBuild::Project",
893
+ "Condition": "UseDeploy",
894
+ "DependsOn": "DeployLogGroup",
895
+ "Properties": {
896
+ "Name": {
897
+ "Fn::Sub": "pipeline-builder-runner-deploy-${RunnerId}"
898
+ },
899
+ "Description": "Pipeline Builder runner deploy job: pipeline-manager pipeline deploy-job on the pipeline's managed cdk-synth image (StartBuild overrides only the image digest and the request's PB_* values).",
900
+ "ServiceRole": {
901
+ "Fn::GetAtt": [
902
+ "DeployRole",
903
+ "Arn"
904
+ ]
905
+ },
906
+ "Source": {
907
+ "Type": "NO_SOURCE",
908
+ "BuildSpec": "version: 0.2\nenv:\n shell: bash\n exported-variables:\n - PB_DEPLOY_RESULT\n - PB_DEPLOY_STAGE\nphases:\n build:\n commands:\n - pipeline-manager pipeline deploy-job --result-file /tmp/pb-deploy-result.env\n post_build:\n commands:\n - 'export PB_DEPLOY_RESULT=\"$(grep -E ''^PB_DEPLOY_RESULT=[A-Z_]{1,64}$'' /tmp/pb-deploy-result.env 2>/dev/null | cut -d= -f2)\"'\n - 'export PB_DEPLOY_STAGE=\"$(grep -E ''^PB_DEPLOY_STAGE=[a-z_]{1,32}$'' /tmp/pb-deploy-result.env 2>/dev/null | cut -d= -f2)\"'\n"
909
+ },
910
+ "Artifacts": {
911
+ "Type": "NO_ARTIFACTS"
912
+ },
913
+ "Environment": {
914
+ "Type": "LINUX_CONTAINER",
915
+ "ComputeType": "BUILD_GENERAL1_MEDIUM",
916
+ "Image": {
917
+ "Fn::Sub": "${RegistryPullHost}/system/cdk-synth:set-per-build"
918
+ },
919
+ "ImagePullCredentialsType": "SERVICE_ROLE",
920
+ "RegistryCredential": {
921
+ "Credential": {
922
+ "Ref": "RegistryCredentialSecretName"
923
+ },
924
+ "CredentialProvider": "SECRETS_MANAGER"
925
+ },
926
+ "PrivilegedMode": false,
927
+ "EnvironmentVariables": [
928
+ {
929
+ "Name": "PLATFORM_BASE_URL",
930
+ "Type": "PLAINTEXT",
931
+ "Value": {
932
+ "Ref": "PlatformBaseUrl"
933
+ }
934
+ },
935
+ {
936
+ "Name": "PB_RUNNER_ID",
937
+ "Type": "PLAINTEXT",
938
+ "Value": {
939
+ "Ref": "RunnerId"
940
+ }
941
+ },
942
+ {
943
+ "Name": "PB_CDK_QUALIFIER",
944
+ "Type": "PLAINTEXT",
945
+ "Value": {
946
+ "Ref": "CdkQualifier"
947
+ }
948
+ },
949
+ {
950
+ "Name": "NODE_ENV",
951
+ "Type": "PLAINTEXT",
952
+ "Value": "production"
953
+ }
954
+ ]
955
+ },
956
+ "TimeoutInMinutes": {
957
+ "Ref": "DeployTimeoutMinutes"
958
+ },
959
+ "QueuedTimeoutInMinutes": 30,
960
+ "ConcurrentBuildLimit": {
961
+ "Ref": "DeployConcurrency"
962
+ },
963
+ "LogsConfig": {
964
+ "CloudWatchLogs": {
965
+ "Status": "ENABLED",
966
+ "GroupName": {
967
+ "Fn::Sub": "/aws/codebuild/pipeline-builder-runner-deploy-${RunnerId}"
968
+ }
969
+ }
970
+ }
971
+ }
972
+ },
973
+ "InspectResultsBucket": {
974
+ "Type": "AWS::S3::Bucket",
975
+ "Properties": {
976
+ "BucketEncryption": {
977
+ "ServerSideEncryptionConfiguration": [
978
+ {
979
+ "ServerSideEncryptionByDefault": {
980
+ "SSEAlgorithm": "AES256"
981
+ }
982
+ }
983
+ ]
984
+ },
985
+ "PublicAccessBlockConfiguration": {
986
+ "BlockPublicAcls": true,
987
+ "BlockPublicPolicy": true,
988
+ "IgnorePublicAcls": true,
989
+ "RestrictPublicBuckets": true
990
+ },
991
+ "OwnershipControls": {
992
+ "Rules": [
993
+ {
994
+ "ObjectOwnership": "BucketOwnerEnforced"
995
+ }
996
+ ]
997
+ },
998
+ "LifecycleConfiguration": {
999
+ "Rules": [
1000
+ {
1001
+ "Id": "ExpireInspectSnapshots",
1002
+ "Status": "Enabled",
1003
+ "ExpirationInDays": 1,
1004
+ "AbortIncompleteMultipartUpload": {
1005
+ "DaysAfterInitiation": 1
1006
+ }
1007
+ }
1008
+ ]
1009
+ }
1010
+ },
1011
+ "Condition": "RunnerOn"
1012
+ },
1013
+ "InspectResultsBucketPolicy": {
1014
+ "Type": "AWS::S3::BucketPolicy",
1015
+ "Properties": {
1016
+ "Bucket": {
1017
+ "Ref": "InspectResultsBucket"
1018
+ },
1019
+ "PolicyDocument": {
1020
+ "Version": "2012-10-17",
1021
+ "Statement": [
1022
+ {
1023
+ "Sid": "DenyInsecureTransport",
1024
+ "Effect": "Deny",
1025
+ "Principal": "*",
1026
+ "Action": "s3:*",
1027
+ "Resource": [
1028
+ {
1029
+ "Fn::GetAtt": [
1030
+ "InspectResultsBucket",
1031
+ "Arn"
1032
+ ]
1033
+ },
1034
+ {
1035
+ "Fn::Sub": "${InspectResultsBucket.Arn}/*"
1036
+ }
1037
+ ],
1038
+ "Condition": {
1039
+ "Bool": {
1040
+ "aws:SecureTransport": "false"
1041
+ }
1042
+ }
1043
+ },
1044
+ {
1045
+ "Sid": "OnlyTheInspectBuildWrites",
1046
+ "Effect": "Deny",
1047
+ "Principal": "*",
1048
+ "Action": "s3:PutObject",
1049
+ "Resource": {
1050
+ "Fn::Sub": "${InspectResultsBucket.Arn}/*"
1051
+ },
1052
+ "Condition": {
1053
+ "ArnNotEquals": {
1054
+ "aws:PrincipalArn": {
1055
+ "Fn::GetAtt": [
1056
+ "InspectBuildRole",
1057
+ "Arn"
1058
+ ]
1059
+ }
1060
+ }
1061
+ }
1062
+ },
1063
+ {
1064
+ "Sid": "OnlyTheRunnerReads",
1065
+ "Effect": "Deny",
1066
+ "Principal": "*",
1067
+ "Action": [
1068
+ "s3:GetObject",
1069
+ "s3:DeleteObject"
1070
+ ],
1071
+ "Resource": {
1072
+ "Fn::Sub": "${InspectResultsBucket.Arn}/*"
1073
+ },
1074
+ "Condition": {
1075
+ "ArnNotEquals": {
1076
+ "aws:PrincipalArn": {
1077
+ "Fn::GetAtt": [
1078
+ "RunnerRole",
1079
+ "Arn"
1080
+ ]
1081
+ }
1082
+ }
1083
+ }
1084
+ }
1085
+ ]
1086
+ }
1087
+ },
1088
+ "Condition": "RunnerOn"
1089
+ },
1090
+ "InspectLogGroup": {
1091
+ "Type": "AWS::Logs::LogGroup",
1092
+ "Properties": {
1093
+ "LogGroupName": {
1094
+ "Fn::Sub": "/aws/codebuild/pipeline-builder-inspect-${RunnerId}"
1095
+ },
1096
+ "RetentionInDays": 14
1097
+ },
1098
+ "Condition": "RunnerOn"
1099
+ },
1100
+ "InspectBuildRole": {
1101
+ "Type": "AWS::IAM::Role",
1102
+ "Properties": {
1103
+ "RoleName": {
1104
+ "Fn::Sub": "pipeline-builder-inspect-${RunnerId}"
1105
+ },
1106
+ "Description": "Pipeline Builder runner inspect build: clones one repository through a CodeConnections connection and writes a bounded snapshot to the results bucket.",
1107
+ "AssumeRolePolicyDocument": {
1108
+ "Version": "2012-10-17",
1109
+ "Statement": [
1110
+ {
1111
+ "Effect": "Allow",
1112
+ "Principal": {
1113
+ "Service": "codebuild.amazonaws.com"
1114
+ },
1115
+ "Action": "sts:AssumeRole",
1116
+ "Condition": {
1117
+ "StringEquals": {
1118
+ "aws:SourceAccount": {
1119
+ "Ref": "AWS::AccountId"
1120
+ }
1121
+ },
1122
+ "ArnLike": {
1123
+ "aws:SourceArn": {
1124
+ "Fn::Sub": "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:project/pipeline-builder-inspect-${RunnerId}"
1125
+ }
1126
+ }
1127
+ }
1128
+ }
1129
+ ]
1130
+ },
1131
+ "Policies": [
1132
+ {
1133
+ "PolicyName": "inspect-build",
1134
+ "PolicyDocument": {
1135
+ "Version": "2012-10-17",
1136
+ "Statement": [
1137
+ {
1138
+ "Sid": "UseConnections",
1139
+ "Effect": "Allow",
1140
+ "Action": [
1141
+ "codeconnections:GetConnection",
1142
+ "codeconnections:GetConnectionToken",
1143
+ "codeconnections:UseConnection",
1144
+ "codestar-connections:GetConnection",
1145
+ "codestar-connections:GetConnectionToken",
1146
+ "codestar-connections:UseConnection"
1147
+ ],
1148
+ "Resource": [
1149
+ {
1150
+ "Fn::Sub": "arn:${AWS::Partition}:codeconnections:${AWS::Region}:${AWS::AccountId}:connection/*"
1151
+ },
1152
+ {
1153
+ "Fn::Sub": "arn:${AWS::Partition}:codestar-connections:${AWS::Region}:${AWS::AccountId}:connection/*"
1154
+ }
1155
+ ]
1156
+ },
1157
+ {
1158
+ "Sid": "WriteResults",
1159
+ "Effect": "Allow",
1160
+ "Action": [
1161
+ "s3:PutObject"
1162
+ ],
1163
+ "Resource": {
1164
+ "Fn::Sub": "${InspectResultsBucket.Arn}/*"
1165
+ }
1166
+ },
1167
+ {
1168
+ "Sid": "WriteLogs",
1169
+ "Effect": "Allow",
1170
+ "Action": [
1171
+ "logs:CreateLogStream",
1172
+ "logs:PutLogEvents"
1173
+ ],
1174
+ "Resource": [
1175
+ {
1176
+ "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/pipeline-builder-inspect-${RunnerId}:*"
1177
+ }
1178
+ ]
1179
+ }
1180
+ ]
1181
+ }
1182
+ }
1183
+ ],
1184
+ "PermissionsBoundary": {
1185
+ "Fn::If": [
1186
+ "HasPermissionsBoundary",
1187
+ {
1188
+ "Ref": "PermissionsBoundaryArn"
1189
+ },
1190
+ {
1191
+ "Ref": "AWS::NoValue"
1192
+ }
1193
+ ]
1194
+ }
1195
+ },
1196
+ "Condition": "RunnerOn"
1197
+ },
1198
+ "InspectProject": {
1199
+ "Type": "AWS::CodeBuild::Project",
1200
+ "DependsOn": "InspectLogGroup",
1201
+ "Properties": {
1202
+ "Name": {
1203
+ "Fn::Sub": "pipeline-builder-inspect-${RunnerId}"
1204
+ },
1205
+ "Description": "Pipeline Builder runner inspect build (Generate from Git): the runner starts it with the repository as a CodeConnections source override; it writes what an analysis reads to the results bucket.",
1206
+ "ServiceRole": {
1207
+ "Fn::GetAtt": [
1208
+ "InspectBuildRole",
1209
+ "Arn"
1210
+ ]
1211
+ },
1212
+ "Source": {
1213
+ "Type": "NO_SOURCE",
1214
+ "BuildSpec": "version: 0.2\nphases:\n build:\n commands:\n - echo 'Deploy this stack with pipeline-manager infra setup-runner, which fills in the inspect buildspec.' && exit 1\n"
1215
+ },
1216
+ "Artifacts": {
1217
+ "Type": "NO_ARTIFACTS"
1218
+ },
1219
+ "Environment": {
1220
+ "Type": "LINUX_CONTAINER",
1221
+ "ComputeType": "BUILD_GENERAL1_SMALL",
1222
+ "Image": "aws/codebuild/amazonlinux-x86_64-standard:5.0",
1223
+ "PrivilegedMode": false,
1224
+ "EnvironmentVariables": [
1225
+ {
1226
+ "Name": "INSPECT_RESULTS_BUCKET",
1227
+ "Type": "PLAINTEXT",
1228
+ "Value": {
1229
+ "Ref": "InspectResultsBucket"
1230
+ }
1231
+ }
1232
+ ]
1233
+ },
1234
+ "TimeoutInMinutes": 10,
1235
+ "QueuedTimeoutInMinutes": 5,
1236
+ "ConcurrentBuildLimit": 2,
1237
+ "LogsConfig": {
1238
+ "CloudWatchLogs": {
1239
+ "Status": "ENABLED",
1240
+ "GroupName": {
1241
+ "Fn::Sub": "/aws/codebuild/pipeline-builder-inspect-${RunnerId}"
1242
+ }
1243
+ }
1244
+ }
1245
+ },
1246
+ "Condition": "RunnerOn"
1247
+ },
1248
+ "FunctionUrl": {
1249
+ "Type": "AWS::Lambda::Url",
1250
+ "Condition": "UseFunctionUrl",
1251
+ "Properties": {
1252
+ "AuthType": "NONE",
1253
+ "TargetFunctionArn": {
1254
+ "Fn::GetAtt": [
1255
+ "RunnerFunction",
1256
+ "Arn"
1257
+ ]
1258
+ }
1259
+ }
1260
+ },
1261
+ "FunctionUrlPermission": {
1262
+ "Type": "AWS::Lambda::Permission",
1263
+ "Condition": "UseFunctionUrl",
1264
+ "Properties": {
1265
+ "FunctionName": {
1266
+ "Ref": "RunnerFunction"
1267
+ },
1268
+ "Action": "lambda:InvokeFunctionUrl",
1269
+ "Principal": "*",
1270
+ "FunctionUrlAuthType": "NONE"
1271
+ }
1272
+ },
1273
+ "FunctionUrlInvokePermission": {
1274
+ "Type": "AWS::Lambda::Permission",
1275
+ "Condition": "UseFunctionUrl",
1276
+ "Properties": {
1277
+ "FunctionName": {
1278
+ "Ref": "RunnerFunction"
1279
+ },
1280
+ "Action": "lambda:InvokeFunction",
1281
+ "Principal": "*",
1282
+ "InvokedViaFunctionUrl": true
1283
+ }
1284
+ },
1285
+ "RunnerApi": {
1286
+ "Type": "AWS::ApiGateway::RestApi",
1287
+ "Condition": "UseApiGateway",
1288
+ "Properties": {
1289
+ "Name": {
1290
+ "Fn::Sub": "pipeline-builder-runner${NameSuffix}"
1291
+ },
1292
+ "Description": "Pipeline Builder runner entry point, admitting only the platform's egress IPs",
1293
+ "EndpointConfiguration": {
1294
+ "Types": [
1295
+ "REGIONAL"
1296
+ ]
1297
+ },
1298
+ "Policy": {
1299
+ "Version": "2012-10-17",
1300
+ "Statement": [
1301
+ {
1302
+ "Effect": "Allow",
1303
+ "Principal": "*",
1304
+ "Action": "execute-api:Invoke",
1305
+ "Resource": "execute-api:/*",
1306
+ "Condition": {
1307
+ "IpAddress": {
1308
+ "aws:SourceIp": {
1309
+ "Ref": "AllowedIps"
1310
+ }
1311
+ }
1312
+ }
1313
+ }
1314
+ ]
1315
+ }
1316
+ }
1317
+ },
1318
+ "RunnerApiMethod": {
1319
+ "Type": "AWS::ApiGateway::Method",
1320
+ "Condition": "UseApiGateway",
1321
+ "Properties": {
1322
+ "RestApiId": {
1323
+ "Ref": "RunnerApi"
1324
+ },
1325
+ "ResourceId": {
1326
+ "Fn::GetAtt": [
1327
+ "RunnerApi",
1328
+ "RootResourceId"
1329
+ ]
1330
+ },
1331
+ "HttpMethod": "POST",
1332
+ "AuthorizationType": "NONE",
1333
+ "Integration": {
1334
+ "Type": "AWS_PROXY",
1335
+ "IntegrationHttpMethod": "POST",
1336
+ "Uri": {
1337
+ "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RunnerFunction.Arn}/invocations"
1338
+ }
1339
+ }
1340
+ }
1341
+ },
1342
+ "RunnerApiDeployment": {
1343
+ "Type": "AWS::ApiGateway::Deployment",
1344
+ "Condition": "UseApiGateway",
1345
+ "DependsOn": "RunnerApiMethod",
1346
+ "Properties": {
1347
+ "RestApiId": {
1348
+ "Ref": "RunnerApi"
1349
+ }
1350
+ }
1351
+ },
1352
+ "RunnerApiStage": {
1353
+ "Type": "AWS::ApiGateway::Stage",
1354
+ "Condition": "UseApiGateway",
1355
+ "Properties": {
1356
+ "RestApiId": {
1357
+ "Ref": "RunnerApi"
1358
+ },
1359
+ "DeploymentId": {
1360
+ "Ref": "RunnerApiDeployment"
1361
+ },
1362
+ "StageName": "runner",
1363
+ "MethodSettings": [
1364
+ {
1365
+ "ResourcePath": "/*",
1366
+ "HttpMethod": "*",
1367
+ "ThrottlingRateLimit": 5,
1368
+ "ThrottlingBurstLimit": 10
1369
+ }
1370
+ ]
1371
+ }
1372
+ },
1373
+ "RunnerApiPermission": {
1374
+ "Type": "AWS::Lambda::Permission",
1375
+ "Condition": "UseApiGateway",
1376
+ "Properties": {
1377
+ "FunctionName": {
1378
+ "Ref": "RunnerFunction"
1379
+ },
1380
+ "Action": "lambda:InvokeFunction",
1381
+ "Principal": "apigateway.amazonaws.com",
1382
+ "SourceArn": {
1383
+ "Fn::Sub": "arn:${AWS::Partition}:execute-api:${AWS::Region}:${AWS::AccountId}:${RunnerApi}/*/POST/"
1384
+ }
1385
+ }
1386
+ },
1387
+ "RunnerWebAcl": {
1388
+ "Type": "AWS::WAFv2::WebACL",
1389
+ "Condition": "UseWaf",
1390
+ "Properties": {
1391
+ "Name": {
1392
+ "Fn::Sub": "pipeline-builder-runner${NameSuffix}"
1393
+ },
1394
+ "Description": "Pipeline Builder runner API: per-source-IP rate limit (in front of the resource-policy IP allowlist and the stage throttle)",
1395
+ "Scope": "REGIONAL",
1396
+ "DefaultAction": {
1397
+ "Allow": {}
1398
+ },
1399
+ "Rules": [
1400
+ {
1401
+ "Name": "per-ip-rate-limit",
1402
+ "Priority": 0,
1403
+ "Action": {
1404
+ "Block": {}
1405
+ },
1406
+ "Statement": {
1407
+ "RateBasedStatement": {
1408
+ "Limit": {
1409
+ "Ref": "WafRateLimit"
1410
+ },
1411
+ "AggregateKeyType": "IP",
1412
+ "EvaluationWindowSec": 300
1413
+ }
1414
+ },
1415
+ "VisibilityConfig": {
1416
+ "SampledRequestsEnabled": true,
1417
+ "CloudWatchMetricsEnabled": true,
1418
+ "MetricName": {
1419
+ "Fn::Sub": "pipeline-builder-runner${NameSuffix}-rate-limit"
1420
+ }
1421
+ }
1422
+ }
1423
+ ],
1424
+ "VisibilityConfig": {
1425
+ "SampledRequestsEnabled": true,
1426
+ "CloudWatchMetricsEnabled": true,
1427
+ "MetricName": {
1428
+ "Fn::Sub": "pipeline-builder-runner${NameSuffix}"
1429
+ }
1430
+ }
1431
+ }
1432
+ },
1433
+ "RunnerWebAclAssociation": {
1434
+ "Type": "AWS::WAFv2::WebACLAssociation",
1435
+ "Condition": "UseWaf",
1436
+ "Properties": {
1437
+ "ResourceArn": {
1438
+ "Fn::Sub": "arn:${AWS::Partition}:apigateway:${AWS::Region}::/restapis/${RunnerApi}/stages/${RunnerApiStage}"
1439
+ },
1440
+ "WebACLArn": {
1441
+ "Fn::GetAtt": [
1442
+ "RunnerWebAcl",
1443
+ "Arn"
1444
+ ]
1445
+ }
1446
+ }
1447
+ },
1448
+ "EventQueue": {
1449
+ "Type": "AWS::SQS::Queue",
1450
+ "Condition": "ReportingOn",
1451
+ "Properties": {
1452
+ "QueueName": {
1453
+ "Fn::Sub": "pipeline-builder-events${NameSuffix}"
1454
+ },
1455
+ "VisibilityTimeout": 300,
1456
+ "MessageRetentionPeriod": 1209600,
1457
+ "SqsManagedSseEnabled": true,
1458
+ "RedrivePolicy": {
1459
+ "deadLetterTargetArn": {
1460
+ "Fn::GetAtt": [
1461
+ "EventDeadLetterQueue",
1462
+ "Arn"
1463
+ ]
1464
+ },
1465
+ "maxReceiveCount": 3
1466
+ }
1467
+ }
1468
+ },
1469
+ "EventDeadLetterQueue": {
1470
+ "Type": "AWS::SQS::Queue",
1471
+ "Condition": "ReportingOn",
1472
+ "Properties": {
1473
+ "QueueName": {
1474
+ "Fn::Sub": "pipeline-builder-events${NameSuffix}-dlq"
1475
+ },
1476
+ "MessageRetentionPeriod": 1209600,
1477
+ "SqsManagedSseEnabled": true
1478
+ }
1479
+ },
1480
+ "EventQueuePolicy": {
1481
+ "Type": "AWS::SQS::QueuePolicy",
1482
+ "Condition": "ReportingOn",
1483
+ "Properties": {
1484
+ "Queues": [
1485
+ {
1486
+ "Ref": "EventQueue"
1487
+ }
1488
+ ],
1489
+ "PolicyDocument": {
1490
+ "Version": "2012-10-17",
1491
+ "Statement": [
1492
+ {
1493
+ "Sid": "FromTheRule",
1494
+ "Effect": "Allow",
1495
+ "Principal": {
1496
+ "Service": "events.amazonaws.com"
1497
+ },
1498
+ "Action": "sqs:SendMessage",
1499
+ "Resource": {
1500
+ "Fn::GetAtt": [
1501
+ "EventQueue",
1502
+ "Arn"
1503
+ ]
1504
+ },
1505
+ "Condition": {
1506
+ "ArnEquals": {
1507
+ "aws:SourceArn": {
1508
+ "Fn::GetAtt": [
1509
+ "EventRule",
1510
+ "Arn"
1511
+ ]
1512
+ }
1513
+ }
1514
+ }
1515
+ },
1516
+ {
1517
+ "Sid": "TlsOnly",
1518
+ "Effect": "Deny",
1519
+ "Principal": "*",
1520
+ "Action": "sqs:*",
1521
+ "Resource": {
1522
+ "Fn::GetAtt": [
1523
+ "EventQueue",
1524
+ "Arn"
1525
+ ]
1526
+ },
1527
+ "Condition": {
1528
+ "Bool": {
1529
+ "aws:SecureTransport": "false"
1530
+ }
1531
+ }
1532
+ }
1533
+ ]
1534
+ }
1535
+ }
1536
+ },
1537
+ "EventRule": {
1538
+ "Type": "AWS::Events::Rule",
1539
+ "Condition": "ReportingOn",
1540
+ "Properties": {
1541
+ "Name": {
1542
+ "Fn::Sub": "pipeline-builder-events${NameSuffix}"
1543
+ },
1544
+ "Description": "CodePipeline state changes of the allowlisted pipelines (this region's, and the regional forwarders')",
1545
+ "State": "ENABLED",
1546
+ "EventPattern": {
1547
+ "source": [
1548
+ "aws.codepipeline"
1549
+ ],
1550
+ "detail-type": [
1551
+ "CodePipeline Pipeline Execution State Change",
1552
+ "CodePipeline Stage Execution State Change",
1553
+ "CodePipeline Action Execution State Change"
1554
+ ]
1555
+ },
1556
+ "Targets": [
1557
+ {
1558
+ "Id": "pipeline-events-queue",
1559
+ "Arn": {
1560
+ "Fn::GetAtt": [
1561
+ "EventQueue",
1562
+ "Arn"
1563
+ ]
1564
+ }
1565
+ }
1566
+ ]
1567
+ }
1568
+ },
1569
+ "LastEventParameter": {
1570
+ "Type": "AWS::SSM::Parameter",
1571
+ "Condition": "ReportingOn",
1572
+ "Properties": {
1573
+ "Name": {
1574
+ "Fn::Sub": "/pipeline-builder/events${NameSuffix}/last-event"
1575
+ },
1576
+ "Type": "String",
1577
+ "Value": "never",
1578
+ "Description": "When the events Lambda last delivered an event to the platform (ISO time); the runner health ping reports it."
1579
+ }
1580
+ },
1581
+ "EventsRole": {
1582
+ "Type": "AWS::IAM::Role",
1583
+ "Properties": {
1584
+ "RoleName": {
1585
+ "Fn::Sub": "pipeline-builder-events${NameSuffix}"
1586
+ },
1587
+ "AssumeRolePolicyDocument": {
1588
+ "Version": "2012-10-17",
1589
+ "Statement": [
1590
+ {
1591
+ "Effect": "Allow",
1592
+ "Principal": {
1593
+ "Service": "lambda.amazonaws.com"
1594
+ },
1595
+ "Action": "sts:AssumeRole"
1596
+ }
1597
+ ]
1598
+ },
1599
+ "ManagedPolicyArns": [
1600
+ {
1601
+ "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
1602
+ }
1603
+ ],
1604
+ "Policies": [
1605
+ {
1606
+ "PolicyName": "events",
1607
+ "PolicyDocument": {
1608
+ "Statement": [
1609
+ {
1610
+ "Effect": "Allow",
1611
+ "Action": [
1612
+ "sqs:ReceiveMessage",
1613
+ "sqs:DeleteMessage",
1614
+ "sqs:GetQueueAttributes"
1615
+ ],
1616
+ "Resource": {
1617
+ "Fn::GetAtt": [
1618
+ "EventQueue",
1619
+ "Arn"
1620
+ ]
1621
+ }
1622
+ },
1623
+ {
1624
+ "Effect": "Allow",
1625
+ "Action": [
1626
+ "sqs:StartMessageMoveTask",
1627
+ "sqs:ListMessageMoveTasks",
1628
+ "sqs:GetQueueAttributes"
1629
+ ],
1630
+ "Resource": [
1631
+ {
1632
+ "Fn::GetAtt": [
1633
+ "EventQueue",
1634
+ "Arn"
1635
+ ]
1636
+ },
1637
+ {
1638
+ "Fn::GetAtt": [
1639
+ "EventDeadLetterQueue",
1640
+ "Arn"
1641
+ ]
1642
+ }
1643
+ ]
1644
+ },
1645
+ {
1646
+ "Effect": "Allow",
1647
+ "Action": "cloudwatch:GetMetricStatistics",
1648
+ "Resource": "*"
1649
+ },
1650
+ {
1651
+ "Effect": "Allow",
1652
+ "Action": "secretsmanager:GetSecretValue",
1653
+ "Resource": [
1654
+ {
1655
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/${OrgId}/reporting-ingest-*"
1656
+ },
1657
+ {
1658
+ "Fn::If": [
1659
+ "DoraOn",
1660
+ {
1661
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/${OrgId}/github-token-*"
1662
+ },
1663
+ {
1664
+ "Ref": "AWS::NoValue"
1665
+ }
1666
+ ]
1667
+ },
1668
+ {
1669
+ "Fn::If": [
1670
+ "DoraOn",
1671
+ {
1672
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/${OrgId}/github-token/*"
1673
+ },
1674
+ {
1675
+ "Ref": "AWS::NoValue"
1676
+ }
1677
+ ]
1678
+ }
1679
+ ]
1680
+ },
1681
+ {
1682
+ "Sid": "EventPipelineTags",
1683
+ "Effect": "Allow",
1684
+ "Action": "codepipeline:ListTagsForResource",
1685
+ "Resource": {
1686
+ "Fn::Sub": "arn:${AWS::Partition}:codepipeline:${AWS::Region}:${AWS::AccountId}:*"
1687
+ }
1688
+ },
1689
+ {
1690
+ "Sid": "EventBuildFacts",
1691
+ "Effect": "Allow",
1692
+ "Action": "codebuild:BatchGetBuilds",
1693
+ "Resource": {
1694
+ "Fn::Sub": "arn:${AWS::Partition}:codebuild:${AWS::Region}:${AWS::AccountId}:project/*"
1695
+ }
1696
+ },
1697
+ {
1698
+ "Sid": "EventBuildLogs",
1699
+ "Effect": "Allow",
1700
+ "Action": "logs:FilterLogEvents",
1701
+ "Resource": {
1702
+ "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/codebuild/*:*"
1703
+ }
1704
+ },
1705
+ {
1706
+ "Fn::If": [
1707
+ "DoraOn",
1708
+ {
1709
+ "Sid": "EventCommitMeta",
1710
+ "Effect": "Allow",
1711
+ "Action": "codecommit:GetCommit",
1712
+ "Resource": {
1713
+ "Fn::Sub": "arn:${AWS::Partition}:codecommit:${AWS::Region}:${AWS::AccountId}:*"
1714
+ }
1715
+ },
1716
+ {
1717
+ "Ref": "AWS::NoValue"
1718
+ }
1719
+ ]
1720
+ },
1721
+ {
1722
+ "Sid": "StampLastEvent",
1723
+ "Effect": "Allow",
1724
+ "Action": "ssm:PutParameter",
1725
+ "Resource": {
1726
+ "Fn::Sub": "arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/pipeline-builder/events${NameSuffix}/last-event"
1727
+ }
1728
+ }
1729
+ ]
1730
+ }
1731
+ }
1732
+ ],
1733
+ "PermissionsBoundary": {
1734
+ "Fn::If": [
1735
+ "HasPermissionsBoundary",
1736
+ {
1737
+ "Ref": "PermissionsBoundaryArn"
1738
+ },
1739
+ {
1740
+ "Ref": "AWS::NoValue"
1741
+ }
1742
+ ]
1743
+ }
1744
+ },
1745
+ "Condition": "ReportingOn"
1746
+ },
1747
+ "EventsFunction": {
1748
+ "Type": "AWS::Lambda::Function",
1749
+ "Properties": {
1750
+ "FunctionName": {
1751
+ "Fn::Sub": "pipeline-builder-events${NameSuffix}"
1752
+ },
1753
+ "Runtime": "nodejs26.x",
1754
+ "Architectures": [
1755
+ "arm64"
1756
+ ],
1757
+ "Handler": "index.handler",
1758
+ "Code": {
1759
+ "ZipFile": "exports.handler=async()=>{throw new Error('Placeholder — pipeline-manager infra setup-account uploads the events handler')}"
1760
+ },
1761
+ "Role": {
1762
+ "Fn::GetAtt": [
1763
+ "EventsRole",
1764
+ "Arn"
1765
+ ]
1766
+ },
1767
+ "Timeout": 60,
1768
+ "MemorySize": 256,
1769
+ "Environment": {
1770
+ "Variables": {
1771
+ "PLATFORM_BASE_URL": {
1772
+ "Ref": "PlatformBaseUrl"
1773
+ },
1774
+ "PLATFORM_SECRET_NAME": {
1775
+ "Ref": "ReportingSecretName"
1776
+ },
1777
+ "DORA_ENABLED": {
1778
+ "Ref": "DoraEnabled"
1779
+ },
1780
+ "EVENT_DLQ_ARN": {
1781
+ "Fn::GetAtt": [
1782
+ "EventDeadLetterQueue",
1783
+ "Arn"
1784
+ ]
1785
+ },
1786
+ "LAST_EVENT_PARAMETER": {
1787
+ "Ref": "LastEventParameter"
1788
+ }
1789
+ }
1790
+ },
1791
+ "ReservedConcurrentExecutions": 5
1792
+ },
1793
+ "Condition": "ReportingOn"
1794
+ },
1795
+ "EventSourceMapping": {
1796
+ "Type": "AWS::Lambda::EventSourceMapping",
1797
+ "Properties": {
1798
+ "EventSourceArn": {
1799
+ "Fn::GetAtt": [
1800
+ "EventQueue",
1801
+ "Arn"
1802
+ ]
1803
+ },
1804
+ "FunctionName": {
1805
+ "Ref": "EventsFunction"
1806
+ },
1807
+ "BatchSize": 10,
1808
+ "MaximumBatchingWindowInSeconds": 5,
1809
+ "Enabled": true,
1810
+ "FunctionResponseTypes": [
1811
+ "ReportBatchItemFailures"
1812
+ ]
1813
+ },
1814
+ "Condition": "ReportingOn"
1815
+ },
1816
+ "EventsLogGroup": {
1817
+ "Type": "AWS::Logs::LogGroup",
1818
+ "Condition": "ReportingOn",
1819
+ "Properties": {
1820
+ "LogGroupName": {
1821
+ "Fn::Sub": "/aws/lambda/pipeline-builder-events${NameSuffix}"
1822
+ },
1823
+ "RetentionInDays": 30
1824
+ }
1825
+ },
1826
+ "RenewRole": {
1827
+ "Type": "AWS::IAM::Role",
1828
+ "Properties": {
1829
+ "RoleName": {
1830
+ "Fn::Sub": "pipeline-builder-renew${NameSuffix}"
1831
+ },
1832
+ "AssumeRolePolicyDocument": {
1833
+ "Version": "2012-10-17",
1834
+ "Statement": [
1835
+ {
1836
+ "Effect": "Allow",
1837
+ "Principal": {
1838
+ "Service": "lambda.amazonaws.com"
1839
+ },
1840
+ "Action": "sts:AssumeRole"
1841
+ }
1842
+ ]
1843
+ },
1844
+ "ManagedPolicyArns": [
1845
+ {
1846
+ "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
1847
+ }
1848
+ ],
1849
+ "Policies": [
1850
+ {
1851
+ "PolicyName": "renew",
1852
+ "PolicyDocument": {
1853
+ "Statement": [
1854
+ {
1855
+ "Effect": "Allow",
1856
+ "Action": [
1857
+ "secretsmanager:GetSecretValue",
1858
+ "secretsmanager:PutSecretValue",
1859
+ "secretsmanager:DescribeSecret"
1860
+ ],
1861
+ "Resource": {
1862
+ "Fn::Sub": "arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pipeline-builder/${OrgId}/*"
1863
+ }
1864
+ }
1865
+ ]
1866
+ }
1867
+ }
1868
+ ],
1869
+ "PermissionsBoundary": {
1870
+ "Fn::If": [
1871
+ "HasPermissionsBoundary",
1872
+ {
1873
+ "Ref": "PermissionsBoundaryArn"
1874
+ },
1875
+ {
1876
+ "Ref": "AWS::NoValue"
1877
+ }
1878
+ ]
1879
+ }
1880
+ },
1881
+ "Condition": "RenewOn"
1882
+ },
1883
+ "RenewFunction": {
1884
+ "Type": "AWS::Lambda::Function",
1885
+ "Properties": {
1886
+ "FunctionName": {
1887
+ "Fn::Sub": "pipeline-builder-renew${NameSuffix}"
1888
+ },
1889
+ "Runtime": "nodejs26.x",
1890
+ "Architectures": [
1891
+ "arm64"
1892
+ ],
1893
+ "Handler": "index.handler",
1894
+ "Code": {
1895
+ "ZipFile": "exports.handler=async()=>{throw new Error('Placeholder — pipeline-manager infra setup-account uploads the key renewal')}"
1896
+ },
1897
+ "Role": {
1898
+ "Fn::GetAtt": [
1899
+ "RenewRole",
1900
+ "Arn"
1901
+ ]
1902
+ },
1903
+ "Timeout": 60,
1904
+ "MemorySize": 256,
1905
+ "Environment": {
1906
+ "Variables": {
1907
+ "PLATFORM_SECRET_NAMES": {
1908
+ "Ref": "RenewSecretNames"
1909
+ },
1910
+ "KEY_TTL_DAYS": {
1911
+ "Ref": "KeyLifetimeDays"
1912
+ },
1913
+ "PIPELINE_MANAGER_VERSION": {
1914
+ "Ref": "PipelineManagerVersion"
1915
+ },
1916
+ "NODE_ENV": "production"
1917
+ }
1918
+ }
1919
+ },
1920
+ "Condition": "RenewOn"
1921
+ },
1922
+ "RenewScheduleRule": {
1923
+ "Type": "AWS::Events::Rule",
1924
+ "Properties": {
1925
+ "Name": {
1926
+ "Fn::Sub": "pipeline-builder-renew${NameSuffix}"
1927
+ },
1928
+ "Description": "Scheduled service-account key rotation",
1929
+ "State": "ENABLED",
1930
+ "ScheduleExpression": {
1931
+ "Ref": "RenewSchedule"
1932
+ },
1933
+ "Targets": [
1934
+ {
1935
+ "Id": "renew-lambda",
1936
+ "Arn": {
1937
+ "Fn::GetAtt": [
1938
+ "RenewFunction",
1939
+ "Arn"
1940
+ ]
1941
+ }
1942
+ }
1943
+ ]
1944
+ },
1945
+ "Condition": "RenewOn"
1946
+ },
1947
+ "RenewInvokePermission": {
1948
+ "Type": "AWS::Lambda::Permission",
1949
+ "Properties": {
1950
+ "FunctionName": {
1951
+ "Ref": "RenewFunction"
1952
+ },
1953
+ "Action": "lambda:InvokeFunction",
1954
+ "Principal": "events.amazonaws.com",
1955
+ "SourceArn": {
1956
+ "Fn::GetAtt": [
1957
+ "RenewScheduleRule",
1958
+ "Arn"
1959
+ ]
1960
+ }
1961
+ },
1962
+ "Condition": "RenewOn"
1963
+ },
1964
+ "RenewLogGroup": {
1965
+ "Type": "AWS::Logs::LogGroup",
1966
+ "Condition": "RenewOn",
1967
+ "Properties": {
1968
+ "LogGroupName": {
1969
+ "Fn::Sub": "/aws/lambda/pipeline-builder-renew${NameSuffix}"
1970
+ },
1971
+ "RetentionInDays": 30
1972
+ }
1973
+ }
1974
+ },
1975
+ "Outputs": {
1976
+ "FunctionName": {
1977
+ "Value": {
1978
+ "Ref": "RunnerFunction"
1979
+ },
1980
+ "Condition": "RunnerOn"
1981
+ },
1982
+ "RunnerId": {
1983
+ "Value": {
1984
+ "Ref": "RunnerId"
1985
+ },
1986
+ "Condition": "RunnerOn"
1987
+ },
1988
+ "EndpointUrl": {
1989
+ "Description": "Where the platform delivers run requests. Treat as a secret: never log it.",
1990
+ "Value": {
1991
+ "Fn::If": [
1992
+ "UseFunctionUrl",
1993
+ {
1994
+ "Fn::GetAtt": [
1995
+ "FunctionUrl",
1996
+ "FunctionUrl"
1997
+ ]
1998
+ },
1999
+ {
2000
+ "Fn::Sub": "https://${RunnerApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/runner/"
2001
+ }
2002
+ ]
2003
+ },
2004
+ "Condition": "RunnerOn"
2005
+ },
2006
+ "EventsFunctionName": {
2007
+ "Condition": "ReportingOn",
2008
+ "Value": {
2009
+ "Ref": "EventsFunction"
2010
+ }
2011
+ },
2012
+ "EventQueueUrl": {
2013
+ "Condition": "ReportingOn",
2014
+ "Value": {
2015
+ "Ref": "EventQueue"
2016
+ }
2017
+ },
2018
+ "EventDeadLetterQueueUrl": {
2019
+ "Condition": "ReportingOn",
2020
+ "Value": {
2021
+ "Ref": "EventDeadLetterQueue"
2022
+ }
2023
+ },
2024
+ "RenewFunctionName": {
2025
+ "Condition": "RenewOn",
2026
+ "Value": {
2027
+ "Ref": "RenewFunction"
2028
+ }
2029
+ }
2030
+ },
2031
+ "Rules": {
2032
+ "RunnerNeedsItsId": {
2033
+ "RuleCondition": {
2034
+ "Fn::Equals": [
2035
+ {
2036
+ "Ref": "EnableRunner"
2037
+ },
2038
+ "true"
2039
+ ]
2040
+ },
2041
+ "Assertions": [
2042
+ {
2043
+ "Assert": {
2044
+ "Fn::Not": [
2045
+ {
2046
+ "Fn::Equals": [
2047
+ {
2048
+ "Ref": "RunnerId"
2049
+ },
2050
+ ""
2051
+ ]
2052
+ }
2053
+ ]
2054
+ },
2055
+ "AssertDescription": "A stack with the runner (EnableRunner=true) is always bound to the connector it was registered as: RunnerId is required."
2056
+ }
2057
+ ]
2058
+ }
2059
+ }
2060
+ }