All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider Maven / Gradle / Ivy

Go to download

CDK construct to create GitHub Actions self-hosted runners. A webhook listens to events and creates ephemeral runners on the fly.

There is a newer version: 0.14.6
Show newest version
package com.cloudsnorkel.cdk.github.runners;

/**
 * (experimental) GitHub Actions runner provider using ECS on EC2 to execute jobs.
 * 

* ECS can be useful when you want more control of the infrastructure running the GitHub Actions Docker containers. You can control the autoscaling * group to scale down to zero during the night and scale up during work hours. This way you can still save money, but have to wait less for * infrastructure to spin up. *

* This construct is not meant to be used by itself. It should be passed in the providers property for GitHubRunners. */ @javax.annotation.Generated(value = "jsii-pacmak/1.103.1 (build bef2dea)", date = "2024-09-14T02:42:19.412Z") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @software.amazon.jsii.Jsii(module = com.cloudsnorkel.cdk.github.runners.$Module.class, fqn = "@cloudsnorkel/cdk-github-runners.EcsRunnerProvider") public class EcsRunnerProvider extends software.constructs.Construct implements com.cloudsnorkel.cdk.github.runners.IRunnerProvider { protected EcsRunnerProvider(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected EcsRunnerProvider(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { super(initializationMode); } /** * @param scope This parameter is required. * @param id This parameter is required. * @param props */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public EcsRunnerProvider(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.Nullable com.cloudsnorkel.cdk.github.runners.EcsRunnerProviderProps props) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), props }); } /** * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public EcsRunnerProvider(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required") }); } /** * (experimental) Create new image builder that builds ECS specific runner images. *

* You can customize the OS, architecture, VPC, subnet, security groups, etc. by passing in props. *

* You can add components to the image builder by calling imageBuilder.addComponent(). *

* The default OS is Ubuntu running on x64 architecture. *

* Included components: *

*

    *
  • RunnerImageComponent.requiredPackages()
  • *
  • RunnerImageComponent.runnerUser()
  • *
  • RunnerImageComponent.git()
  • *
  • RunnerImageComponent.githubCli()
  • *
  • RunnerImageComponent.awsCli()
  • *
  • RunnerImageComponent.docker()
  • *
  • RunnerImageComponent.githubRunner()
  • *
*

* @param scope This parameter is required. * @param id This parameter is required. * @param props */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.IConfigurableRunnerImageBuilder imageBuilder(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.Nullable com.cloudsnorkel.cdk.github.runners.RunnerImageBuilderProps props) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider.class, "imageBuilder", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.IConfigurableRunnerImageBuilder.class), new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), props }); } /** * (experimental) Create new image builder that builds ECS specific runner images. *

* You can customize the OS, architecture, VPC, subnet, security groups, etc. by passing in props. *

* You can add components to the image builder by calling imageBuilder.addComponent(). *

* The default OS is Ubuntu running on x64 architecture. *

* Included components: *

*

    *
  • RunnerImageComponent.requiredPackages()
  • *
  • RunnerImageComponent.runnerUser()
  • *
  • RunnerImageComponent.git()
  • *
  • RunnerImageComponent.githubCli()
  • *
  • RunnerImageComponent.awsCli()
  • *
  • RunnerImageComponent.docker()
  • *
  • RunnerImageComponent.githubRunner()
  • *
*

* @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.IConfigurableRunnerImageBuilder imageBuilder(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id) { return software.amazon.jsii.JsiiObject.jsiiStaticCall(com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider.class, "imageBuilder", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.IConfigurableRunnerImageBuilder.class), new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required") }); } /** * (experimental) Generate step function task(s) to start a new runner. *

* Called by GithubRunners and shouldn't be called manually. *

* @param parameters workflow job details. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.stepfunctions.IChainable getStepFunctionTask(final @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.RunnerRuntimeParameters parameters) { return software.amazon.jsii.Kernel.call(this, "getStepFunctionTask", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.stepfunctions.IChainable.class), new Object[] { java.util.Objects.requireNonNull(parameters, "parameters is required") }); } /** * (experimental) An optional method that modifies the role of the state machine after all the tasks have been generated. *

* This can be used to add additional policy * statements to the state machine role that are not automatically added by the task returned from {@link getStepFunctionTask}. *

* @param _ This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public void grantStateMachine(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iam.IGrantable __) { software.amazon.jsii.Kernel.call(this, "grantStateMachine", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(__, "__ is required") }); } /** * @param defaultLabel This parameter is required. * @param propsLabel * @param propsLabels */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull java.util.List labelsFromProperties(final @org.jetbrains.annotations.NotNull java.lang.String defaultLabel, final @org.jetbrains.annotations.Nullable java.lang.String propsLabel, final @org.jetbrains.annotations.Nullable java.util.List propsLabels) { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.call(this, "labelsFromProperties", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)), new Object[] { java.util.Objects.requireNonNull(defaultLabel, "defaultLabel is required"), propsLabel, propsLabels })); } /** * @param defaultLabel This parameter is required. * @param propsLabel */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull java.util.List labelsFromProperties(final @org.jetbrains.annotations.NotNull java.lang.String defaultLabel, final @org.jetbrains.annotations.Nullable java.lang.String propsLabel) { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.call(this, "labelsFromProperties", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)), new Object[] { java.util.Objects.requireNonNull(defaultLabel, "defaultLabel is required"), propsLabel })); } /** * @param defaultLabel This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull java.util.List labelsFromProperties(final @org.jetbrains.annotations.NotNull java.lang.String defaultLabel) { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.call(this, "labelsFromProperties", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)), new Object[] { java.util.Objects.requireNonNull(defaultLabel, "defaultLabel is required") })); } /** * (experimental) Return status of the runner provider to be used in the main status function. *

* Also gives the status function any needed permissions to query the Docker image or AMI. *

* @param statusFunctionRole This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.IRunnerProviderStatus status(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iam.IGrantable statusFunctionRole) { return software.amazon.jsii.Kernel.call(this, "status", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.IRunnerProviderStatus.class), new Object[] { java.util.Objects.requireNonNull(statusFunctionRole, "statusFunctionRole is required") }); } /** * (experimental) The network connections associated with this resource. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ec2.Connections getConnections() { return software.amazon.jsii.Kernel.get(this, "connections", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.Connections.class)); } /** * (experimental) Grant principal used to add permissions to the runner role. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.iam.IPrincipal getGrantPrincipal() { return software.amazon.jsii.Kernel.get(this, "grantPrincipal", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.iam.IPrincipal.class)); } /** * (experimental) Labels associated with this provider. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public @org.jetbrains.annotations.NotNull java.util.List getLabels() { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "labels", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)))); } /** * (experimental) Log group where provided runners will save their logs. *

* Note that this is not the job log, but the runner itself. It will not contain output from the GitHub Action but only metadata on its execution. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.ILogGroup getLogGroup() { return software.amazon.jsii.Kernel.get(this, "logGroup", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.logs.ILogGroup.class)); } /** * (experimental) List of step functions errors that should be retried. */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public @org.jetbrains.annotations.NotNull java.util.List getRetryableErrors() { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "retryableErrors", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)))); } /** * (experimental) A fluent builder for {@link com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static final class Builder implements software.amazon.jsii.Builder { /** * @return a new instance of {@link Builder}. * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static Builder create(final software.constructs.Construct scope, final java.lang.String id) { return new Builder(scope, id); } private final software.constructs.Construct scope; private final java.lang.String id; private com.cloudsnorkel.cdk.github.runners.EcsRunnerProviderProps.Builder props; private Builder(final software.constructs.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; } /** * (experimental) The number of days log events are kept in CloudWatch Logs. *

* When updating * this property, unsetting it doesn't remove the log retention policy. To * remove the retention policy, set the value to INFINITE. *

* Default: logs.RetentionDays.ONE_MONTH *

* @return {@code this} * @param logRetention The number of days log events are kept in CloudWatch Logs. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder logRetention(final software.amazon.awscdk.services.logs.RetentionDays logRetention) { this.props().logRetention(logRetention); return this; } /** * @return {@code this} * @deprecated use {@link retryOptions } on {@link GitHubRunners } instead * @param retryOptions This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) @Deprecated public Builder retryOptions(final com.cloudsnorkel.cdk.github.runners.ProviderRetryOptions retryOptions) { this.props().retryOptions(retryOptions); return this; } /** * (experimental) Assign public IP to the runner task. *

* Make sure the task will have access to GitHub. A public IP might be required unless you have NAT gateway. *

* Default: true *

* @return {@code this} * @param assignPublicIp Assign public IP to the runner task. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder assignPublicIp(final java.lang.Boolean assignPublicIp) { this.props().assignPublicIp(assignPublicIp); return this; } /** * (experimental) Existing capacity provider to use. *

* Make sure the AMI used by the capacity provider is compatible with ECS. *

* Default: new capacity provider *

* @return {@code this} * @param capacityProvider Existing capacity provider to use. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder capacityProvider(final software.amazon.awscdk.services.ecs.AsgCapacityProvider capacityProvider) { this.props().capacityProvider(capacityProvider); return this; } /** * (experimental) Existing ECS cluster to use. *

* Default: a new cluster *

* @return {@code this} * @param cluster Existing ECS cluster to use. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder cluster(final software.amazon.awscdk.services.ecs.Cluster cluster) { this.props().cluster(cluster); return this; } /** * (experimental) The number of cpu units used by the task. *

* 1024 units is 1 vCPU. Fractions of a vCPU are supported. *

* Default: 1024 *

* @return {@code this} * @param cpu The number of cpu units used by the task. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder cpu(final java.lang.Number cpu) { this.props().cpu(cpu); return this; } /** * (experimental) Support building and running Docker images by enabling Docker-in-Docker (dind) and the required CodeBuild privileged mode. *

* Disabling this can * speed up provisioning of CodeBuild runners. If you don't intend on running or building Docker images, disable this for faster start-up times. *

* Default: true *

* @return {@code this} * @param dockerInDocker Support building and running Docker images by enabling Docker-in-Docker (dind) and the required CodeBuild privileged mode. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder dockerInDocker(final java.lang.Boolean dockerInDocker) { this.props().dockerInDocker(dockerInDocker); return this; } /** * (experimental) Runner image builder used to build Docker images containing GitHub Runner and all requirements. *

* The image builder determines the OS and architecture of the runner. *

* Default: EcsRunnerProvider.imageBuilder() *

* @return {@code this} * @param imageBuilder Runner image builder used to build Docker images containing GitHub Runner and all requirements. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder imageBuilder(final com.cloudsnorkel.cdk.github.runners.IRunnerImageBuilder imageBuilder) { this.props().imageBuilder(imageBuilder); return this; } /** * (experimental) Instance type of ECS cluster instances. *

* Only used when creating a new cluster. *

* Default: m6i.large or m6g.large *

* @return {@code this} * @param instanceType Instance type of ECS cluster instances. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder instanceType(final software.amazon.awscdk.services.ec2.InstanceType instanceType) { this.props().instanceType(instanceType); return this; } /** * (experimental) GitHub Actions labels used for this provider. *

* These labels are used to identify which provider should spawn a new on-demand runner. Every job sends a webhook with the labels it's looking for * based on runs-on. We match the labels from the webhook with the labels specified here. If all the labels specified here are present in the * job's labels, this provider will be chosen and spawn a new runner. *

* Default: ['ecs'] *

* @return {@code this} * @param labels GitHub Actions labels used for this provider. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder labels(final java.util.List labels) { this.props().labels(labels); return this; } /** * (experimental) The maximum number of instances to run in the cluster. *

* Only used when creating a new cluster. *

* Default: 5 *

* @return {@code this} * @param maxInstances The maximum number of instances to run in the cluster. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder maxInstances(final java.lang.Number maxInstances) { this.props().maxInstances(maxInstances); return this; } /** * (experimental) The amount (in MiB) of memory used by the task. *

* Default: 3500, unless `memoryReservationMiB` is used and then it's undefined *

* @return {@code this} * @param memoryLimitMiB The amount (in MiB) of memory used by the task. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder memoryLimitMiB(final java.lang.Number memoryLimitMiB) { this.props().memoryLimitMiB(memoryLimitMiB); return this; } /** * (experimental) The soft limit (in MiB) of memory to reserve for the container. *

* Default: undefined *

* @return {@code this} * @param memoryReservationMiB The soft limit (in MiB) of memory to reserve for the container. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder memoryReservationMiB(final java.lang.Number memoryReservationMiB) { this.props().memoryReservationMiB(memoryReservationMiB); return this; } /** * (experimental) The minimum number of instances to run in the cluster. *

* Only used when creating a new cluster. *

* Default: 0 *

* @return {@code this} * @param minInstances The minimum number of instances to run in the cluster. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder minInstances(final java.lang.Number minInstances) { this.props().minInstances(minInstances); return this; } /** * (experimental) Security groups to assign to the task. *

* Default: a new security group *

* @return {@code this} * @param securityGroups Security groups to assign to the task. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder securityGroups(final java.util.List securityGroups) { this.props().securityGroups(securityGroups); return this; } /** * (experimental) Use spot capacity. *

* Default: false (true if spotMaxPrice is specified) *

* @return {@code this} * @param spot Use spot capacity. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder spot(final java.lang.Boolean spot) { this.props().spot(spot); return this; } /** * (experimental) Maximum price for spot instances. *

* @return {@code this} * @param spotMaxPrice Maximum price for spot instances. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder spotMaxPrice(final java.lang.String spotMaxPrice) { this.props().spotMaxPrice(spotMaxPrice); return this; } /** * (experimental) Size of volume available for launched cluster instances. *

* This modifies the boot volume size and doesn't add any additional volumes. *

* Each instance can be used by multiple runners, so make sure there is enough space for all of them. *

* Default: default size for AMI (usually 30GB for Linux and 50GB for Windows) *

* @return {@code this} * @param storageSize Size of volume available for launched cluster instances. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder storageSize(final software.amazon.awscdk.Size storageSize) { this.props().storageSize(storageSize); return this; } /** * (experimental) Subnets to run the runners in. *

* Default: ECS default *

* @return {@code this} * @param subnetSelection Subnets to run the runners in. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder subnetSelection(final software.amazon.awscdk.services.ec2.SubnetSelection subnetSelection) { this.props().subnetSelection(subnetSelection); return this; } /** * (experimental) VPC to launch the runners in. *

* Default: default account VPC *

* @return {@code this} * @param vpc VPC to launch the runners in. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder vpc(final software.amazon.awscdk.services.ec2.IVpc vpc) { this.props().vpc(vpc); return this; } /** * @return a newly built instance of {@link com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider build() { return new com.cloudsnorkel.cdk.github.runners.EcsRunnerProvider( this.scope, this.id, this.props != null ? this.props.build() : null ); } private com.cloudsnorkel.cdk.github.runners.EcsRunnerProviderProps.Builder props() { if (this.props == null) { this.props = new com.cloudsnorkel.cdk.github.runners.EcsRunnerProviderProps.Builder(); } return this.props; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy