interface PipelineProjectProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.CodeBuild.PipelineProjectProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#PipelineProjectProps |
Java | software.amazon.awscdk.services.codebuild.PipelineProjectProps |
Python | aws_cdk.aws_codebuild.PipelineProjectProps |
TypeScript (source) | aws-cdk-lib » aws_codebuild » PipelineProjectProps |
Example
// Create a Cloudfront Web Distribution
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
declare const distribution: cloudfront.Distribution;
// Create the build project that will invalidate the cache
const invalidateBuildProject = new codebuild.PipelineProject(this, `InvalidateProject`, {
buildSpec: codebuild.BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands:[
'aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths "/*"',
// Choose whatever files or paths you'd like, or all files as specified here
],
},
},
}),
environmentVariables: {
CLOUDFRONT_ID: { value: distribution.distributionId },
},
});
// Add Cloudfront invalidation permissions to the project
const distributionArn = `arn:aws:cloudfront::${this.account}:distribution/${distribution.distributionId}`;
invalidateBuildProject.addToRolePolicy(new iam.PolicyStatement({
resources: [distributionArn],
actions: [
'cloudfront:CreateInvalidation',
],
}));
// Create the pipeline (here only the S3 deploy and Invalidate cache build)
const deployBucket = new s3.Bucket(this, 'DeployBucket');
const deployInput = new codepipeline.Artifact();
new codepipeline.Pipeline(this, 'Pipeline', {
stages: [
// ...
{
stageName: 'Deploy',
actions: [
new codepipeline_actions.S3DeployAction({
actionName: 'S3Deploy',
bucket: deployBucket,
input: deployInput,
runOrder: 1,
}),
new codepipeline_actions.CodeBuildAction({
actionName: 'InvalidateCache',
project: invalidateBuildProject,
input: deployInput,
runOrder: 2,
}),
],
},
],
});
Properties
Name | Type | Description |
---|---|---|
allow | boolean | Whether to allow the CodeBuild to send all network traffic. |
badge? | boolean | Indicates whether AWS CodeBuild generates a publicly accessible URL for your project's build badge. |
build | Build | Filename or contents of buildspec in JSON format. |
cache? | Cache | Caching strategy to use. |
check | boolean | Whether to check for the presence of any secrets in the environment variables of the default type, BuildEnvironmentVariableType.PLAINTEXT. Since using a secret for the value of that kind of variable would result in it being displayed in plain text in the AWS Console, the construct will throw an exception if it detects a secret was passed there. Pass this property as false if you want to skip this validation, and keep using a secret in a plain text environment variable. |
concurrent | number | Maximum number of concurrent builds. |
description? | string | A description of the project. |
encryption | IKey | Encryption key to use to read and write artifacts. |
environment? | Build | Build environment to use for the build. |
environment | { [string]: Build } | Additional environment variables to add to the build environment. |
file | IFile [] | An ProjectFileSystemLocation objects for a CodeBuild build project. |
grant | boolean | Add permissions to this project's role to create and use test report groups with name starting with the name of this project. |
logging? | Logging | Information about logs for the build project. |
project | string | The physical, human-readable name of the CodeBuild Project. |
queued | Duration | The number of minutes after which AWS CodeBuild stops the build if it's still in queue. |
role? | IRole | Service Role to assume while running the build. |
security | ISecurity [] | What security group to associate with the codebuild project's network interfaces. |
ssm | boolean | Add the permissions necessary for debugging builds with SSM Session Manager. |
subnet | Subnet | Where to place the network interfaces within the VPC. |
timeout? | Duration | The number of minutes after which AWS CodeBuild stops the build if it's not complete. |
visibility? | Project | Specifies the visibility of the project's builds. |
vpc? | IVpc | VPC network to place codebuild network interfaces. |
allowAllOutbound?
Type:
boolean
(optional, default: true)
Whether to allow the CodeBuild to send all network traffic.
If set to false, you must individually add traffic rules to allow the CodeBuild project to connect to network targets.
Only used if 'vpc' is supplied.
badge?
Type:
boolean
(optional, default: false)
Indicates whether AWS CodeBuild generates a publicly accessible URL for your project's build badge.
For more information, see Build Badges Sample in the AWS CodeBuild User Guide.
buildSpec?
Type:
Build
(optional, default: Empty buildspec.)
Filename or contents of buildspec in JSON format.
cache?
Type:
Cache
(optional, default: Cache.none)
Caching strategy to use.
checkSecretsInPlainTextEnvVariables?
Type:
boolean
(optional, default: true)
Whether to check for the presence of any secrets in the environment variables of the default type, BuildEnvironmentVariableType.PLAINTEXT. Since using a secret for the value of that kind of variable would result in it being displayed in plain text in the AWS Console, the construct will throw an exception if it detects a secret was passed there. Pass this property as false if you want to skip this validation, and keep using a secret in a plain text environment variable.
concurrentBuildLimit?
Type:
number
(optional, default: no explicit limit is set)
Maximum number of concurrent builds.
Minimum value is 1 and maximum is account build limit.
description?
Type:
string
(optional, default: No description.)
A description of the project.
Use the description to identify the purpose of the project.
encryptionKey?
Type:
IKey
(optional, default: The AWS-managed CMK for Amazon Simple Storage Service (Amazon S3) is used.)
Encryption key to use to read and write artifacts.
environment?
Type:
Build
(optional, default: BuildEnvironment.LinuxBuildImage.STANDARD_7_0)
Build environment to use for the build.
environmentVariables?
Type:
{ [string]:
Build
}
(optional, default: No additional environment variables are specified.)
Additional environment variables to add to the build environment.
fileSystemLocations?
Type:
IFile
[]
(optional, default: no file system locations)
An ProjectFileSystemLocation objects for a CodeBuild build project.
A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System.
grantReportGroupPermissions?
Type:
boolean
(optional, default: true)
Add permissions to this project's role to create and use test report groups with name starting with the name of this project.
That is the standard report group that gets created when a simple name (in contrast to an ARN) is used in the 'reports' section of the buildspec of this project. This is usually harmless, but you can turn these off if you don't plan on using test reports in this project.
logging?
Type:
Logging
(optional, default: no log configuration is set)
Information about logs for the build project.
A project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.
projectName?
Type:
string
(optional, default: Name is automatically generated.)
The physical, human-readable name of the CodeBuild Project.
queuedTimeout?
Type:
Duration
(optional, default: no queue timeout is set)
The number of minutes after which AWS CodeBuild stops the build if it's still in queue.
For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.
role?
Type:
IRole
(optional, default: A role will be created.)
Service Role to assume while running the build.
securityGroups?
Type:
ISecurity
[]
(optional, default: Security group will be automatically created.)
What security group to associate with the codebuild project's network interfaces.
If no security group is identified, one will be created automatically.
Only used if 'vpc' is supplied.
ssmSessionPermissions?
Type:
boolean
(optional, default: false)
Add the permissions necessary for debugging builds with SSM Session Manager.
If the following prerequisites have been met:
- The necessary permissions have been added by setting this flag to true.
- The build image has the SSM agent installed (true for default CodeBuild images).
- The build is started with debugSessionEnabled set to true.
Then the build container can be paused and inspected using Session Manager
by invoking the codebuild-breakpoint
command somewhere during the build.
codebuild-breakpoint
commands will be ignored if the build is not started
with debugSessionEnabled=true
.
See also: https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html
subnetSelection?
Type:
Subnet
(optional, default: private subnets if available else public subnets)
Where to place the network interfaces within the VPC.
To access AWS services, your CodeBuild project needs to be in one of the following types of subnets:
- Subnets with access to the internet (of type PRIVATE_WITH_EGRESS).
- Private subnets unconnected to the internet, but with VPC endpoints for the necessary services.
If you don't specify a subnet selection, the default behavior is to use PRIVATE_WITH_EGRESS subnets first if they exist, then PRIVATE_WITHOUT_EGRESS, and finally PUBLIC subnets. If your VPC doesn't have PRIVATE_WITH_EGRESS subnets but you need AWS service access, add VPC Endpoints to your private subnets.
See also: https://docs.aws.amazon.com/codebuild/latest/userguide/vpc-support.html
timeout?
Type:
Duration
(optional, default: Duration.hours(1))
The number of minutes after which AWS CodeBuild stops the build if it's not complete.
For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.
visibility?
Type:
Project
(optional, default: no visibility is set)
Specifies the visibility of the project's builds.
vpc?
Type:
IVpc
(optional, default: No VPC is specified.)
VPC network to place codebuild network interfaces.
Specify this if the codebuild project needs to access resources in a VPC.