CloudSnorkel / cdk-github-runners

CDK constructs for self-hosted GitHub Actions runners
https://constructs.dev/packages/@cloudsnorkel/cdk-github-runners/
Apache License 2.0
255 stars 37 forks source link

Missing AL2023 support in a few places #531

Closed wash-amzn closed 1 month ago

wash-amzn commented 1 month ago

The below is with regard to version 0.12.4 and I am using Ec2RunnerProvider.

I ran into a few problems using Os.LINUX_AMAZON_2023. Really simple stuff, but they prevented synthesis if I wanted to use this OS.

The simple diff below resolved the issue for me:

diff --git a/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/ami.js b/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/ami.js
index 8b66c06..6eb9bfd 100644
--- a/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/ami.js
+++ b/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/ami.js
@@ -79,6 +79,14 @@ function defaultBaseAmi(scope, os, architecture) {
             resourceName: `amazon-linux-2-${arch}/x.x.x`,
         });
     }
+    if (os.is(providers_1.Os.LINUX_AMAZON_2023)) {
+        return stack.formatArn({
+            service: 'imagebuilder',
+            resource: 'image',
+            account: 'aws',
+            resourceName: `amazon-linux-2023-${arch}/x.x.x`,
+        });
+    }
     if (os.is(providers_1.Os.WINDOWS)) {
         return stack.formatArn({
             service: 'imagebuilder',
diff --git a/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/builder.js b/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/builder.js
index 2970556..4610b79 100644
--- a/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/builder.js
+++ b/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/builder.js
@@ -193,7 +193,7 @@ class AwsImageBuilderRunnerImageBuilder extends common_2.RunnerImageBuilderBase
         if (this.os.is(providers_1.Os.WINDOWS)) {
             return 'Windows';
         }
-        if (this.os.is(providers_1.Os.LINUX_AMAZON_2) || this.os.is(providers_1.Os.LINUX_UBUNTU)) {
+        if (this.os.is(providers_1.Os.LINUX_AMAZON_2) || this.os.is(providers_1.Os.LINUX_AMAZON_2023) || this.os.is(providers_1.Os.LINUX_UBUNTU)) {
             return 'Linux';
         }
         throw new Error(`OS ${this.os.name} is not supported by AWS Image Builder`);
diff --git a/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/container.js b/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/container.js
index 18bdff2..b31163e 100644
--- a/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/container.js
+++ b/node_modules/@cloudsnorkel/cdk-github-runners/lib/image-builders/aws-image-builder/container.js
@@ -55,6 +55,9 @@ function defaultBaseDockerImage(os) {
     else if (os.is(providers_1.Os.LINUX_AMAZON_2)) {
         return 'public.ecr.aws/amazonlinux/amazonlinux:2';
     }
+    else if (os.is(providers_1.Os.LINUX_AMAZON_2023)) {
+        return 'public.ecr.aws/amazonlinux/amazonlinux:2023';
+    }
     else {
         throw new Error(`OS ${os.name} not supported for Docker runner image`);
     }