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

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

package com.cloudsnorkel.cdk.github.runners;

/**
 * (experimental) An AMI builder that uses AWS Image Builder to build AMIs pre-baked with all the GitHub Actions runner requirements.
 * 

* Builders can be used with {@link Ec2Runner}. *

* Each builder re-runs automatically at a set interval to make sure the AMIs contain the latest versions of everything. *

* You can create an instance of this construct to customize the AMI used to spin-up runners. Some runner providers may require custom components. Check the runner provider documentation. *

* For example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the EC2 provider, use: *

*

 * const builder = new AmiBuilder(this, 'Builder', {
 *      runnerVersion: RunnerVersion.specific('2.293.0'),
 *      rebuildInterval: Duration.days(14),
 * });
 * builder.addComponent(new ImageBuilderComponent(scope, id, {
 *    platform: 'Linux',
 *    displayName: 'p7zip',
 *    description: 'Install some more packages',
 *    commands: [
 *      'set -ex',
 *      'apt-get install p7zip',
 *    ],
 * }));
 * new Ec2Runner(this, 'EC2 provider', {
 *      label: 'custom-ec2',
 *      amiBuilder: builder,
 * });
 * 
*/ @javax.annotation.Generated(value = "jsii-pacmak/1.73.0 (build 6faeda3)", date = "2023-01-17T21:04:02.904Z") @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.AmiBuilder") public class AmiBuilder extends software.constructs.Construct implements com.cloudsnorkel.cdk.github.runners.IAmiBuilder, software.amazon.awscdk.services.ec2.IConnectable { protected AmiBuilder(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); } protected AmiBuilder(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 AmiBuilder(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.AmiBuilderProps 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 AmiBuilder(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) Add a component to be installed. *

* @param component This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addComponent(final @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.ImageBuilderComponent component) { software.amazon.jsii.Kernel.call(this, "addComponent", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(component, "component is required") }); } /** * (experimental) Add extra trusted certificates. *

* This helps deal with self-signed certificates for GitHub Enterprise Server. *

* @param path path to directory containing a file called certs.pem containing all the required certificates. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addExtraCertificates(final @org.jetbrains.annotations.NotNull java.lang.String path) { software.amazon.jsii.Kernel.call(this, "addExtraCertificates", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(path, "path is required") }); } /** * (experimental) Called by IRunnerProvider to finalize settings and create the AMI builder. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.RunnerAmi bind() { return software.amazon.jsii.Kernel.call(this, "bind", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.RunnerAmi.class)); } /** * @param infra This parameter is required. * @param dist This parameter is required. * @param log This parameter is required. * @param imageRecipeArn * @param containerRecipeArn */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnImage createImage(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration infra, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnDistributionConfiguration dist, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup log, final @org.jetbrains.annotations.Nullable java.lang.String imageRecipeArn, final @org.jetbrains.annotations.Nullable java.lang.String containerRecipeArn) { return software.amazon.jsii.Kernel.call(this, "createImage", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnImage.class), new Object[] { java.util.Objects.requireNonNull(infra, "infra is required"), java.util.Objects.requireNonNull(dist, "dist is required"), java.util.Objects.requireNonNull(log, "log is required"), imageRecipeArn, containerRecipeArn }); } /** * @param infra This parameter is required. * @param dist This parameter is required. * @param log This parameter is required. * @param imageRecipeArn */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnImage createImage(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration infra, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnDistributionConfiguration dist, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup log, final @org.jetbrains.annotations.Nullable java.lang.String imageRecipeArn) { return software.amazon.jsii.Kernel.call(this, "createImage", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnImage.class), new Object[] { java.util.Objects.requireNonNull(infra, "infra is required"), java.util.Objects.requireNonNull(dist, "dist is required"), java.util.Objects.requireNonNull(log, "log is required"), imageRecipeArn }); } /** * @param infra This parameter is required. * @param dist This parameter is required. * @param log This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnImage createImage(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration infra, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnDistributionConfiguration dist, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup log) { return software.amazon.jsii.Kernel.call(this, "createImage", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnImage.class), new Object[] { java.util.Objects.requireNonNull(infra, "infra is required"), java.util.Objects.requireNonNull(dist, "dist is required"), java.util.Objects.requireNonNull(log, "log is required") }); } /** * @param managedPolicies This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration createInfrastructure(final @org.jetbrains.annotations.NotNull java.util.List managedPolicies) { return software.amazon.jsii.Kernel.call(this, "createInfrastructure", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration.class), new Object[] { java.util.Objects.requireNonNull(managedPolicies, "managedPolicies is required") }); } /** * @param recipeName This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup createLog(final @org.jetbrains.annotations.NotNull java.lang.String recipeName) { return software.amazon.jsii.Kernel.call(this, "createLog", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.logs.LogGroup.class), new Object[] { java.util.Objects.requireNonNull(recipeName, "recipeName is required") }); } /** * @param infra This parameter is required. * @param dist This parameter is required. * @param log This parameter is required. * @param imageRecipeArn * @param containerRecipeArn */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnImagePipeline createPipeline(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration infra, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnDistributionConfiguration dist, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup log, final @org.jetbrains.annotations.Nullable java.lang.String imageRecipeArn, final @org.jetbrains.annotations.Nullable java.lang.String containerRecipeArn) { return software.amazon.jsii.Kernel.call(this, "createPipeline", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnImagePipeline.class), new Object[] { java.util.Objects.requireNonNull(infra, "infra is required"), java.util.Objects.requireNonNull(dist, "dist is required"), java.util.Objects.requireNonNull(log, "log is required"), imageRecipeArn, containerRecipeArn }); } /** * @param infra This parameter is required. * @param dist This parameter is required. * @param log This parameter is required. * @param imageRecipeArn */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnImagePipeline createPipeline(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration infra, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnDistributionConfiguration dist, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup log, final @org.jetbrains.annotations.Nullable java.lang.String imageRecipeArn) { return software.amazon.jsii.Kernel.call(this, "createPipeline", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnImagePipeline.class), new Object[] { java.util.Objects.requireNonNull(infra, "infra is required"), java.util.Objects.requireNonNull(dist, "dist is required"), java.util.Objects.requireNonNull(log, "log is required"), imageRecipeArn }); } /** * @param infra This parameter is required. * @param dist This parameter is required. * @param log This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnImagePipeline createPipeline(final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnInfrastructureConfiguration infra, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.imagebuilder.CfnDistributionConfiguration dist, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.logs.LogGroup log) { return software.amazon.jsii.Kernel.call(this, "createPipeline", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.imagebuilder.CfnImagePipeline.class), new Object[] { java.util.Objects.requireNonNull(infra, "infra is required"), java.util.Objects.requireNonNull(dist, "dist is required"), java.util.Objects.requireNonNull(log, "log is required") }); } /** * (experimental) Add a component to be installed before any other components. *

* Useful for required system settings like certificates or proxy settings. *

* @param component This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void prependComponent(final @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.ImageBuilderComponent component) { software.amazon.jsii.Kernel.call(this, "prependComponent", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(component, "component is required") }); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.Architecture getArchitecture() { return software.amazon.jsii.Kernel.get(this, "architecture", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.Architecture.class)); } /** * (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)); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull java.lang.String getDescription() { return software.amazon.jsii.Kernel.get(this, "description", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.Os getOs() { return software.amazon.jsii.Kernel.get(this, "os", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.Os.class)); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull java.lang.String getPlatform() { return software.amazon.jsii.Kernel.get(this, "platform", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull com.cloudsnorkel.cdk.github.runners.RunnerVersion getRunnerVersion() { return software.amazon.jsii.Kernel.get(this, "runnerVersion", software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.RunnerVersion.class)); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected @org.jetbrains.annotations.NotNull java.util.List getComponents() { return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "components", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(com.cloudsnorkel.cdk.github.runners.ImageBuilderComponent.class)))); } /** */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) protected void setComponents(final @org.jetbrains.annotations.NotNull java.util.List value) { software.amazon.jsii.Kernel.set(this, "components", java.util.Objects.requireNonNull(value, "components is required")); } /** * (experimental) A fluent builder for {@link com.cloudsnorkel.cdk.github.runners.AmiBuilder}. */ @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.AmiBuilderProps.Builder props; private Builder(final software.constructs.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; } /** * (experimental) Image architecture. *

* Default: Architecture.X86_64 *

* @return {@code this} * @param architecture Image architecture. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder architecture(final com.cloudsnorkel.cdk.github.runners.Architecture architecture) { this.props().architecture(architecture); return this; } /** * (experimental) Install Docker inside the image, so it can be used by the runner. *

* You may want to disable this if you are building a Windows image and don't have a Docker Desktop license. *

* Default: true *

* @return {@code this} * @param installDocker Install Docker inside the image, so it can be used by the runner. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder installDocker(final java.lang.Boolean installDocker) { this.props().installDocker(installDocker); return this; } /** * (experimental) The instance type used to build the image. *

* Default: m5.large *

* @return {@code this} * @param instanceType The instance type used to build the image. 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) Removal policy for logs of image builds. *

* If deployment fails on the custom resource, try setting this to RemovalPolicy.RETAIN. This way the logs can still be viewed, and you can see why the build failed. *

* We try to not leave anything behind when removed. But sometimes a log staying behind is useful. *

* Default: RemovalPolicy.DESTROY *

* @return {@code this} * @param logRemovalPolicy Removal policy for logs of image builds. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder logRemovalPolicy(final software.amazon.awscdk.RemovalPolicy logRemovalPolicy) { this.props().logRemovalPolicy(logRemovalPolicy); return this; } /** * (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; } /** * (experimental) Image OS. *

* Default: OS.LINUX *

* @return {@code this} * @param os Image OS. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder os(final com.cloudsnorkel.cdk.github.runners.Os os) { this.props().os(os); return this; } /** * (experimental) Schedule the AMI to be rebuilt every given interval. *

* Useful for keeping the AMI up-do-date with the latest GitHub runner version and latest OS updates. *

* Set to zero to disable. *

* Default: Duration.days(7) *

* @return {@code this} * @param rebuildInterval Schedule the AMI to be rebuilt every given interval. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder rebuildInterval(final software.amazon.awscdk.Duration rebuildInterval) { this.props().rebuildInterval(rebuildInterval); return this; } /** * (experimental) Version of GitHub Runners to install. *

* Default: latest version available *

* @return {@code this} * @param runnerVersion Version of GitHub Runners to install. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder runnerVersion(final com.cloudsnorkel.cdk.github.runners.RunnerVersion runnerVersion) { this.props().runnerVersion(runnerVersion); return this; } /** * (deprecated) Security group to assign to launched builder instances. *

* Default: new security group *

* @return {@code this} * @deprecated use {@link securityGroups} * @param securityGroup Security group to assign to launched builder instances. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Deprecated) @Deprecated public Builder securityGroup(final software.amazon.awscdk.services.ec2.ISecurityGroup securityGroup) { this.props().securityGroup(securityGroup); return this; } /** * (experimental) Security groups to assign to launched builder instances. *

* Default: new security group *

* @return {@code this} * @param securityGroups Security groups to assign to launched builder instances. 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) Where to place the network interfaces within the VPC. *

* Only the first matched subnet will be used. *

* Default: default VPC subnet *

* @return {@code this} * @param subnetSelection Where to place the network interfaces within the VPC. 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 where builder instances will be launched. *

* Default: default account VPC *

* @return {@code this} * @param vpc VPC where builder instances will be launched. 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; } /** * @returns a newly built instance of {@link com.cloudsnorkel.cdk.github.runners.AmiBuilder}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public com.cloudsnorkel.cdk.github.runners.AmiBuilder build() { return new com.cloudsnorkel.cdk.github.runners.AmiBuilder( this.scope, this.id, this.props != null ? this.props.build() : null ); } private com.cloudsnorkel.cdk.github.runners.AmiBuilderProps.Builder props() { if (this.props == null) { this.props = new com.cloudsnorkel.cdk.github.runners.AmiBuilderProps.Builder(); } return this.props; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy