Skip to content
v2.275.0

VariableProps Struct ​

Properties of pipeline-level variable.

Example ​

ts
declare const sourceAction: codepipeline_actions.S3SourceAction;
declare const sourceOutput: codepipeline.Artifact;
declare const deployBucket: s3.Bucket;

// Pipeline-level variable
const variable = new codepipeline.Variable({
  variableName: 'bucket-var',
  description: 'description',
  defaultValue: 'sample',
});

new codepipeline.Pipeline(this, 'Pipeline', {
  pipelineType: codepipeline.PipelineType.V2,
  variables: [variable],
  stages: [
    {
      stageName: 'Source',
      actions: [sourceAction],
    },
    {
      stageName: 'Deploy',
      actions: [
        new codepipeline_actions.S3DeployAction({
          actionName: 'DeployAction',
          // can reference the variables
          objectKey: `${variable.reference()}.txt`,
          input: sourceOutput,
          bucket: deployBucket,
        }),
      ],
    },
  ],
});

Properties ​

defaultValueoptionalstringdefault_valueoptionalstrdefaultValueoptionalStringDefaultValueoptionalstringDefaultValueoptional*string#
The default value of a pipeline-level variable.

Default: No default value.

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
The description of a pipeline-level variable.

Default: No description.

It's used to add additional context about the variable, and not being used at time when pipeline executes.

variableNamestringvariable_namestrvariableNameStringVariableNamestringVariableName*stringrequired#
The name of a pipeline-level variable.