aws-cdk-lib.aws_codebuild.LinuxBuildImage

class LinuxBuildImage

LanguageType name
.NETAmazon.CDK.AWS.CodeBuild.LinuxBuildImage
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#LinuxBuildImage
Javasoftware.amazon.awscdk.services.codebuild.LinuxBuildImage
Pythonaws_cdk.aws_codebuild.LinuxBuildImage
TypeScript (source)aws-cdk-lib » aws_codebuild » LinuxBuildImage

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)

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html

Example

const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
  synth: new pipelines.ShellStep('Synth', {
    input: pipelines.CodePipelineSource.connection('my-org/my-app', 'main', {
      connectionArn: 'arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41', // Created using the AWS console * });',
    }),
    commands: ['npm ci','npm run build','npx cdk synth'],
  }),

  // Turn this on because the pipeline uses Docker image assets
  dockerEnabledForSelfMutation: true,
});

pipeline.addWave('MyWave', {
  post: [
    new pipelines.CodeBuildStep('RunApproval', {
      commands: ['command-from-image'],
      buildEnvironment: {
        // The user of a Docker image asset in the pipeline requires turning on
        // 'dockerEnabledForSelfMutation'.
        buildImage: codebuild.LinuxBuildImage.fromAsset(this, 'Image', {
          directory: './docker-image',
        }),
      },
    }),
  ],
});

Properties

NameTypeDescription
defaultComputeTypeComputeTypeThe default ComputeType to use with this image, if one was not specified in BuildEnvironment#computeType explicitly.
imageIdstringThe Docker image identifier that the build environment uses.
typestringThe type of build environment.
imagePullPrincipalType?ImagePullPrincipalTypeThe type of principal that CodeBuild will use to pull this build Docker image.
repository?IRepositoryAn optional ECR repository that the image is hosted in.
secretsManagerCredentials?ISecretThe secretsManagerCredentials for access to a private registry.
static AMAZON_LINUX_2IBuildImage
static AMAZON_LINUX_2_2IBuildImage
static AMAZON_LINUX_2_3IBuildImageThe Amazon Linux 2 x86_64 standard image, version 3.0.
static AMAZON_LINUX_2_4IBuildImageThe Amazon Linux 2 x86_64 standard image, version 4.0.
static AMAZON_LINUX_2_5IBuildImageThe Amazon Linux 2 x86_64 standard image, version 5.0.
static AMAZON_LINUX_2_ARM⚠️IBuildImage
static AMAZON_LINUX_2_ARM_2⚠️IBuildImageImage "aws/codebuild/amazonlinux2-aarch64-standard:2.0".
static AMAZON_LINUX_2_ARM_3⚠️IBuildImage
static STANDARD_1_0IBuildImage
static STANDARD_2_0IBuildImage
static STANDARD_3_0IBuildImage
static STANDARD_4_0IBuildImageThe aws/codebuild/standard:4.0 build image.
static STANDARD_5_0IBuildImageThe aws/codebuild/standard:5.0 build image.
static STANDARD_6_0IBuildImageThe aws/codebuild/standard:6.0 build image.
static STANDARD_7_0IBuildImageThe aws/codebuild/standard:7.0 build image.

defaultComputeType

Type: ComputeType

The default ComputeType to use with this image, if one was not specified in BuildEnvironment#computeType explicitly.


imageId

Type: string

The Docker image identifier that the build environment uses.


type

Type: string

The type of build environment.


imagePullPrincipalType?

Type: ImagePullPrincipalType (optional)

The type of principal that CodeBuild will use to pull this build Docker image.


repository?

Type: IRepository (optional)

An optional ECR repository that the image is hosted in.


secretsManagerCredentials?

Type: ISecret (optional)

The secretsManagerCredentials for access to a private registry.


static AMAZON_LINUX_2

Type: IBuildImage


static AMAZON_LINUX_2_2

Type: IBuildImage


static AMAZON_LINUX_2_3

Type: IBuildImage

The Amazon Linux 2 x86_64 standard image, version 3.0.


static AMAZON_LINUX_2_4

Type: IBuildImage

The Amazon Linux 2 x86_64 standard image, version 4.0.


static AMAZON_LINUX_2_5

Type: IBuildImage

The Amazon Linux 2 x86_64 standard image, version 5.0.


static AMAZON_LINUX_2_ARM⚠️

⚠️ Deprecated: Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_1_0 instead.

Type: IBuildImage


static AMAZON_LINUX_2_ARM_2⚠️

⚠️ Deprecated: Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_2_0 instead.

Type: IBuildImage

Image "aws/codebuild/amazonlinux2-aarch64-standard:2.0".


static AMAZON_LINUX_2_ARM_3⚠️

⚠️ Deprecated: Use LinuxArmBuildImage.AMAZON_LINUX_2_STANDARD_3_0 instead.

Type: IBuildImage


static STANDARD_1_0

Type: IBuildImage


static STANDARD_2_0

Type: IBuildImage


static STANDARD_3_0

Type: IBuildImage


static STANDARD_4_0

Type: IBuildImage

The aws/codebuild/standard:4.0 build image.


static STANDARD_5_0

Type: IBuildImage

The aws/codebuild/standard:5.0 build image.


static STANDARD_6_0

Type: IBuildImage

The aws/codebuild/standard:6.0 build image.


static STANDARD_7_0

Type: IBuildImage

The aws/codebuild/standard:7.0 build image.

Methods

NameDescription
runScriptBuildspec(entrypoint)Make a buildspec to run the indicated script.
validate(_env)Allows the image a chance to validate whether the passed configuration is correct.
static fromAsset(scope, id, props)Uses an Docker image asset as a x86-64 Linux build image.
static fromCodeBuildImageId(id)Uses a Docker image provided by CodeBuild.
static fromDockerRegistry(name, options?)
static fromEcrRepository(repository, tagOrDigest?)

runScriptBuildspec(entrypoint)

public runScriptBuildspec(entrypoint: string): BuildSpec

Parameters

  • entrypoint string

Returns

  • BuildSpec

Make a buildspec to run the indicated script.


validate(_env)

public validate(_env: BuildEnvironment): string[]

Parameters

  • _env BuildEnvironment

Returns

  • string[]

Allows the image a chance to validate whether the passed configuration is correct.


static fromAsset(scope, id, props)

public static fromAsset(scope: Construct, id: string, props: DockerImageAssetProps): IBuildImage

Parameters

  • scope Construct
  • id string
  • props DockerImageAssetProps

Returns

  • IBuildImage

Uses an Docker image asset as a x86-64 Linux build image.


static fromCodeBuildImageId(id)

public static fromCodeBuildImageId(id: string): IBuildImage

Parameters

  • id string — The image identifier.

Returns

  • IBuildImage

Uses a Docker image provided by CodeBuild.

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html Example

'aws/codebuild/standard:4.0'

static fromDockerRegistry(name, options?)

public static fromDockerRegistry(name: string, options?: DockerImageOptions): IBuildImage

Parameters

  • name string
  • options DockerImageOptions

Returns

  • IBuildImage

static fromEcrRepository(repository, tagOrDigest?)

public static fromEcrRepository(repository: IRepository, tagOrDigest?: string): IBuildImage

Parameters

  • repository IRepository — The ECR repository.
  • tagOrDigest string — Image tag or digest (default "latest", digests must start with sha256:).

Returns

  • IBuildImage

See also: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html