Class PipelineProjectProps
Inheritance
Namespace: Amazon.CDK.AWS.CodeBuild
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class PipelineProjectProps : Object, IPipelineProjectProps, ICommonProjectProps
Syntax (vb)
Public Class PipelineProjectProps
Inherits Object
Implements IPipelineProjectProps, ICommonProjectProps
Remarks
ExampleMetadata: infused
Examples
// 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
}) }
} }
});
Synopsis
Constructors
PipelineProjectProps() |
Properties
AllowAllOutbound | Whether to allow the CodeBuild to send all network traffic. |
Badge | Indicates whether AWS CodeBuild generates a publicly accessible URL for your project's build badge. |
BuildSpec | Filename or contents of buildspec in JSON format. |
Cache | Caching strategy to use. |
CheckSecretsInPlainTextEnvVariables | 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 | Maximum number of concurrent builds. |
Description | A description of the project. |
EncryptionKey | Encryption key to use to read and write artifacts. |
Environment | Build environment to use for the build. |
EnvironmentVariables | Additional environment variables to add to the build environment. |
FileSystemLocations | An ProjectFileSystemLocation objects for a CodeBuild build project. |
GrantReportGroupPermissions | Add permissions to this project's role to create and use test report groups with name starting with the name of this project. |
Logging | Information about logs for the build project. |
ProjectName | The physical, human-readable name of the CodeBuild Project. |
QueuedTimeout | The number of minutes after which AWS CodeBuild stops the build if it's still in queue. |
Role | Service Role to assume while running the build. |
SecurityGroups | What security group to associate with the codebuild project's network interfaces. |
SsmSessionPermissions | Add the permissions necessary for debugging builds with SSM Session Manager. |
SubnetSelection | Where to place the network interfaces within the VPC. |
Timeout | The number of minutes after which AWS CodeBuild stops the build if it's not complete. |
Vpc | VPC network to place codebuild network interfaces. |
Constructors
PipelineProjectProps()
public PipelineProjectProps()
Properties
AllowAllOutbound
Whether to allow the CodeBuild to send all network traffic.
public Nullable<bool> AllowAllOutbound { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
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.
Default: true
Badge
Indicates whether AWS CodeBuild generates a publicly accessible URL for your project's build badge.
public Nullable<bool> Badge { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
For more information, see Build Badges Sample in the AWS CodeBuild User Guide.
Default: false
BuildSpec
Filename or contents of buildspec in JSON format.
public BuildSpec BuildSpec { get; set; }
Property Value
Remarks
Default: - Empty buildspec.
See: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-example
Cache
Caching strategy to use.
public Cache Cache { get; set; }
Property Value
Remarks
Default: Cache.none
CheckSecretsInPlainTextEnvVariables
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.
public Nullable<bool> CheckSecretsInPlainTextEnvVariables { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
ConcurrentBuildLimit
Maximum number of concurrent builds.
public Nullable<double> ConcurrentBuildLimit { get; set; }
Property Value
System.Nullable<System.Double>
Remarks
Minimum value is 1 and maximum is account build limit.
Default: - no explicit limit is set
Description
A description of the project.
public string Description { get; set; }
Property Value
System.String
Remarks
Use the description to identify the purpose of the project.
Default: - No description.
EncryptionKey
Encryption key to use to read and write artifacts.
public IKey EncryptionKey { get; set; }
Property Value
Remarks
Default: - The AWS-managed CMK for Amazon Simple Storage Service (Amazon S3) is used.
Environment
Build environment to use for the build.
public IBuildEnvironment Environment { get; set; }
Property Value
Remarks
Default: BuildEnvironment.LinuxBuildImage.STANDARD_1_0
EnvironmentVariables
Additional environment variables to add to the build environment.
public IDictionary<string, IBuildEnvironmentVariable> EnvironmentVariables { get; set; }
Property Value
System.Collections.Generic.IDictionary<System.String, IBuildEnvironmentVariable>
Remarks
Default: - No additional environment variables are specified.
FileSystemLocations
An ProjectFileSystemLocation objects for a CodeBuild build project.
public IFileSystemLocation[] FileSystemLocations { get; set; }
Property Value
Remarks
A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System.
Default: - no file system locations
GrantReportGroupPermissions
Add permissions to this project's role to create and use test report groups with name starting with the name of this project.
public Nullable<bool> GrantReportGroupPermissions { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
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.
Default: true
See: https://docs.aws.amazon.com/codebuild/latest/userguide/test-report-group-naming.html
Logging
Information about logs for the build project.
public ILoggingOptions Logging { get; set; }
Property Value
Remarks
A project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.
Default: - no log configuration is set
ProjectName
The physical, human-readable name of the CodeBuild Project.
public string ProjectName { get; set; }
Property Value
System.String
Remarks
Default: - Name is automatically generated.
QueuedTimeout
The number of minutes after which AWS CodeBuild stops the build if it's still in queue.
public Duration QueuedTimeout { get; set; }
Property Value
Remarks
For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.
Default: - no queue timeout is set
Role
Service Role to assume while running the build.
public IRole Role { get; set; }
Property Value
Remarks
Default: - A role will be created.
SecurityGroups
What security group to associate with the codebuild project's network interfaces.
public ISecurityGroup[] SecurityGroups { get; set; }
Property Value
Remarks
If no security group is identified, one will be created automatically.
Only used if 'vpc' is supplied.
Default: - Security group will be automatically created.
SsmSessionPermissions
Add the permissions necessary for debugging builds with SSM Session Manager.
public Nullable<bool> SsmSessionPermissions { get; set; }
Property Value
System.Nullable<System.Boolean>
Remarks
If the following prerequisites have been met:
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
.
Default: false
See: https://docs.aws.amazon.com/codebuild/latest/userguide/session-manager.html
SubnetSelection
Where to place the network interfaces within the VPC.
public ISubnetSelection SubnetSelection { get; set; }
Property Value
Remarks
To access AWS services, your CodeBuild project needs to be in one of the following types of subnets:
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
See: https://docs.aws.amazon.com/codebuild/latest/userguide/vpc-support.html for more details.
Timeout
The number of minutes after which AWS CodeBuild stops the build if it's not complete.
public Duration Timeout { get; set; }
Property Value
Remarks
For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.
Default: Duration.hours(1)
Vpc
VPC network to place codebuild network interfaces.
public IVpc Vpc { get; set; }
Property Value
Remarks
Specify this if the codebuild project needs to access resources in a VPC.
Default: - No VPC is specified.