Class CodeBuildAction
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.codepipeline.Action
software.amazon.awscdk.services.codepipeline.actions.Action
software.amazon.awscdk.services.codepipeline.actions.CodeBuildAction
- All Implemented Interfaces:
IAction,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:48.384Z")
@Stability(Stable)
public class CodeBuildAction
extends Action
CodePipeline build action that uses AWS CodeBuild.
Example:
// 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();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.codepipeline.IAction
IAction.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCodeBuildAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCodeBuildAction(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionprotected ActionConfigbound(Construct scope, IStage _stage, ActionBindOptions options) This is a renamed version of theIAction.bindmethod.Reference a CodePipeline variable defined by the CodeBuild project this action points to.Methods inherited from class software.amazon.awscdk.services.codepipeline.actions.Action
getProvidedActionPropertiesMethods inherited from class software.amazon.awscdk.services.codepipeline.Action
bind, getActionProperties, onStateChange, onStateChange, onStateChange, variableExpressionMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
CodeBuildAction
protected CodeBuildAction(software.amazon.jsii.JsiiObjectRef objRef) -
CodeBuildAction
protected CodeBuildAction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CodeBuildAction
- Parameters:
props- This parameter is required.
-
-
Method Details
-
bound
@Stability(Stable) @NotNull protected ActionConfig bound(@NotNull Construct scope, @NotNull IStage _stage, @NotNull ActionBindOptions options) This is a renamed version of theIAction.bindmethod. -
variable
Reference a CodePipeline variable defined by the CodeBuild project this action points to.Variables in CodeBuild actions are defined using the 'exported-variables' subsection of the 'env' section of the buildspec.
- Parameters:
variableName- the name of the variable to reference. This parameter is required.- See Also:
-