Class LinuxBuildImage

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.codebuild.LinuxBuildImage
All Implemented Interfaces:
IBuildImage, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-18T17:54:14.094Z") @Stability(Stable) public class LinuxBuildImage extends software.amazon.jsii.JsiiObject implements IBuildImage
A CodeBuild image running x86-64 Linux.

This class has a bunch of public constants that represent the most popular images.

You can also specify a custom image using one of the static methods:

  • LinuxBuildImage.fromDockerRegistry(image[, { secretsManagerCredentials }])
  • LinuxBuildImage.fromEcrRepository(repo[, tag])
  • LinuxBuildImage.fromAsset(parent, id, props)

Example:

 CodePipeline pipeline = CodePipeline.Builder.create(this, "Pipeline")
         .synth(ShellStep.Builder.create("Synth")
                 .input(CodePipelineSource.connection("my-org/my-app", "main", ConnectionSourceOptions.builder()
                         .connectionArn("arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41")
                         .build()))
                 .commands(List.of("npm ci", "npm run build", "npx cdk synth"))
                 .build())
         // Turn this on because the pipeline uses Docker image assets
         .dockerEnabledForSelfMutation(true)
         .build();
 pipeline.addWave("MyWave", WaveOptions.builder()
         .post(List.of(
             CodeBuildStep.Builder.create("RunApproval")
                     .commands(List.of("command-from-image"))
                     .buildEnvironment(BuildEnvironment.builder()
                             // The user of a Docker image asset in the pipeline requires turning on
                             // 'dockerEnabledForSelfMutation'.
                             .buildImage(LinuxBuildImage.fromAsset(this, "Image", DockerImageAssetProps.builder()
                                     .directory("./docker-image")
                                     .build()))
                             .build())
                     .build()))
         .build());
 

See Also:
  • Field Details

    • AMAZON_LINUX_2

      @Stability(Deprecated) @Deprecated public static final IBuildImage AMAZON_LINUX_2
      Deprecated.
      Use LinuxBuildImage.AMAZON_LINUX_2_5 instead.
    • AMAZON_LINUX_2_2

      @Stability(Deprecated) @Deprecated public static final IBuildImage AMAZON_LINUX_2_2
      Deprecated.
      Use LinuxBuildImage.AMAZON_LINUX_2_5 instead.
    • AMAZON_LINUX_2_3

      @Stability(Deprecated) @Deprecated public static final IBuildImage AMAZON_LINUX_2_3
      Deprecated.
      Use LinuxBuildImage.AMAZON_LINUX_2_5 instead.
      (deprecated) The Amazon Linux 2 x86_64 standard image, version 3.0.

    • AMAZON_LINUX_2_4

      @Stability(Stable) public static final IBuildImage AMAZON_LINUX_2_4
      The Amazon Linux 2 x86_64 standard image, version 4.0.
    • AMAZON_LINUX_2_5

      @Stability(Stable) public static final IBuildImage AMAZON_LINUX_2_5
      The Amazon Linux 2 x86_64 standard image, version 5.0.
    • AMAZON_LINUX_2_ARM

      @Stability(Deprecated) @Deprecated public static final IBuildImage AMAZON_LINUX_2_ARM
      Deprecated.
      Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0 instead.
    • AMAZON_LINUX_2_ARM_2

      @Stability(Stable) public static final IBuildImage AMAZON_LINUX_2_ARM_2
      The aws/codebuild/amazonlinux2-aarch64-standard:2.0 build image.
    • AMAZON_LINUX_2_ARM_3

      @Stability(Stable) public static final IBuildImage AMAZON_LINUX_2_ARM_3
      The aws/codebuild/amazonlinux2-aarch64-standard:3.0 build image.
    • STANDARD_1_0

      @Stability(Deprecated) @Deprecated public static final IBuildImage STANDARD_1_0
      Deprecated.
      Use LinuxBuildImage.STANDARD_7_0 instead.
    • STANDARD_2_0

      @Stability(Deprecated) @Deprecated public static final IBuildImage STANDARD_2_0
      Deprecated.
      Use LinuxBuildImage.STANDARD_7_0 instead.
    • STANDARD_3_0

      @Stability(Deprecated) @Deprecated public static final IBuildImage STANDARD_3_0
      Deprecated.
      Use LinuxBuildImage.STANDARD_7_0 instead.
    • STANDARD_4_0

      @Stability(Deprecated) @Deprecated public static final IBuildImage STANDARD_4_0
      Deprecated.
      Use LinuxBuildImage.STANDARD_7_0 instead.
      (deprecated) The aws/codebuild/standard:4.0 build image.

    • STANDARD_5_0

      @Stability(Stable) public static final IBuildImage STANDARD_5_0
      The aws/codebuild/standard:5.0 build image.
    • STANDARD_6_0

      @Stability(Stable) public static final IBuildImage STANDARD_6_0
      The aws/codebuild/standard:6.0 build image.
    • STANDARD_7_0

      @Stability(Stable) public static final IBuildImage STANDARD_7_0
      The aws/codebuild/standard:7.0 build image.
  • Constructor Details

    • LinuxBuildImage

      protected LinuxBuildImage(software.amazon.jsii.JsiiObjectRef objRef)
    • LinuxBuildImage

      protected LinuxBuildImage(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
  • Method Details

    • fromAsset

      @Stability(Stable) @NotNull public static IBuildImage fromAsset(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull DockerImageAssetProps props)
      Uses an Docker image asset as a x86-64 Linux build image.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
    • fromCodeBuildImageId

      @Stability(Stable) @NotNull public static IBuildImage fromCodeBuildImageId(@NotNull String id)
      Uses a Docker image provided by CodeBuild.

      Example:

       "aws/codebuild/standard:4.0";
       

      Parameters:
      id - The image identifier. This parameter is required.
      Returns:
      A Docker image provided by CodeBuild.
      See Also:
    • fromDockerRegistry

      @Stability(Stable) @NotNull public static IBuildImage fromDockerRegistry(@NotNull String name, @Nullable DockerImageOptions options)
      Parameters:
      name - This parameter is required.
      options -
      Returns:
      a x86-64 Linux build image from a Docker Hub image.
    • fromDockerRegistry

      @Stability(Stable) @NotNull public static IBuildImage fromDockerRegistry(@NotNull String name)
      Parameters:
      name - This parameter is required.
      Returns:
      a x86-64 Linux build image from a Docker Hub image.
    • fromEcrRepository

      @Stability(Stable) @NotNull public static IBuildImage fromEcrRepository(@NotNull IRepository repository, @Nullable String tagOrDigest)
      Parameters:
      repository - The ECR repository. This parameter is required.
      tagOrDigest - Image tag or digest (default "latest", digests must start with sha256:).
      Returns:
      A x86-64 Linux build image from an ECR repository.

      NOTE: if the repository is external (i.e. imported), then we won't be able to add a resource policy statement for it so CodeBuild can pull the image.

      See Also:
    • fromEcrRepository

      @Stability(Stable) @NotNull public static IBuildImage fromEcrRepository(@NotNull IRepository repository)
      Parameters:
      repository - The ECR repository. This parameter is required.
      Returns:
      A x86-64 Linux build image from an ECR repository.

      NOTE: if the repository is external (i.e. imported), then we won't be able to add a resource policy statement for it so CodeBuild can pull the image.

      See Also:
    • runScriptBuildspec

      @Stability(Stable) @NotNull public BuildSpec runScriptBuildspec(@NotNull String entrypoint)
      Make a buildspec to run the indicated script.

      Specified by:
      runScriptBuildspec in interface IBuildImage
      Parameters:
      entrypoint - This parameter is required.
    • validate

      @Stability(Stable) @NotNull public List<String> validate(@NotNull BuildEnvironment env)
      Allows the image a chance to validate whether the passed configuration is correct.

      Specified by:
      validate in interface IBuildImage
      Parameters:
      env - This parameter is required.
    • getDefaultComputeType

      @Stability(Stable) @NotNull public ComputeType getDefaultComputeType()
      The default ComputeType to use with this image, if one was not specified in BuildEnvironment#computeType explicitly.
      Specified by:
      getDefaultComputeType in interface IBuildImage
    • getImageId

      @Stability(Stable) @NotNull public String getImageId()
      The Docker image identifier that the build environment uses.
      Specified by:
      getImageId in interface IBuildImage
      See Also:
    • getType

      @Stability(Stable) @NotNull public String getType()
      The type of build environment.
      Specified by:
      getType in interface IBuildImage
    • getImagePullPrincipalType

      @Stability(Stable) @Nullable public ImagePullPrincipalType getImagePullPrincipalType()
      The type of principal that CodeBuild will use to pull this build Docker image.
      Specified by:
      getImagePullPrincipalType in interface IBuildImage
    • getRepository

      @Stability(Stable) @Nullable public IRepository getRepository()
      An optional ECR repository that the image is hosted in.
      Specified by:
      getRepository in interface IBuildImage
    • getSecretsManagerCredentials

      @Stability(Stable) @Nullable public ISecret getSecretsManagerCredentials()
      The secretsManagerCredentials for access to a private registry.
      Specified by:
      getSecretsManagerCredentials in interface IBuildImage