Interface IPipelineProjectProps
Inherited Members
Namespace: Amazon.CDK.AWS.CodeBuild
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IPipelineProjectProps : ICommonProjectProps
Syntax (vb)
Public Interface IPipelineProjectProps
Inherits 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
}) }
} }
});