aws-cdk-lib.aws_codebuild.BuildEnvironment

interface BuildEnvironment

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

Example

declare const vpc: ec2.Vpc;
declare const mySecurityGroup: ec2.SecurityGroup;
new pipelines.CodeBuildStep('Synth', {
  // ...standard ShellStep props...
  commands: [/* ... */],
  env: { /* ... */ },

  // If you are using a CodeBuildStep explicitly, set the 'cdk.out' directory
  // to be the synth step's output.
  primaryOutputDirectory: 'cdk.out',

  // Control the name of the project
  projectName: 'MyProject',

  // Control parts of the BuildSpec other than the regular 'build' and 'install' commands
  partialBuildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    // ...
  }),

  // Control the build environment
  buildEnvironment: {
    computeType: codebuild.ComputeType.LARGE,
    privileged: true,
  },
  timeout: Duration.minutes(90),
  fileSystemLocations: [codebuild.FileSystemLocation.efs({
      identifier: "myidentifier2",
      location: "myclodation.mydnsroot.com:/loc",
      mountPoint: "/media",
      mountOptions: "opts",
    })],

  // Control Elastic Network Interface creation
  vpc: vpc,
  subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
  securityGroups: [mySecurityGroup],

  // Control caching
  cache: codebuild.Cache.bucket(new s3.Bucket(this, 'Cache')),

  // Additional policy statements for the execution role
  rolePolicyStatements: [
    new iam.PolicyStatement({ /* ... */ }),
  ],
});

Properties

NameTypeDescription
buildImage?IBuildImageThe image used for the builds.
certificate?BuildEnvironmentCertificateThe location of the PEM-encoded certificate for the build project.
computeType?ComputeTypeThe type of compute to use for this build.
environmentVariables?{ [string]: BuildEnvironmentVariable }The environment variables that your builds can use.
privileged?booleanIndicates how the project builds Docker images.

buildImage?

Type: IBuildImage (optional, default: LinuxBuildImage.STANDARD_1_0)

The image used for the builds.


certificate?

Type: BuildEnvironmentCertificate (optional, default: No external certificate is added to the project)

The location of the PEM-encoded certificate for the build project.


computeType?

Type: ComputeType (optional, default: taken from #buildImage#defaultComputeType)

The type of compute to use for this build.

See the ComputeType enum for the possible values.


environmentVariables?

Type: { [string]: BuildEnvironmentVariable } (optional)

The environment variables that your builds can use.


privileged?

Type: boolean (optional, default: false)

Indicates how the project builds Docker images.

Specify true to enable running the Docker daemon inside a Docker container. This value must be set to true only if this build project will be used to build Docker images, and the specified build environment image is not one provided by AWS CodeBuild with Docker support. Otherwise, all associated builds that attempt to interact with the Docker daemon will fail.