cdk-github-runner-switch 0.1.1 → 0.2.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/README.md CHANGED
@@ -102,6 +102,7 @@ To flip the switch by hand: `gh variable set RUNNER --body aws` (or `github`).
102
102
  | `nodeMajorVersion` | `24` | Node.js installed in the image. |
103
103
  | `cachedImages` | `[]` | Container images pulled into the AMI, for faster `services:`. |
104
104
  | `extraImageCommands` | `[]` | Extra setup, e.g. `npx -y playwright install-deps chromium`. |
105
+ | `secret` | new secret | Reuse an existing secret with `webhookSecret`, `appId` and `privateKey` (e.g. when migrating). |
105
106
  | `imageSchedule` | monthly (day 1, 05:00 UTC) | EventBridge cron for the image rebuild. |
106
107
  | `reconcileInterval` / `usageCheckInterval` | 5 min / 30 min | |
107
108
 
@@ -45,6 +45,11 @@ export interface GitHubRunnerSwitchProps {
45
45
  readonly extraImageCommands?: string[];
46
46
  /** When the image is rebuilt (EventBridge cron, UTC). @default 'cron(0 5 1 * ? *)' — monthly, day 1 at 05:00 */
47
47
  readonly imageSchedule?: string;
48
+ /**
49
+ * Existing secret with `webhookSecret`, `appId` and `privateKey` (and `billingToken` for personal accounts), e.g. when
50
+ * migrating an existing setup. @default - a new secret with a generated `webhookSecret`
51
+ */
52
+ readonly secret?: secretsmanager.ISecret;
48
53
  /** @default Duration.minutes(5) */
49
54
  readonly reconcileInterval?: Duration;
50
55
  /** @default Duration.minutes(30) */
@@ -149,7 +149,7 @@ class GitHubRunnerSwitch extends constructs_1.Construct {
149
149
  });
150
150
  this.imagePipelineArn = pipeline.attrArn;
151
151
  // GitHub App credentials: the webhook secret is generated here; the setup script adds appId and privateKey.
152
- const secret = new secretsmanager.Secret(this, 'AppSecret', {
152
+ const secret = props.secret ?? new secretsmanager.Secret(this, 'AppSecret', {
153
153
  description: `GitHub App of the runners for ${props.repository} (cdk-github-runner-switch)`,
154
154
  generateSecretString: {
155
155
  secretStringTemplate: JSON.stringify({ appId: '', privateKey: '' }),
@@ -167,7 +167,8 @@ class GitHubRunnerSwitch extends constructs_1.Construct {
167
167
  logGroup: new logs.LogGroup(this, 'ControlLogs', { retention: logs.RetentionDays.ONE_MONTH, removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY }),
168
168
  description: `GitHub runner switch for ${props.repository}: webhook, reconciliation and minutes check`,
169
169
  environment: {
170
- SECRET_ID: secret.secretArn,
170
+ // An imported secret is read by name: its grant covers the full ARN (with the random suffix), not a partial ARN.
171
+ SECRET_ID: props.secret ? props.secret.secretName : secret.secretArn,
171
172
  REPOSITORY: props.repository,
172
173
  BILLING: props.billing ?? BillingScope.ORGANIZATION,
173
174
  LABEL: label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdk-github-runner-switch",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "AWS CDK construct: GitHub Actions runners that switch from GitHub-hosted free minutes to disposable EC2 Spot (Graviton) machines when the monthly minutes run out — and back when the month resets.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "uarch-solutions",