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.104.0 (build e79254c)",
date="2024-11-22T02:23:58.959Z")
@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 classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.codepipeline.IAction
IAction.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
CodeBuildAction
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CodeBuildAction
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionprotected ActionConfig
bound
(software.constructs.Construct scope, IStage _stage, ActionBindOptions options) This is a renamed version of theIAction.bind
method.Reference a CodePipeline variable defined by the CodeBuild project this action points to.Methods inherited from class software.amazon.awscdk.services.codepipeline.actions.Action
getProvidedActionProperties
Methods inherited from class software.amazon.awscdk.services.codepipeline.Action
bind, getActionProperties, onStateChange, onStateChange, onStateChange, variableExpression
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 software.constructs.Construct scope, @NotNull IStage _stage, @NotNull ActionBindOptions options) This is a renamed version of theIAction.bind
method. -
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:
-