CodeBuildActionProps Struct
Construction properties of the CodeBuildAction CodeBuild build CodePipeline action.
Example
// 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,
}),
],
},
],
});
Properties
Note that Action names must be unique within a single Stage.
checkSecretsInPlainTextEnvVariablesbooleancheck_secrets_in_plain_text_env_variablesboolcheckSecretsInPlainTextEnvVariablesBooleanCheckSecretsInPlainTextEnvVariablesboolCheckSecretsInPlainTextEnvVariables*bool= true#combineBatchBuildArtifactsbooleancombine_batch_build_artifactsboolcombineBatchBuildArtifactsBooleanCombineBatchBuildArtifactsboolCombineBatchBuildArtifacts*bool= false#Enabling this will combine the build artifacts into the same location for batch builds. If executeBatchBuild is not set to true, this property is ignored.
environmentVariables{ [key: string]: BuildEnvironmentVariable }environment_variablestyping.Mapping[str, BuildEnvironmentVariable]environmentVariablesMap<String, BuildEnvironmentVariable>EnvironmentVariablesIDictionary<string, BuildEnvironmentVariable>EnvironmentVariables*map[string]BuildEnvironmentVariable= No additional environment variab…#If a variable with the same name was set both on the project level, and here, this value will take precedence.
default
Default: No additional environment variables are specified.
executeBatchBuildbooleanexecute_batch_buildboolexecuteBatchBuildBooleanExecuteBatchBuildboolExecuteBatchBuild*bool= false#Enabling this will enable batch builds on the CodeBuild project.
extraInputsArtifact[]extra_inputstyping.List[Artifact]extraInputsList<Artifact>ExtraInputsArtifact[]ExtraInputs*[]Artifact#notes
The directories the additional inputs will be available at are available during the project's build in the CODEBUILD_SRC_DIR_<artifact-name> environment variables. The project's build always starts in the directory with the primary input artifact checked out, the one pointed to by the input property. For more information, see https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html .
outputsArtifact[]outputstyping.List[Artifact]outputsList<Artifact>OutputsArtifact[]Outputs*[]Artifact= the action will not have any out…#notes · default
Note: if you specify more than one output Artifact here, you cannot use the primary 'artifacts' section of the buildspec; you have to use the 'secondary-artifacts' section instead. See https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html for details.
Default: the action will not have any outputs
notes
The Pipeline's Role will assume this Role (the required permissions for that will be granted automatically) right before executing this Action. This Action will be passed into your IAction.bind method in the ActionBindOptions.role property.
RunOrder determines the relative order in which multiple Actions in the same Stage execute.
typeCodeBuildActionTypetypeCodeBuildActionTypetypeCodeBuildActionTypeTypeCodeBuildActionTypeTypeCodeBuildActionType= CodeBuildActionType.BUILD#variablesNamespacestringvariables_namespacestrvariablesNamespaceStringVariablesNamespacestringVariablesNamespace*string= a name will be generated, based …#default
Default: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set