Skip to content
v2.273.0

PipelineProject L2 construct ​

A convenience class for CodeBuild Projects that are used in CodePipeline.

Example ​

ts
// 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,
        }),
      ],
    },
  ],
});
python
# Create a Cloudfront Web Distribution
import aws_cdk.aws_cloudfront as cloudfront
# distribution: cloudfront.Distribution


# Create the build project that will invalidate the cache
invalidate_build_project = codebuild.PipelineProject(self, "InvalidateProject",
    build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2",
        "phases": {
            "build": {
                "commands": ["aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths \"/*\""
                ]
            }
        }
    }),
    environment_variables={
        "CLOUDFRONT_ID": codebuild.BuildEnvironmentVariable(value=distribution.distribution_id)
    }
)

# Add Cloudfront invalidation permissions to the project
distribution_arn = f"arn:aws:cloudfront::{this.account}:distribution/{distribution.distributionId}"
invalidate_build_project.add_to_role_policy(iam.PolicyStatement(
    resources=[distribution_arn],
    actions=["cloudfront:CreateInvalidation"
    ]
))

# Create the pipeline (here only the S3 deploy and Invalidate cache build)
deploy_bucket = s3.Bucket(self, "DeployBucket")
deploy_input = codepipeline.Artifact()
codepipeline.Pipeline(self, "Pipeline",
    stages=[codepipeline.StageProps(
        stage_name="Deploy",
        actions=[
            codepipeline_actions.S3DeployAction(
                action_name="S3Deploy",
                bucket=deploy_bucket,
                input=deploy_input,
                run_order=1
            ),
            codepipeline_actions.CodeBuildAction(
                action_name="InvalidateCache",
                project=invalidate_build_project,
                input=deploy_input,
                run_order=2
            )
        ]
    )
    ]
)
java
// Create a Cloudfront Web Distribution
import software.amazon.awscdk.services.cloudfront.*;
Distribution distribution;


// Create the build project that will invalidate the cache
PipelineProject invalidateBuildProject = PipelineProject.Builder.create(this, "InvalidateProject")
        .buildSpec(BuildSpec.fromObject(Map.of(
                "version", "0.2",
                "phases", Map.of(
                        "build", Map.of(
                                "commands", List.of("aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths \"/*\""))))))
        .environmentVariables(Map.of(
                "CLOUDFRONT_ID", BuildEnvironmentVariable.builder().value(distribution.getDistributionId()).build()))
        .build();

// Add Cloudfront invalidation permissions to the project
String distributionArn = String.format("arn:aws:cloudfront::%s:distribution/%s", this.account, distribution.getDistributionId());
invalidateBuildProject.addToRolePolicy(PolicyStatement.Builder.create()
        .resources(List.of(distributionArn))
        .actions(List.of("cloudfront:CreateInvalidation"))
        .build());

// Create the pipeline (here only the S3 deploy and Invalidate cache build)
Bucket deployBucket = new Bucket(this, "DeployBucket");
Artifact deployInput = new Artifact();
Pipeline.Builder.create(this, "Pipeline")
        .stages(List.of(StageProps.builder()
                .stageName("Deploy")
                .actions(List.of(
                    S3DeployAction.Builder.create()
                            .actionName("S3Deploy")
                            .bucket(deployBucket)
                            .input(deployInput)
                            .runOrder(1)
                            .build(),
                    CodeBuildAction.Builder.create()
                            .actionName("InvalidateCache")
                            .project(invalidateBuildProject)
                            .input(deployInput)
                            .runOrder(2)
                            .build()))
                .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a Cloudfront Web Distribution
using Amazon.CDK.AWS.CloudFront;
Distribution distribution;


// Create the build project that will invalidate the cache
var invalidateBuildProject = new PipelineProject(this, "InvalidateProject", new PipelineProjectProps {
    BuildSpec = BuildSpec.FromObject(new Dictionary<string, object> {
        { "version", "0.2" },
        { "phases", new Dictionary<string, IDictionary<string, string[]>> {
            { "build", new Struct {
                Commands = new [] { "aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths \"/*\"" }
            } }
        } }
    }),
    EnvironmentVariables = new Dictionary<string, BuildEnvironmentVariable> {
        { "CLOUDFRONT_ID", new BuildEnvironmentVariable { Value = distribution.DistributionId } }
    }
});

// Add Cloudfront invalidation permissions to the project
var distributionArn = $"arn:aws:cloudfront::{this.account}:distribution/{distribution.distributionId}";
invalidateBuildProject.AddToRolePolicy(new PolicyStatement(new PolicyStatementProps {
    Resources = new [] { distributionArn },
    Actions = new [] { "cloudfront:CreateInvalidation" }
}));

// Create the pipeline (here only the S3 deploy and Invalidate cache build)
var deployBucket = new Bucket(this, "DeployBucket");
var deployInput = new Artifact();
new Pipeline(this, "Pipeline", new PipelineProps {
    Stages = new [] { new StageProps {
        StageName = "Deploy",
        Actions = new [] {
            new S3DeployAction(new S3DeployActionProps {
                ActionName = "S3Deploy",
                Bucket = deployBucket,
                Input = deployInput,
                RunOrder = 1
            }),
            new CodeBuildAction(new CodeBuildActionProps {
                ActionName = "InvalidateCache",
                Project = invalidateBuildProject,
                Input = deployInput,
                RunOrder = 2
            }) }
    } }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a Cloudfront Web Distribution
import cloudfront "github.com/aws/aws-cdk-go/awscdk"
var distribution Distribution


// Create the build project that will invalidate the cache
invalidateBuildProject := codebuild.NewPipelineProject(this, jsii.String("InvalidateProject"), &PipelineProjectProps{
	BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
		"version": jsii.String("0.2"),
		"phases": map[string]map[string][]*string{
			"build": map[string][]*string{
				"commands": []*string{
					jsii.String("aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_ID} --paths \"/*\""),
				},
			},
		},
	}),
	EnvironmentVariables: map[string]BuildEnvironmentVariable{
		"CLOUDFRONT_ID": &BuildEnvironmentVariable{
			"value": distribution.distributionId,
		},
	},
})

// Add Cloudfront invalidation permissions to the project
distributionArn := fmt.Sprintf("arn:aws:cloudfront::%v:distribution/%v", this.Account, distribution.DistributionId)
invalidateBuildProject.addToRolePolicy(iam.NewPolicyStatement(&PolicyStatementProps{
	Resources: []*string{
		distributionArn,
	},
	Actions: []*string{
		jsii.String("cloudfront:CreateInvalidation"),
	},
}))

// Create the pipeline (here only the S3 deploy and Invalidate cache build)
deployBucket := s3.NewBucket(this, jsii.String("DeployBucket"))
deployInput := codepipeline.NewArtifact()
codepipeline.NewPipeline(this, jsii.String("Pipeline"), &PipelineProps{
	Stages: []StageProps{
		&StageProps{
			StageName: jsii.String("Deploy"),
			Actions: []IAction{
				codepipeline_actions.NewS3DeployAction(&S3DeployActionProps{
					ActionName: jsii.String("S3Deploy"),
					Bucket: deployBucket,
					Input: deployInput,
					RunOrder: jsii.Number(1),
				}),
				codepipeline_actions.NewCodeBuildAction(&CodeBuildActionProps{
					ActionName: jsii.String("InvalidateCache"),
					Project: invalidateBuildProject,
					Input: deployInput,
					RunOrder: jsii.Number(2),
				}),
			},
		},
	},
})

Initializer ​

ts
new PipelineProject(scope: Construct, id: string, props?: PipelineProjectProps)
python
PipelineProject(scope: Construct, id: str, props: typing.Optional[PipelineProjectProps] = None)
java
new PipelineProject(Construct scope, String id, PipelineProjectProps props)
csharp
new PipelineProject(Construct scope, string id, PipelineProjectProps? props = null)
go
NewPipelineProject(Scope Construct, Id *string, Props PipelineProjectProps)

Construct Props ​

allowAllOutboundbooleanallow_all_outboundboolallowAllOutboundBooleanAllowAllOutboundboolAllowAllOutbound*bool= 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.

autoRetryLimitnumberauto_retry_limitint | floatautoRetryLimitNumberAutoRetryLimitdoubleAutoRetryLimit*float64= no retry#
CodeBuild will automatically call retry build using the project's service role up to the auto-retry limit.

autoRetryLimit must be between 0 and 10.

badgebooleanbadgeboolbadgeBooleanBadgeboolBadge*bool= 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.

buildSpecBuildSpecbuild_specBuildSpecbuildSpecBuildSpecBuildSpecBuildSpecBuildSpecBuildSpec= Empty buildspec.#
Filename or contents of buildspec in JSON format.
cacheCachecacheCachecacheCacheCacheCacheCacheCache= Cache.none#
Caching strategy to use.
checkSecretsInPlainTextEnvVariablesbooleancheck_secrets_in_plain_text_env_variablesboolcheckSecretsInPlainTextEnvVariablesBooleanCheckSecretsInPlainTextEnvVariablesboolCheckSecretsInPlainTextEnvVariables*bool= 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.
concurrentBuildLimitnumberconcurrent_build_limitint | floatconcurrentBuildLimitNumberConcurrentBuildLimitdoubleConcurrentBuildLimit*float64= no explicit limit is set#
Maximum number of concurrent builds.

Minimum value is 1 and maximum is account build limit.

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= No description.#
A description of the project.

Use the description to identify the purpose of the project.

encryptionKeyIKeyencryption_keyIKeyencryptionKeyIKeyEncryptionKeyIKeyEncryptionKeyIKey= The AWS-managed CMK for Amazon S…#
Encryption key to use to read and write artifacts.
default

Default: The AWS-managed CMK for Amazon Simple Storage Service (Amazon S3) is used.

environmentBuildEnvironmentenvironmentBuildEnvironmentenvironmentBuildEnvironmentEnvironmentBuildEnvironmentEnvironmentBuildEnvironment= BuildEnvironment.LinuxBuildImage…#
Build environment to use for the build.
default

Default: BuildEnvironment.LinuxBuildImage.STANDARD_7_0

environmentVariables{ [key: string]: BuildEnvironmentVariable }environment_variablestyping.Mapping[str, BuildEnvironmentVariable]environmentVariablesMap<String, BuildEnvironmentVariable>EnvironmentVariablesIDictionary<string, BuildEnvironmentVariable>EnvironmentVariables*map[string]BuildEnvironmentVariable= No additional environment variab…#
Additional environment variables to add to the build environment.
default

Default: No additional environment variables are specified.

fileSystemLocationsIFileSystemLocation[]file_system_locationstyping.List[IFileSystemLocation]fileSystemLocationsList<IFileSystemLocation>FileSystemLocationsIFileSystemLocation[]FileSystemLocations*[]IFileSystemLocation= 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.

grantReportGroupPermissionsbooleangrant_report_group_permissionsboolgrantReportGroupPermissionsBooleanGrantReportGroupPermissionsboolGrantReportGroupPermissions*bool= true#
Add permissions to this project's role to create and use test report groups with name starting with the name of this project.
notes

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.

loggingLoggingOptionsloggingLoggingOptionsloggingLoggingOptionsLoggingLoggingOptionsLoggingLoggingOptions= 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.

projectNamestringproject_namestrprojectNameStringProjectNamestringProjectName*string= Name is automatically generated.#
The physical, human-readable name of the CodeBuild Project.
queuedTimeoutDurationqueued_timeoutDurationqueuedTimeoutDurationQueuedTimeoutDurationQueuedTimeoutDuration= 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.

roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole= A role will be created.#
Service Role to assume while running the build.
securityGroupsISecurityGroup[]security_groupstyping.List[ISecurityGroup]securityGroupsList<ISecurityGroup>SecurityGroupsISecurityGroup[]SecurityGroups*[]ISecurityGroup= Security group will be automatic…#
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.

default

Default: Security group will be automatically created.

ssmSessionPermissionsbooleanssm_session_permissionsboolssmSessionPermissionsBooleanSsmSessionPermissionsboolSsmSessionPermissions*bool= false#
Add the permissions necessary for debugging builds with SSM Session Manager.
notes

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.

subnetSelectionSubnetSelectionsubnet_selectionSubnetSelectionsubnetSelectionSubnetSelectionSubnetSelectionSubnetSelectionSubnetSelectionSubnetSelection= private subnets if available els…#
Where to place the network interfaces within the VPC.
notes · default

To access AWS services, your CodeBuild project needs to be in one of the following types of subnets:

  1. Subnets with access to the internet (of type PRIVATE_WITH_EGRESS).
  2. 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.

Default: private subnets if available else public subnets

timeoutDurationtimeoutDurationtimeoutDurationTimeoutDurationTimeoutDuration= 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.

visibilityProjectVisibilityvisibilityProjectVisibilityvisibilityProjectVisibilityVisibilityProjectVisibilityVisibilityProjectVisibility= no visibility is set#
Specifies the visibility of the project's builds.
vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpc= No VPC is specified.#
VPC network to place codebuild network interfaces.

Specify this if the codebuild project needs to access resources in a VPC.

Properties ​

connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnectionsrequired#
Access the Connections object.

Will fail if this Project does not have a VPC set.

The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#
The principal to grant permissions to.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
projectArnstringproject_arnstrprojectArnStringProjectArnstringProjectArn*stringrequired#
The ARN of the project.
projectNamestringproject_namestrprojectNameStringProjectNamestringProjectName*stringrequired#
The name of the project.
projectRefProjectReferenceproject_refProjectReferenceprojectRefProjectReferenceProjectRefProjectReferenceProjectRefProjectReferencerequired#
A reference to a Project resource.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
roleIRoleroleIRoleroleIRoleRoleIRoleRoleIRole#
The IAM role for this project.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

addFileSystemLocation(fileSystemLocation: IFileSystemLocation): voiddef add_file_system_location(self, file_system_location: IFileSystemLocation) -> Nonepublic void addFileSystemLocation(IFileSystemLocation fileSystemLocation)public void AddFileSystemLocation(IFileSystemLocation fileSystemLocation)func AddFileSystemLocation(FileSystemLocation IFileSystemLocation)#
Adds a fileSystemLocation to the Project.
1 parameter

Parameters

  • fileSystemLocationfile_system_locationfileSystemLocationfileSystemLocationFileSystemLocation — the fileSystemLocation to add.
addSecondaryArtifact(secondaryArtifact: IArtifacts): voiddef add_secondary_artifact(self, secondary_artifact: IArtifacts) -> Nonepublic void addSecondaryArtifact(IArtifacts secondaryArtifact)public void AddSecondaryArtifact(IArtifacts secondaryArtifact)func AddSecondaryArtifact(SecondaryArtifact IArtifacts)#
Adds a secondary artifact to the Project.
1 parameter

Parameters

  • secondaryArtifactsecondary_artifactsecondaryArtifactsecondaryArtifactSecondaryArtifact — the artifact to add as a secondary artifact.
addSecondarySource(secondarySource: ISource): voiddef add_secondary_source(self, secondary_source: ISource) -> Nonepublic void addSecondarySource(ISource secondarySource)public void AddSecondarySource(ISource secondarySource)func AddSecondarySource(SecondarySource ISource)#
Adds a secondary source to the Project.
1 parameter

Parameters

  • secondarySourcesecondary_sourcesecondarySourcesecondarySourceSecondarySource — the source to add as a secondary source.
addToRolePolicy(statement: PolicyStatement): voiddef add_to_role_policy(self, statement: PolicyStatement) -> Nonepublic void addToRolePolicy(PolicyStatement statement)public void AddToRolePolicy(PolicyStatement statement)func AddToRolePolicy(Statement PolicyStatement)#
Add a permission only if there's a policy attached.
1 parameter

Parameters

  • statementstatementstatementstatementStatement — The permissions statement to add.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

bindAsNotificationRuleSource(_scope: Construct): NotificationRuleSourceConfigdef bind_as_notification_rule_source(self, _scope: Construct) -> NotificationRuleSourceConfigpublic NotificationRuleSourceConfig bindAsNotificationRuleSource(Construct _scope)public NotificationRuleSourceConfig BindAsNotificationRuleSource(Construct _scope)func BindAsNotificationRuleSource(_scope Construct) NotificationRuleSourceConfig#
Returns a source configuration for notification rule.
bindToCodePipeline(_scope: Construct, options: BindToCodePipelineOptions): voiddef bind_to_code_pipeline(self, _scope: Construct, options: BindToCodePipelineOptions) -> Nonepublic void bindToCodePipeline(Construct _scope, BindToCodePipelineOptions options)public void BindToCodePipeline(Construct _scope, BindToCodePipelineOptions options)func BindToCodePipeline(_scope Construct, Options BindToCodePipelineOptions)#
A callback invoked when the given project is added to a CodePipeline.
2 parameters

Parameters

  • _scope_scope_scope_scope_scope — the construct the binding is taking place in.
  • optionsoptionsoptionsoptionsOptions — additional options for the binding.
enableBatchBuilds(): BatchBuildConfigdef enable_batch_builds(self, ) -> BatchBuildConfigpublic BatchBuildConfig enableBatchBuilds()public BatchBuildConfig EnableBatchBuilds()func EnableBatchBuilds() BatchBuildConfig#
Enable batch builds.

Returns an object contining the batch service role if batch builds could be enabled.

fromProjectArn(scope: Construct, id: string, projectArn: string): IProject@staticmethod def from_project_arn(scope: Construct, id: str, project_arn: str) -> IProjectpublic static IProject fromProjectArn(Construct scope, String id, String projectArn)public static IProject FromProjectArn(Construct scope, string id, string projectArn)func FromProjectArn(Scope Construct, Id *string, ProjectArn *string) IProjectstatic#
fromProjectName(scope: Construct, id: string, projectName: string): IProject@staticmethod def from_project_name(scope: Construct, id: str, project_name: str) -> IProjectpublic static IProject fromProjectName(Construct scope, String id, String projectName)public static IProject FromProjectName(Construct scope, string id, string projectName)func FromProjectName(Scope Construct, Id *string, ProjectName *string) IProjectstatic#
Import a Project defined either outside the CDK, or in a different CDK Stack (and exported using the `export` method).
3 parameters · returns

Parameters

  • scopescopescopescopeScope — the parent Construct for this Construct.
  • ididididId — the logical name of this Construct.
  • projectNameproject_nameprojectNameprojectNameProjectName — the name of the project to import.

Returns: a reference to the existing Project

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#
2 parameters · returns

Parameters

  • metricNamemetric_namemetricNamemetricNameMetricName — The name of the metric.
  • propspropspropspropsProps — Customization properties.

Returns: a CloudWatch metric associated with this build project.

metricBuilds(props?: MetricOptions): Metricdef metric_builds(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricBuilds(MetricOptions props)public Metric MetricBuilds(MetricOptions? props = null)func MetricBuilds(Props MetricOptions) Metric#
Measures the number of builds triggered.

Units: Count

Valid CloudWatch statistics: Sum

metricDuration(props?: MetricOptions): Metricdef metric_duration(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricDuration(MetricOptions props)public Metric MetricDuration(MetricOptions? props = null)func MetricDuration(Props MetricOptions) Metric#
Measures the duration of all builds over time.

Units: Seconds

Valid CloudWatch statistics: Average (recommended), Maximum, Minimum

metricFailedBuilds(props?: MetricOptions): Metricdef metric_failed_builds(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricFailedBuilds(MetricOptions props)public Metric MetricFailedBuilds(MetricOptions? props = null)func MetricFailedBuilds(Props MetricOptions) Metric#
Measures the number of builds that failed because of client error or because of a timeout.

Units: Count

Valid CloudWatch statistics: Sum

metricSucceededBuilds(props?: MetricOptions): Metricdef metric_succeeded_builds(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSucceededBuilds(MetricOptions props)public Metric MetricSucceededBuilds(MetricOptions? props = null)func MetricSucceededBuilds(Props MetricOptions) Metric#
Measures the number of successful builds.

Units: Count

Valid CloudWatch statistics: Sum

notifyOn(id: string, target: INotificationRuleTarget, options: ProjectNotifyOnOptions): INotificationRuledef notify_on(self, id: str, target: INotificationRuleTarget, options: ProjectNotifyOnOptions) -> INotificationRulepublic INotificationRule notifyOn(String id, INotificationRuleTarget target, ProjectNotifyOnOptions options)public INotificationRule NotifyOn(string id, INotificationRuleTarget target, ProjectNotifyOnOptions options)func NotifyOn(Id *string, Target INotificationRuleTarget, Options ProjectNotifyOnOptions) INotificationRule#
Defines a CodeStar Notification rule triggered when the project events emitted by you specified, it very similar to `onEvent` API.

You can also use the methods notifyOnBuildSucceeded and notifyOnBuildFailed to define rules for these specific event emitted.

notifyOnBuildFailed(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRuledef notify_on_build_failed(self, id: str, target: INotificationRuleTarget, options: typing.Optional[NotificationRuleOptions] = None) -> INotificationRulepublic INotificationRule notifyOnBuildFailed(String id, INotificationRuleTarget target, NotificationRuleOptions options)public INotificationRule NotifyOnBuildFailed(string id, INotificationRuleTarget target, NotificationRuleOptions? options = null)func NotifyOnBuildFailed(Id *string, Target INotificationRuleTarget, Options NotificationRuleOptions) INotificationRule#
Defines a CodeStar notification rule which triggers when a build fails.
notifyOnBuildSucceeded(id: string, target: INotificationRuleTarget, options?: NotificationRuleOptions): INotificationRuledef notify_on_build_succeeded(self, id: str, target: INotificationRuleTarget, options: typing.Optional[NotificationRuleOptions] = None) -> INotificationRulepublic INotificationRule notifyOnBuildSucceeded(String id, INotificationRuleTarget target, NotificationRuleOptions options)public INotificationRule NotifyOnBuildSucceeded(string id, INotificationRuleTarget target, NotificationRuleOptions? options = null)func NotifyOnBuildSucceeded(Id *string, Target INotificationRuleTarget, Options NotificationRuleOptions) INotificationRule#
Defines a CodeStar notification rule which triggers when a build completes successfully.
onBuildFailed(id: string, options?: OnEventOptions): Ruledef on_build_failed(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onBuildFailed(String id, OnEventOptions options)public Rule OnBuildFailed(string id, OnEventOptions? options = null)func OnBuildFailed(Id *string, Options OnEventOptions) Rule#
Defines an event rule which triggers when a build fails.

To access fields from the event in the event target input, use the static fields on the StateChangeEvent class.

onBuildStarted(id: string, options?: OnEventOptions): Ruledef on_build_started(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onBuildStarted(String id, OnEventOptions options)public Rule OnBuildStarted(string id, OnEventOptions? options = null)func OnBuildStarted(Id *string, Options OnEventOptions) Rule#
Defines an event rule which triggers when a build starts.

To access fields from the event in the event target input, use the static fields on the StateChangeEvent class.

onBuildSucceeded(id: string, options?: OnEventOptions): Ruledef on_build_succeeded(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onBuildSucceeded(String id, OnEventOptions options)public Rule OnBuildSucceeded(string id, OnEventOptions? options = null)func OnBuildSucceeded(Id *string, Options OnEventOptions) Rule#
Defines an event rule which triggers when a build completes successfully.

To access fields from the event in the event target input, use the static fields on the StateChangeEvent class.

onEvent(id: string, options?: OnEventOptions): Ruledef on_event(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onEvent(String id, OnEventOptions options)public Rule OnEvent(string id, OnEventOptions? options = null)func OnEvent(Id *string, Options OnEventOptions) Rule#
Defines a CloudWatch event rule triggered when something happens with this project.
onPhaseChange(id: string, options?: OnEventOptions): Ruledef on_phase_change(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onPhaseChange(String id, OnEventOptions options)public Rule OnPhaseChange(string id, OnEventOptions? options = null)func OnPhaseChange(Id *string, Options OnEventOptions) Rule#
Defines a CloudWatch event rule that triggers upon phase change of this build project.
onStateChange(id: string, options?: OnEventOptions): Ruledef on_state_change(self, id: str, options: typing.Optional[OnEventOptions] = None) -> Rulepublic Rule onStateChange(String id, OnEventOptions options)public Rule OnStateChange(string id, OnEventOptions? options = null)func OnStateChange(Id *string, Options OnEventOptions) Rule#
Defines a CloudWatch event rule triggered when the build project state changes.
notes

You can filter specific build status events using an event pattern filter on the build-status detail field:

const rule = project.onStateChange('OnBuildStarted', { target }); rule.addEventPattern({ detail: { 'build-status': [ "IN_PROGRESS", "SUCCEEDED", "FAILED", "STOPPED" ] } });

You can also use the methods onBuildFailed and onBuildSucceeded to define rules for these specific state changes.

To access fields from the event in the event target input, use the static fields on the StateChangeEvent class.

serializeEnvVariables(environmentVariables: { [key: string]: BuildEnvironmentVariable }, validateNoPlainTextSecrets?: boolean, principal?: IGrantable): CfnProject.EnvironmentVariableProperty[]@staticmethod def serialize_env_variables(environment_variables: typing.Mapping[str, BuildEnvironmentVariable], validate_no_plain_text_secrets: typing.Optional[bool] = None, principal: typing.Optional[IGrantable] = None) -> typing.List[EnvironmentVariableProperty]public static List<EnvironmentVariableProperty> serializeEnvVariables(Map<String, BuildEnvironmentVariable> environmentVariables, Boolean validateNoPlainTextSecrets, IGrantable principal)public static EnvironmentVariableProperty[] SerializeEnvVariables(IDictionary<string, BuildEnvironmentVariable> environmentVariables, bool? validateNoPlainTextSecrets = null, IGrantable? principal = null)func SerializeEnvVariables(EnvironmentVariables *map[string]BuildEnvironmentVariable, ValidateNoPlainTextSecrets *bool, Principal IGrantable) *[]EnvironmentVariablePropertystatic#
Convert the environment variables map of string to `BuildEnvironmentVariable`, which is the customer-facing type, to a list of `CfnProject.EnvironmentVariableProperty`, which is the representation of environment variables in CloudFormation.
2 parameters · returns

Parameters

  • environmentVariablesenvironment_variablesenvironmentVariablesenvironmentVariablesEnvironmentVariables — the map of string to environment variables.
  • validateNoPlainTextSecretsvalidate_no_plain_text_secretsvalidateNoPlainTextSecretsvalidateNoPlainTextSecretsValidateNoPlainTextSecrets — whether to throw an exception if any of the plain text environment variables contain secrets, defaults to 'false'.

Returns: an array of CfnProject.EnvironmentVariableProperty instances

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.