cloudsnorkel.cdk-github-runners 0.14.15__py3-none-any.whl → 0.14.21__py3-none-any.whl

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.
@@ -33,9 +33,9 @@ import constructs._jsii
33
33
 
34
34
  __jsii_assembly__ = jsii.JSIIAssembly.load(
35
35
  "@cloudsnorkel/cdk-github-runners",
36
- "0.14.15",
36
+ "0.14.21",
37
37
  __name__[0:-6],
38
- "cdk-github-runners@0.14.15.jsii.tgz",
38
+ "cdk-github-runners@0.14.21.jsii.tgz",
39
39
  )
40
40
 
41
41
  __all__ = [
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloudsnorkel.cdk-github-runners
3
- Version: 0.14.15
3
+ Version: 0.14.21
4
4
  Summary: CDK construct to create GitHub Actions self-hosted runners. Creates ephemeral runners on demand. Easy to deploy and highly customizable.
5
5
  Home-page: https://github.com/CloudSnorkel/cdk-github-runners.git
6
6
  Author: Amir Szekely<amir@cloudsnorkel.com>
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
22
  Requires-Dist: aws-cdk-lib <3.0.0,>=2.155.0
23
23
  Requires-Dist: constructs <11.0.0,>=10.0.5
24
- Requires-Dist: jsii <2.0.0,>=1.120.0
24
+ Requires-Dist: jsii <2.0.0,>=1.124.0
25
25
  Requires-Dist: publication >=0.0.3
26
26
  Requires-Dist: typeguard ==2.13.3
27
27
 
@@ -350,11 +350,197 @@ new GitHubRunners(this, 'runners', {
350
350
  });
351
351
  ```
352
352
 
353
+ ### Composite Providers
354
+
355
+ Composite providers allow you to combine multiple runner providers with different strategies. There are two types:
356
+
357
+ **Fallback Strategy**: Try providers in order until one succeeds. Useful for trying spot instances first, then falling back to on-demand if spot capacity is unavailable.
358
+
359
+ ```python
360
+ // Try spot instances first, fall back to on-demand if spot is unavailable
361
+ const ecsFallback = CompositeProvider.fallback(this, 'ECS Fallback', [
362
+ new EcsRunnerProvider(this, 'ECS Spot', {
363
+ labels: ['ecs', 'linux', 'x64'],
364
+ spot: true,
365
+ // ... other config
366
+ }),
367
+ new EcsRunnerProvider(this, 'ECS On-Demand', {
368
+ labels: ['ecs', 'linux', 'x64'],
369
+ spot: false,
370
+ // ... other config
371
+ }),
372
+ ]);
373
+
374
+ new GitHubRunners(this, 'runners', {
375
+ providers: [ecsFallback],
376
+ });
377
+ ```
378
+
379
+ **Weighted Distribution Strategy**: Randomly select a provider based on weights. Useful for distributing load across multiple availability zones or instance types.
380
+
381
+ ```python
382
+ // Distribute 60% of traffic to AZ-1, 40% to AZ-2
383
+ const distributedProvider = CompositeProvider.distribute(this, 'Fargate Distribution', [
384
+ {
385
+ weight: 3, // 3/(3+2) = 60%
386
+ provider: new FargateRunnerProvider(this, 'Fargate AZ-1', {
387
+ labels: ['fargate', 'linux', 'x64'],
388
+ subnetSelection: vpc.selectSubnets({
389
+ availabilityZones: [vpc.availabilityZones[0]],
390
+ }),
391
+ // ... other config
392
+ }),
393
+ },
394
+ {
395
+ weight: 2, // 2/(3+2) = 40%
396
+ provider: new FargateRunnerProvider(this, 'Fargate AZ-2', {
397
+ labels: ['fargate', 'linux', 'x64'],
398
+ subnetSelection: vpc.selectSubnets({
399
+ availabilityZones: [vpc.availabilityZones[1]],
400
+ }),
401
+ // ... other config
402
+ }),
403
+ },
404
+ ]);
405
+
406
+ new GitHubRunners(this, 'runners', {
407
+ providers: [distributedProvider],
408
+ });
409
+ ```
410
+
411
+ **Important**: All providers in a composite must have the exact same labels. This ensures any provisioned runner can match the labels requested by the GitHub workflow job.
412
+
413
+ ### Custom Provider Selection
414
+
415
+ By default, providers are selected based on label matching: the first provider that has all the labels requested by the job is selected. You can customize this behavior using a provider selector Lambda function to:
416
+
417
+ * Filter out certain jobs (prevent runner provisioning)
418
+ * Dynamically select a provider based on job characteristics (repository, branch, time of day, etc.)
419
+ * Customize labels for the runner (add, remove, or modify labels dynamically)
420
+
421
+ The selector function receives the full GitHub webhook payload, a map of all available providers and their labels, and the default provider/labels that would have been selected. It returns the provider to use (or `undefined` to skip runner creation) and the labels to assign to the runner.
422
+
423
+ **Example: Route jobs to different providers based on repository**
424
+
425
+ ```python
426
+ import { ComputeType } from 'aws-cdk-lib/aws-codebuild';
427
+ import { Function, Code, Runtime } from 'aws-cdk-lib/aws-lambda';
428
+ import { GitHubRunners, CodeBuildRunnerProvider } from '@cloudsnorkel/cdk-github-runners';
429
+
430
+ const defaultProvider = new CodeBuildRunnerProvider(this, 'default', {
431
+ labels: ['custom-runner', 'default'],
432
+ });
433
+ const productionProvider = new CodeBuildRunnerProvider(this, 'production', {
434
+ labels: ['custom-runner', 'production'],
435
+ computeType: ComputeType.LARGE,
436
+ });
437
+
438
+ const providerSelector = new Function(this, 'provider-selector', {
439
+ runtime: Runtime.NODEJS_LATEST,
440
+ handler: 'index.handler',
441
+ code: Code.fromInline(`
442
+ exports.handler = async (event) => {
443
+ const { payload, providers, defaultProvider, defaultLabels } = event;
444
+
445
+ // Route production repos to dedicated provider
446
+ if (payload.repository.name.includes('prod')) {
447
+ return {
448
+ provider: '${productionProvider.node.path}',
449
+ labels: ['custom-runner', 'production', 'modified-via-selector'],
450
+ };
451
+ }
452
+
453
+ // Filter out draft PRs
454
+ if (payload.workflow_job.head_branch?.startsWith('draft/')) {
455
+ return { provider: undefined }; // Skip runner provisioning
456
+ }
457
+
458
+ // Use default for everything else
459
+ return {
460
+ provider: defaultProvider,
461
+ labels: defaultLabels,
462
+ };
463
+ };
464
+ `),
465
+ });
466
+
467
+ new GitHubRunners(this, 'runners', {
468
+ providers: [defaultProvider, productionProvider],
469
+ providerSelector: providerSelector,
470
+ });
471
+ ```
472
+
473
+ **Example: Add dynamic labels based on job metadata**
474
+
475
+ ```python
476
+ const providerSelector = new Function(this, 'provider-selector', {
477
+ runtime: Runtime.NODEJS_LATEST,
478
+ handler: 'index.handler',
479
+ code: Code.fromInline(`
480
+ exports.handler = async (event) => {
481
+ const { payload, defaultProvider, defaultLabels } = event;
482
+
483
+ // Add branch name as a label
484
+ const branch = payload.workflow_job.head_branch || 'unknown';
485
+ const labels = [...(defaultLabels || []), 'branch:' + branch];
486
+
487
+ return {
488
+ provider: defaultProvider,
489
+ labels: labels,
490
+ };
491
+ };
492
+ `),
493
+ });
494
+ ```
495
+
496
+ **Important considerations:**
497
+
498
+ * ⚠️ **Label matching responsibility**: You are responsible for ensuring the selected provider's labels match what the job requires. If labels don't match, the runner will be provisioned but GitHub Actions won't assign the job to it.
499
+ * ⚠️ **No guarantee of assignment**: Provider selection only determines which provider will provision a runner. GitHub Actions may still route the job to any available runner with matching labels. For reliable provider assignment, consider repo-level runner registration (the default).
500
+ * ⚡ **Performance**: The selector runs synchronously during webhook processing. Keep it fast and efficient—the webhook has a 30-second timeout total.
501
+
353
502
  ## Examples
354
503
 
355
- Beyond the code snippets above, the fullest example available is the [integration test](test/default.integ.ts).
504
+ We provide comprehensive examples in the [`examples/`](examples/) folder to help you get started quickly:
505
+
506
+ ### Getting Started
507
+
508
+ * **[Simple CodeBuild](examples/typescript/simple-codebuild/)** - Basic setup with just a CodeBuild provider (also available in [Python](examples/python/simple-codebuild/))
509
+
510
+ ### Provider Configuration
511
+
512
+ * **[Composite Provider](examples/typescript/composite-provider/)** - Fallback and weighted distribution strategies (also available in [Python](examples/python/composite-provider/))
513
+ * **[Provider Selector](examples/typescript/provider-selector/)** - Custom provider selection with Lambda function (also available in [Python](examples/python/provider-selector/))
514
+ * **[EC2 Windows Provider](examples/typescript/ec2-windows-provider/)** - EC2 configuration for Windows runners (also available in [Python](examples/python/ec2-windows-provider/))
515
+ * **[Split Stacks](examples/typescript/split-stacks/)** - Split image builders and providers across multiple stacks (also available in [Python](examples/python/split-stacks/))
516
+
517
+ ### Compute & Performance
518
+
519
+ * **[Compute Options](examples/typescript/compute-options/)** - Configure CPU, memory, and instance types for different providers (also available in [Python](examples/python/compute-options/))
520
+ * **[Spot Instances](examples/typescript/spot-instances/)** - Use spot instances for cost savings across EC2, Fargate, and ECS (also available in [Python](examples/python/spot-instances/))
521
+ * **[Storage Options](examples/typescript/storage-options/)** - Custom EBS storage options for EC2 runners (also available in [Python](examples/python/storage-options/))
522
+ * **[ECS Scaling](examples/typescript/ecs-scaling/)** - Custom autoscaling group scaling policies for ECS providers (also available in [Python](examples/python/ecs-scaling/))
523
+
524
+ ### Security & Access
525
+
526
+ * **[IAM Permissions](examples/typescript/iam-permissions/)** - Grant AWS IAM permissions to runners (also available in [Python](examples/python/iam-permissions/))
527
+ * **[Network Access](examples/typescript/network-access/)** - Configure network access with VPCs and security groups (also available in [Python](examples/python/network-access/))
528
+ * **[Access Control](examples/typescript/access-control/)** - Configure access control for webhook and setup functions (also available in [Python](examples/python/access-control/))
529
+
530
+ ### Customization
531
+
532
+ * **[Add Software](examples/typescript/add-software/)** - Add custom software to runner images (also available in [Python](examples/python/add-software/))
533
+
534
+ ### Enterprise & Monitoring
535
+
536
+ * **[GHES](examples/typescript/ghes/)** - Configure runners for GitHub Enterprise Server (also available in [Python](examples/python/ghes/))
537
+ * **[Monitoring](examples/typescript/monitoring/)** - Set up CloudWatch alarms and SNS notifications (also available in [Python](examples/python/monitoring/))
538
+
539
+ Each example is self-contained with its own dependencies and README. Start with the simple examples and work your way up to more advanced configurations.
540
+
541
+ Another good and very full example is the [integration test](test/default.integ.ts).
356
542
 
357
- If you have more to share, please open a PR adding them to the `examples` folder.
543
+ If you have more to share, please open a PR adding examples to the `examples` folder.
358
544
 
359
545
  ## Architecture
360
546
 
@@ -416,5 +602,5 @@ If you use and love this project, please consider contributing.
416
602
 
417
603
  ## Other Options
418
604
 
419
- 1. [philips-labs/terraform-aws-github-runner](https://github.com/philips-labs/terraform-aws-github-runner) if you're using Terraform
605
+ 1. [github-aws-runners/terraform-aws-github-runner](https://github.com/github-aws-runners/terraform-aws-github-runner) if you're using Terraform
420
606
  2. [actions/actions-runner-controller](https://github.com/actions/actions-runner-controller) if you're using Kubernetes
@@ -0,0 +1,9 @@
1
+ cloudsnorkel/cdk_github_runners/__init__.py,sha256=s1fznhel_1kk511FJpaBgdRcIOCjSBcPTBIurf8jpLY,723479
2
+ cloudsnorkel/cdk_github_runners/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
+ cloudsnorkel/cdk_github_runners/_jsii/__init__.py,sha256=Issv_0CyOVxbrDxZPKJDbEOIlAQQjvOIlX_X5iZ6f-w,1478
4
+ cloudsnorkel/cdk_github_runners/_jsii/cdk-github-runners@0.14.21.jsii.tgz,sha256=IZk85poW8I6RVt3sJSIvAhZipU0UCbZ_2LiP58OtxPw,905901
5
+ cloudsnorkel_cdk_github_runners-0.14.21.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
6
+ cloudsnorkel_cdk_github_runners-0.14.21.dist-info/METADATA,sha256=SkYg5enDirOGPBfTOw1Cy3ck_2-omYMzbneSHFbE-wk,26442
7
+ cloudsnorkel_cdk_github_runners-0.14.21.dist-info/WHEEL,sha256=WnJ8fYhv8N4SYVK2lLYNI6N0kVATA7b0piVUNvqIIJE,91
8
+ cloudsnorkel_cdk_github_runners-0.14.21.dist-info/top_level.txt,sha256=6vUrT-dcGOiRMT4Q6gEQPznoyS7nHOJ269MHpo4DEd8,13
9
+ cloudsnorkel_cdk_github_runners-0.14.21.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.2)
2
+ Generator: setuptools (75.3.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- cloudsnorkel/cdk_github_runners/__init__.py,sha256=lt48SFAM2lBqZtBrmeMBqVC_mVUWIRnGj2a9ImPZFok,644017
2
- cloudsnorkel/cdk_github_runners/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
- cloudsnorkel/cdk_github_runners/_jsii/__init__.py,sha256=GgTHeJjfy3W99X2Xpd9vCouQShyHTb7SXdiu-ujkonY,1478
4
- cloudsnorkel/cdk_github_runners/_jsii/cdk-github-runners@0.14.15.jsii.tgz,sha256=c5nXenc2JZsl0J6m4l5nawQs3WxhGMi2SO91I6vyjgU,1629062
5
- cloudsnorkel_cdk_github_runners-0.14.15.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
6
- cloudsnorkel_cdk_github_runners-0.14.15.dist-info/METADATA,sha256=OTf79TdAl1kCMejyzSCbvJlAFp-RnIXJeV10C0o6Opg,17808
7
- cloudsnorkel_cdk_github_runners-0.14.15.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
8
- cloudsnorkel_cdk_github_runners-0.14.15.dist-info/top_level.txt,sha256=6vUrT-dcGOiRMT4Q6gEQPznoyS7nHOJ269MHpo4DEd8,13
9
- cloudsnorkel_cdk_github_runners-0.14.15.dist-info/RECORD,,